/* 读经会考 · 出席登记 —— 移动优先样式表
   设计目标：手机上单手可操作、信息层次清楚、状态一眼可辨。 */

:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #16211c;
  --ink-2: #3d4a44;
  --muted: #6d7d75;
  --line: #e2e8e4;
  --line-strong: #cfd8d2;
  --primary: #1c6b4a;
  --primary-dark: #14523a;
  --primary-soft: #e8f3ee;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #b3261e;
  --red-soft: #fdeceb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(22, 33, 28, .05), 0 6px 18px rgba(22, 33, 28, .05);
  --tap: 44px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- 外壳 ---------- */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; padding: 16px 14px 40px; max-width: 1120px; margin: 0 auto; width: 100%; }

footer {
  padding: 16px 14px calc(20px + env(safe-area-inset-bottom));
  color: var(--muted); font-size: 12px; text-align: center;
  border-top: 1px solid var(--line); background: var(--surface);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 17px; font-weight: 700;
}
.brand-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edition { font-size: 11px; color: var(--muted); white-space: nowrap; }
.account-area { display: flex; align-items: center; gap: 8px; flex: none; }
.who { text-align: right; line-height: 1.25; }
.who strong { display: block; font-size: 12px; }
.who span { display: none; }

/* ---------- 按钮 ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, transform .06s;
  white-space: nowrap;
}
.button:active { transform: translateY(1px); }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); }
.button-confirm { background: var(--primary-soft); color: var(--primary-dark); border-color: #bfe0d1; }
.button-muted { background: var(--surface-2); color: var(--ink-2); border-color: var(--line-strong); }
.button-quiet { background: transparent; color: var(--muted); border-color: var(--line-strong); }
.button:disabled { opacity: .5; cursor: not-allowed; }
#logout { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* ---------- 登录页 ---------- */
.login-wrap { display: grid; gap: 20px; padding-top: 12px; }
.eyebrow {
  display: inline-block; margin-bottom: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  color: var(--primary); text-transform: uppercase;
}
.login-copy h1 { font-size: 30px; margin-bottom: 10px; }
.login-copy p { color: var(--muted); font-size: 14.5px; }
.login-callout {
  margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--amber-soft); border: 1px solid #f0dcc0;
  font-size: 13px; color: #7a4a10;
}
.login-callout strong { display: block; margin-bottom: 2px; }
.login-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow);
  display: grid; gap: 14px;
}
.login-card h2 { font-size: 19px; }
.login-card p { font-size: 13px; color: var(--muted); }
label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
input, select {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.error-text { color: var(--red); font-size: 13.5px; min-height: 1em; }

/* ---------- 页面标题区 ---------- */
.heading-row { display: grid; gap: 10px; margin-bottom: 16px; }
#pageTitle { font-size: 24px; }
#pageDescription { font-size: 14px; color: var(--muted); }
.snapshot { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------- 统计卡 ---------- */
.summary-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px;
}
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  display: grid; gap: 2px; align-content: start;
}
.metric-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.metric strong { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
.metric small { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.metric:nth-child(2) strong { color: var(--primary); }
.metric:nth-child(3) strong { color: var(--amber); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-title h2 { font-size: 17px; }
.count-chip {
  flex: none; padding: 4px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 12px; font-weight: 700;
}

/* ---------- 分区进度 ---------- */
.region-grid { display: grid; gap: 12px; }
.region-row { display: grid; gap: 5px; }
.region-line { display: flex; justify-content: space-between; font-size: 13.5px; }
.region-line span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 999px; background: #e8eeea; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .3s; }

/* ---------- 筛选 ---------- */
.filters { display: grid; gap: 8px; margin-bottom: 12px; }
.searchbox {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; min-height: var(--tap);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2);
}
.searchbox span { color: var(--muted); font-size: 16px; }
.searchbox input { border: none; background: transparent; padding: 0; min-height: auto; }
.searchbox input:focus { outline: none; }

/* ---------- 批量操作条 ---------- */
.bulkbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--primary-soft); border: 1px solid #bfe0d1; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; color: var(--primary-dark);
}
.bulkbar > div { display: flex; gap: 8px; flex-wrap: wrap; }
.bulkbar .button { min-height: 38px; font-size: 14px; padding: 0 14px; }

/* ---------- 名单：手机为卡片 ---------- */
.table-scroll { border-radius: var(--radius-sm); }
table, tbody { display: block; width: 100%; }
thead { display: none; }
tbody tr {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name check" "meta meta" "subj subj" "stat stat" "sel sel";
  gap: 6px 10px;
  padding: 14px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
tbody td { border: none; padding: 0; vertical-align: middle; }
tbody td:nth-child(1) { grid-area: check; justify-self: end; }
tbody td:nth-child(2) { grid-area: name; }
tbody td:nth-child(3) { grid-area: meta; }
tbody td:nth-child(4), tbody td:nth-child(5) { display: none; }
tbody td:nth-child(6) { grid-area: subj; }
tbody td:nth-child(7) { grid-area: stat; }
tbody td:nth-child(8) { grid-area: sel; }

tbody input[type=checkbox] {
  width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); cursor: pointer;
}
.candidate-name { font-size: 16.5px; font-weight: 700; }
.candidate-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
tbody td:nth-child(3)::before { content: "单位 · "; color: var(--muted); font-size: 12.5px; }
tbody td:nth-child(3) { font-size: 12.5px; color: var(--ink-2); }
.subject-list { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.subject-list::before { content: "科段："; color: var(--ink-2); font-weight: 600; }
.group-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2);
}
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-yes { background: var(--primary-soft); color: var(--primary-dark); }
.status-no { background: var(--red-soft); color: var(--red); }
.status-wait { background: var(--amber-soft); color: var(--amber); }
.status-select { font-size: 15px; }

.empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- 账号与记录 ---------- */
.admin-panel .section-title { align-items: center; }
.user-form { display: grid; gap: 12px; margin-bottom: 16px; }
.user-form .button { justify-self: start; }
.user-list, .audit-list { display: grid; gap: 8px; }
.user-row, .audit-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 13.5px;
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 999px;
  background: #16211c; color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 平板及以上 ---------- */
@media (min-width: 720px) {
  main { padding: 24px 24px 56px; }
  .topbar { padding: 12px 24px; }
  .brand-name { font-size: 15px; }
  .who span { display: block; font-size: 11px; color: var(--muted); }
  .summary-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .metric strong { font-size: 34px; }
  #pageTitle { font-size: 28px; }
  .heading-row { grid-template-columns: 1fr auto; align-items: start; }
  .snapshot { text-align: right; }
  .filters { grid-template-columns: 1fr 170px 150px 170px; align-items: center; }
  .login-wrap { grid-template-columns: 1fr 400px; align-items: center; gap: 40px; padding-top: 40px; }
  .region-grid { grid-template-columns: repeat(2, 1fr); gap: 14px 24px; }
  .user-form { grid-template-columns: repeat(2, 1fr); }
  .user-form .scope-label, .user-form .button, .user-form .error-text { grid-column: 1 / -1; }

  /* 桌面回到表格 */
  .table-scroll { overflow-x: auto; }
  table, tbody { display: table; width: 100%; }
  thead { display: table-header-group; }
  table { border-collapse: separate; border-spacing: 0; font-size: 14px; }
  thead th {
    position: sticky; top: 0; z-index: 2;
    padding: 10px 12px; text-align: left; white-space: nowrap;
    background: var(--surface-2); color: var(--muted);
    font-size: 12.5px; font-weight: 700; border-bottom: 1px solid var(--line);
  }
  tbody tr { display: table-row; margin: 0; border: none; box-shadow: none; border-radius: 0; }
  tbody tr:nth-child(even) { background: var(--surface-2); }
  tbody td { display: table-cell; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  tbody td:nth-child(4), tbody td:nth-child(5) { display: table-cell; }
  tbody td:nth-child(3)::before { content: none; }
  tbody td:nth-child(3) { font-size: 14px; color: var(--ink); }
  .subject-list::before { content: none; }
  .subject-list { max-width: 260px; }
  .candidate-name { font-size: 14.5px; }
  .status-select { min-height: 38px; font-size: 14px; }
  .empty { padding: 40px; }
  tbody tr:hover { box-shadow: none; background: var(--primary-soft); }
}

/* ---------- 微交互：悬停 / 按下 / 聚焦 ---------- */
:root { --ease: cubic-bezier(.2,.8,.2,1); }

.button {
  transition: background .2s var(--ease), transform .18s var(--ease),
              box-shadow .25s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(28,107,74,.24); }
.button:active:not(:disabled) { transform: translateY(0) scale(.965); box-shadow: 0 2px 8px rgba(28,107,74,.18); }
.button:focus-visible { outline: 3px solid rgba(28,107,74,.45); outline-offset: 2px; }
.button-quiet:hover:not(:disabled) {
  background: var(--primary-soft); border-color: #bfe0d1; color: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(28,107,74,.14);
}
.button-muted:hover:not(:disabled) { background: #eef2f0; box-shadow: 0 6px 16px rgba(22,33,28,.10); }

.metric { transition: transform .28s var(--ease), box-shadow .28s var(--ease), border-color .28s var(--ease); }
.metric:hover {
  transform: translateY(-2px); border-color: rgba(28,107,74,.30);
  box-shadow: 0 10px 26px rgba(28,107,74,.12);
}

tbody tr { transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease); }
tbody tr:hover { border-color: rgba(28,107,74,.35); box-shadow: 0 8px 24px rgba(28,107,74,.12); }
tbody tr:active { transform: scale(.995); }

.panel { transition: border-color .28s var(--ease), box-shadow .28s var(--ease); }
.panel:hover { border-color: var(--line-strong); }

input, select { transition: border-color .2s var(--ease), box-shadow .25s var(--ease); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(28,107,74,.14); }
.bar i { transition: width .5s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .metric:hover, tbody tr:hover, tbody tr:active, .button:hover:not(:disabled) { transform: none; }
}
