/* ==========================================================================
   学校晨午检汇总系统 —— 样式表
   设计目标：浅色主题、大字体（教师用）、移动端友好、汇总表还原纸质表格
   ========================================================================== */

:root {
  /* 浅色 · 清爽 · 教师办公风格（2026-11-01 改版：墨蓝主色，靠留白与细线分层） */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --subtle: #f2f4f7;
  --border: #e4e8ef;
  --border-strong: #cfd6e0;
  --text: #1a2233;
  --text-soft: #5a6472;
  --text-mute: #8a93a2;
  --primary: #2563a8;
  --primary-dark: #1e4e88;
  --primary-soft: #eef4fb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --success: #15803d;
  --success-bg: #ecfdf3;
  --warn: #b45309;
  --warn-bg: #fffaeb;
  --radius: 12px;
  --fs-base: 16px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: var(--fs-base);
  line-height: 1.6;
  /* 数字等宽：表格里的手机号、人数、日期纵向对齐，扫读更快 */
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ---------------- 访问口令门 ---------------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.06);
  text-align: center;
}
.gate-title { margin: 0 0 6px; font-size: 22px; }
.gate-sub { margin: 0 0 18px; color: var(--text-soft); font-size: 15px; }
.gate-input {
  width: 100%;
  font-size: 20px;
  text-align: center;
  letter-spacing: 2px;
  padding: 12px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  margin-bottom: 14px;
  outline: none;
}
.gate-input:focus { border-color: var(--primary); }

/* ---------------- 登录 / 注册 / 身份设置 ---------------- */
.auth-box {
  max-width: 420px;
  text-align: left;
  padding: 24px 22px;
}
.auth-box .gate-title { text-align: center; }
.auth-box .gate-sub { text-align: center; }

.seg-row {
  display: flex;
  gap: 6px;
  margin: 4px 0 16px;
  border-bottom: 1px solid var(--border);
}
.seg-btn {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-soft);
  padding: 10px 4px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  min-height: 44px;
}
.seg-btn.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.otp-row { display: flex; gap: 8px; align-items: stretch; }
.otp-row input { flex: 1 1 auto; width: auto; }
.otp-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* 登录状态保持：勾选项（小字号） */
.keep-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
}
.keep-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.keep-opt input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-hint {
  margin: 6px 0 0;
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.55;
}
.form-hint:empty { display: none; }

/* 固定值输入框：只读，视觉上弱化，提示用户无需填写 */
.input-fixed {
  background: var(--subtle);
  color: var(--text-soft);
  cursor: default;
}

.stack-gap { margin-top: 10px; }

.owner-tip {
  margin: -4px 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--subtle);
  border: none;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 9px 12px;
}
.owner-tip:empty { display: none; }

/* ---------------- 布局 ---------------- */
.app { min-height: 100vh; padding-bottom: 40px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.user-email {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 16px;
  font-weight: 600;
  padding: 11px 8px;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.tab-btn:hover { background: var(--subtle); color: var(--text); }
.tab-btn.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  border-bottom-color: var(--primary);
}

.app-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* ============ 左侧导航：三组（请假填报 / 办公打印 / 基础数据） ============ */
.app-body {
  display: flex;
  align-items: flex-start;
  max-width: 1420px;
  margin: 0 auto;
}
.app-body .app-main {
  flex: 1 1 auto;
  min-width: 0;
}

.side-nav {
  flex: 0 0 208px;
  width: 208px;
  position: sticky;
  top: 62px;
  max-height: calc(100vh - 62px);
  overflow-y: auto;
  padding: 14px 10px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background: #1e4e88;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.side-nav-brand {
  padding: 0 8px 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.side-nav-title { font-size: 14px; font-weight: 700; color: #ffffff; }
.side-nav-sub { font-size: 12px; color: rgba(255, 255, 255, 0.66); margin-top: 2px; }

.side-nav-groups { display: flex; flex-direction: column; gap: 2px; }

.nav-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: left;
}
.nav-group-head:hover { background: rgba(255, 255, 255, 0.10); color: #ffffff; }
.nav-caret {
  flex: none;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transform: rotate(-90deg);
  transition: transform 0.15s;
  opacity: 0.7;
}
.nav-group-head.is-open .nav-caret { transform: rotate(0deg); }

.nav-group-items { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 8px; }

.nav-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 9px 10px 9px 18px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.10); color: #ffffff; }
.nav-item.is-active { background: rgba(255, 255, 255, 0.16); color: #ffffff; }
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: #8fc2ff;
}

/* 纵向排列顺序：组名 → 该组子项，交替（保证折叠时子项紧跟组名） */
.side-nav-groups [data-group-toggle="leave"] { order: 1; }
.side-nav-groups [data-group-items="leave"] { order: 2; }
.side-nav-groups [data-group-toggle="print"] { order: 3; }
.side-nav-groups [data-group-items="print"] { order: 4; }
.side-nav-groups [data-group-toggle="base"] { order: 5; }
.side-nav-groups [data-group-items="base"] { order: 6; }

.side-nav-foot {
  margin-top: 14px;
  padding: 10px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 个人中心页：两列自适应表单 */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 18px;
}
#tab-profile .card + .card { margin-top: 16px; }

/* 窄屏：左栏收为顶部两行横条（组名一行 + 当前组子项一行可横滑） */
@media (max-width: 900px) {
  .app-body { flex-direction: column; align-items: stretch; }
  .side-nav {
    position: static;
    flex: none;
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 8px 10px 10px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  }
  .side-nav-brand { display: none; }
  .side-nav-groups { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; min-width: 0; }
  .side-nav-groups [data-group-toggle] {
    order: 0;
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    justify-content: center;
    padding: 8px 6px;
    font-size: 13px;
  }
  .side-nav-groups [data-group-items] {
    order: 1;
    flex: 1 1 100%;
    min-width: 0;
    flex-direction: row;
    gap: 6px;
    padding: 2px 0 0;
    overflow-x: auto;
  }
  .side-nav-groups [data-group-items] .nav-item {
    width: auto;
    padding: 8px 12px;
    white-space: nowrap;
  }
  .nav-item.is-active::before { display: none; }
  .side-nav-foot { display: none; }
  /* margin:auto 在纵向 flex 里会禁用宽度拉伸 → 主区被内容最小宽度撑宽、整页横向溢出 */
  .app-body .app-main { max-width: none; width: 100%; margin: 0; padding: 14px 12px 30px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.card-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding-left: 10px;
  border-left: 3px solid var(--primary);
  line-height: 1.4;
}
.section-title {
  margin: 24px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
  border-left: 3px solid var(--primary);
  padding: 0 0 0 10px;
  line-height: 1.4;
}

/* ---------------- 表单 ---------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field { margin-bottom: 14px; display: flex; flex-direction: column; }
.field > label, .label-block {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.req { color: var(--danger); margin-left: 2px; }

input[type="text"], input[type="tel"], input[type="number"],
input[type="date"], input[type="password"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 168, 0.15);
}

.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}
.radio-item input { width: 20px; height: 20px; min-height: 0; }

.sick-block {
  border: 1px solid #f0c36d;
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.hint-warn {
  margin: 0 0 10px;
  font-size: 15px;
  color: #93370d;
  font-weight: 600;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.form-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  min-height: 0;
}
.form-error:empty { display: none; }
.form-success {
  margin: 10px 0 0;
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid #abefc6;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
}
.form-success:empty { display: none; }

/* ---------------- 按钮 ---------------- */
.btn {
  appearance: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 42px;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #a8c2de; cursor: not-allowed; }
.btn-ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--subtle); border-color: var(--text-mute); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; }
.btn-warn { background: #d97706; color: #fff; }
.btn-warn:hover { background: #b45309; }
.btn-sm { font-size: 14px; padding: 4px 12px; min-height: 30px; }
.btn-xs { font-size: 12px; padding: 2px 8px; min-height: 26px; line-height: 1.4; }
.btn-block { width: 100%; display: block; }

/* 家长入口按钮（登录页，醒目橙色） */
.btn-parent { background: #e8590c; color: #fff; border-color: #e8590c; }
.btn-parent:hover { background: #d9480f; border-color: #d9480f; }
.btn-parent:disabled { background: #f3a878; border-color: #f3a878; cursor: not-allowed; }

/* ---------------- 等待审批屏 ---------------- */
.pending-info {
  border: 1px solid var(--border);
  background: var(--subtle);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  text-align: left;
}
.pending-label { margin: 0 0 4px; font-size: 14px; color: var(--text-soft); }
.pending-email {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  word-break: break-all;
}

/* 顶栏身份徽标（班主任 / 汇总人 / 家长） */
.user-role {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  padding: 2px 12px;
  white-space: nowrap;
}
.user-role:empty { display: none; }
.user-email:empty { display: none; }

/* 邮箱登录与家长入口之间的分隔线 */
.login-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  color: var(--text-soft);
  font-size: 14px;
}
.login-or::before,
.login-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.inline-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}
.inline-label { font-size: 16px; font-weight: 600; }
.inline-input { width: auto; min-width: 170px; flex: 0 1 auto; }

/* 口径开关：默认只统计工作日，勾选后含双休日 */
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-soft);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.inline-check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.inline-check:hover { border-color: var(--primary); }

/* ---------------- 统计小卡 ---------------- */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-box {
  flex: 1 1 160px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--subtle);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* 数字在上、标签在下：汇总人一眼读到关键数 */
.stat-label { order: 2; font-size: 13px; color: var(--text-soft); }
.stat-value {
  order: 1;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.25;
}
#sm-absent.stat-value { color: var(--danger); }
#sm-sick.stat-value { color: var(--warn); }

/* ---------------- 记录卡片（返校登记） ---------------- */
.record-list { display: flex; flex-direction: column; gap: 14px; }
.rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.rec-card.is-unreturned {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.rec-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.rec-name { font-size: 19px; font-weight: 700; }
.rec-sub { font-size: 15px; color: var(--text-soft); }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 8px;
  background: var(--subtle);
  color: var(--text-soft);
  border: 1px solid var(--border);
  line-height: 1.6;
}
/* 状态一律「浅底深字」，不用大色块，降低整页噪音 */
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecdca; }
.badge-sick { background: var(--warn-bg); color: #93370d; border-color: #f0c36d; }
.badge-ok { background: var(--success-bg); color: var(--success); border-color: #a7e0bb; }
/* 请假审批状态：待审批（琥珀色，与「已驳回」的红色区分开） */
.badge-wait { background: var(--warn-bg); color: var(--warn); border-color: #f0c36d; }
/* 记录卡片上的驳回原因 */
.rec-reject {
  margin: -4px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fecdca;
  border-radius: 8px;
  padding: 6px 10px;
  word-break: break-word;
}
/* 记录卡片上的审批人与审批时间（审计用，待审批不渲染） */
.rec-approve {
  margin: -4px 0 10px;
  font-size: 14px;
  color: var(--text-soft);
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  word-break: break-word;
}
.rec-approve:empty { display: none; }
/* 「包含待审批」勾选项 */
.check-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* 本班情况：未返校行标红底，表格横向可滚动 */
.cv-table { width: 100%; }
.cv-table td { white-space: nowrap; }
table.user-table tr.is-unreturned td { background: var(--danger-bg); }
table.user-table tr.is-unreturned td:first-child { border-left: 4px solid var(--danger); }
.cv-table-wrap { overflow-x: auto; }
@media (max-width: 640px) {
  .cv-table { font-size: 12px; }
  .cv-table th, .cv-table td { padding: 6px; }
}

.rec-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.empty-tip {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-soft);
  font-size: 16px;
}

/* ---------------- 用户管理（仅汇总人） ---------------- */
.user-list { overflow-x: auto; }
table.user-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table.user-table th,
table.user-table td {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 7px 12px;
  height: 40px;
  text-align: left;
  vertical-align: middle;
  word-break: break-word;
}
table.user-table thead th {
  background: var(--subtle);
  border-bottom: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
  height: 40px;
}
/* 斑马纹 + 悬停：长表格横向扫读不串行（:where 压低优先级，不覆盖下方的状态色） */
table.user-table tbody tr:where(:nth-child(even)) td { background: #fafbfc; }
table.user-table tbody tr:where(:hover) td { background: var(--primary-soft); }
table.user-table tbody tr:last-child td { border-bottom: none; }
/* 待审批账号置顶标红 */
table.user-table tr.is-pending td { background: var(--danger-bg); }
table.user-table tr.is-pending td:first-child { border-left: 3px solid var(--danger); }
.user-actions { white-space: nowrap; }
.user-actions .btn + .btn { margin-left: 8px; }
.badge-pending { background: var(--danger-bg); color: var(--danger); border-color: #fecdca; }
.badge-approved { background: var(--success-bg); color: var(--success); border-color: #a7e0bb; }
.badge-muted { background: var(--subtle); color: var(--text-soft); border-color: var(--border); }

/* ---------------- 学生名册（仅汇总人） ---------------- */
.bulk-input {
  width: 100%;
  font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.6;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.table-wrap { overflow-x: auto; }
table.user-table tr.is-bad td { background: var(--danger-bg); }
table.user-table tr.is-bad td:first-child { border-left: 3px solid var(--danger); }
table.user-table tr.is-inactive td { color: var(--text-mute); background: #fafbfc; }
table.user-table td.mono { font-family: Consolas, Menlo, monospace; white-space: nowrap; font-size: 14px; }
.op-cell { white-space: nowrap; }
.op-cell .btn + .btn { margin-left: 6px; }
.check-cell { width: 38px; text-align: center; }
.check-cell input { width: 18px; height: 18px; cursor: pointer; vertical-align: middle; }
/* 名册：班级 / 姓名 列不换行，长内容留给后面的宽列 */
.st-table td:nth-child(2), .st-table td:nth-child(3) { white-space: nowrap; }
@media (max-width: 640px) {
  .st-table { font-size: 13px; }
  .st-table th, .st-table td { padding: 6px 8px; }
}

/* ---------------- 纸质汇总表 ---------------- */
/* 打印区容器：内容由 summary.js 按 record_date 动态渲染，每天一个 .print-page */
.print-area { overflow-x: auto; }
/* 区间内无记录时的屏幕提示（带 no-print，不会被打印出来） */
.print-empty {
  margin: 0;
  padding: 18px 16px;
  color: var(--text-soft);
  font-size: 14px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.print-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.print-head { text-align: center; margin-bottom: 12px; }
.print-title { font-size: 21px; font-weight: 700; letter-spacing: 1px; }
.print-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: center;
  font-size: 15px;
  color: var(--text-soft);
}
.print-meta b { color: var(--text); }

table.paper-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 15px;
}
table.paper-table th,
table.paper-table td {
  border: 1px solid #000;
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
  word-break: break-word;
}
table.paper-table thead th {
  font-weight: 700;
  background: #f2f4f7;
}
table.paper-table .col-no { width: 46px; }
table.paper-table .col-narrow { width: 74px; }
table.paper-table .empty-cell { color: var(--text-soft); }
table.paper-table .label-cell { font-weight: 700; background: #f2f4f7; width: 92px; }
table.paper-table .note-cell { text-align: left; min-height: 40px; }

.print-sign {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 16px;
}
.print-sign b {
  display: inline-block;
  min-width: 80px;
  border-bottom: 1px solid #000;
  padding: 0 6px;
  font-weight: 700;
}
/* 签名位由 <b> 改为 <span>，保留同样的下划线占位样式，签名图片直接插在里面 */
.print-sign .sign-slot {
  display: inline-block;
  min-width: 80px;
  border-bottom: 1px solid #000;
  padding: 0 6px;
  vertical-align: middle;
}
.sign-img {
  height: 34px;
  max-width: 150px;
  vertical-align: middle;
}
/* 文字签名：用楷体模拟手写体 */
.print-sign .sign-text {
  font-family: "KaiTi", "STKaiti", "楷体", "SimKai", cursive;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  display: inline-block;
}

/* ---------------- 签名字段（手写 / 文字 双模式） ---------------- */
.sign-mode-row {
  display: flex;
  gap: 16px;
  margin: 2px 0 8px;
}
.sign-mode-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.sign-mode-item input[type="radio"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
/* 手写模式：可点击的签名框，点一下进入全屏签名 */
.sign-slot-box {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s;
}
.sign-slot-box:hover,
.sign-slot-box:focus-visible {
  border-color: var(--primary);
}
.sign-slot-box.has-sign {
  border-style: solid;
  padding: 4px;
}
.sign-placeholder {
  color: #9ca3af;
  font-size: 13px;
  user-select: none;
}
.sign-slot-box .sign-placeholder[hidden] { display: none; }
.sign-preview {
  max-height: 68px;
  max-width: 100%;
  display: block;
}
.sign-clear { margin-top: 8px; }

/* 全屏手写签名弹层 */
.sign-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sign-overlay[hidden] { display: none; }
.sign-overlay-card {
  background: #fff;
  border-radius: 12px;
  width: min(680px, 100%);
  padding: 14px 16px 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}
.sign-overlay-title {
  margin: 0 0 8px;
  font-size: 15px;
  text-align: center;
}
.sign-overlay-canvas {
  display: block;
  width: 100%;
  height: min(46vh, 340px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #fff;
  /* 虚线基线用 CSS 背景实现：不进入 canvas 位图，导出的签名图片不带辅助线 */
  background-image: repeating-linear-gradient(90deg, #c2cadb 0 7px, transparent 7px 14px);
  background-size: 100% 1px;
  background-position: 0 72%;
  background-repeat: no-repeat;
  cursor: crosshair;
  touch-action: none;
}
.sign-overlay-tip {
  margin: 6px 0 10px;
  font-size: 12px;
  color: var(--text-soft);
  text-align: center;
}
.sign-overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.print-notes {
  margin: 14px 0 0;
  padding-left: 22px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.8;
}

/* ---------------- 通用模态提示：必须点「确定」才能继续 ---------------- */
.app-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1100; /* 高于手写签名浮层（1000），保证须知盖在最上层 */
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.app-modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(440px, 100%);
  padding: 22px 22px 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}
.app-modal-title {
  margin: 0 0 12px;
  font-size: 20px;
  text-align: center;
  color: var(--text);
}
.app-modal-body {
  margin: 0 0 20px;
  font-size: 18px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
}
.app-modal-ok {
  display: block;
  width: 100%;
  min-width: 120px;
  font-size: 18px;
}

/* ---------------- Toast ---------------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(31, 41, 55, 0.94);
  color: #fff;
  font-size: 15px;
  border-radius: 8px;
  padding: 10px 18px;
  max-width: 90vw;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.2);
}
.toast.is-error { background: var(--danger); }
.toast.is-success { background: var(--success); }

/* ---------------- 移动端 ---------------- */
@media (max-width: 640px) {
  :root { --fs-base: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .app-title { font-size: 17px; }
  .app-header-inner { padding: 10px 12px 4px; }
  .app-main { padding: 12px; }
  .card { padding: 16px 14px; }
  .tab-btn { font-size: 13px; padding: 10px 2px; white-space: nowrap; }
  .inline-input { width: 100%; }
  table.paper-table { font-size: 13px; }
  table.user-table { font-size: 14px; }
  table.user-table th, table.user-table td { padding: 7px 8px; }
  .print-title { font-size: 18px; }
}

/* ---------------- 打印：A4 横向，仅打印汇总表 ---------------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }

  html, body {
    background: #fff !important;
    font-size: 12pt;
  }

  body * { visibility: hidden !important; box-shadow: none !important; }

  /* 多天打印：容器改为常规流（absolute 无法正确分页），每天一张表占一页 */
  #app, .app-main { padding: 0 !important; margin: 0 !important; }

  /* 左侧导航整栏隐藏且不占位（否则会把打印区挤到第二页） */
  .side-nav { display: none !important; }
  .app-body { display: block !important; }

  #sm-print, #sm-print * { visibility: visible !important; }

  #sm-print {
    position: static;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    overflow: visible;
  }

  /* 每天一页，最后一页不额外分页 */
  #sm-print .print-page {
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    padding: 0;
    page-break-after: always;
    break-after: page;
  }
  #sm-print .print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  table.paper-table { font-size: 10pt; }
  table.paper-table th,
  table.paper-table td { border: 1px solid #000 !important; }
  table.paper-table thead th { background: #fff !important; }
  table.paper-table .label-cell { background: #fff !important; }

  .print-head { margin-bottom: 8px; }
  .print-title { font-size: 15pt; }
  .print-meta { font-size: 10pt; }
  .print-sign { font-size: 11pt; margin-top: 10px; }
  .print-notes { font-size: 9pt; }

  /* 手写签名图片：#sm-print * 已置为 visible，这里再显式声明，确保打印不被隐藏 */
  .print-sign .sign-img,
  .sign-img {
    display: inline-block !important;
    visibility: visible !important;
    height: 34px;
    max-width: 150px;
    vertical-align: middle;
    border: none;
  }
  .print-sign .sign-slot {
    border-bottom: 1px solid #000 !important;
    min-width: 80px;
  }

  .no-print, .toast-wrap, .app-modal-mask { display: none !important; }
}

/* ============ 个人中心弹窗 ============ */
.profile-card { width: min(420px, 100%); max-height: 86vh; overflow-y: auto; }
.profile-card .field { margin-bottom: 12px; }
.profile-card input[readonly] { color: var(--text-weak, #64748b); background: rgba(100, 116, 139, 0.08); cursor: not-allowed; }
.profile-divider { border: none; border-top: 1px dashed var(--border, #e2e8f0); margin: 18px 0 14px; }
#profile-btn { cursor: help; }

/* ---- 双休日提示横幅（汇总 / 上报 / 返校登记） ---- */
.weekend-tip {
  margin: 6px 0 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #874d00;
  font-size: 13.5px;
  line-height: 1.6;
}

@media print {
  .weekend-tip { display: none !important; }
}

/* ---- 上报页：输入姓名后从学生名册自动带出信息的提示 ---- */
.autofill-tip {
  margin: -4px 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--primary-soft);
  border: 1px solid #cfe0f2;
  color: var(--primary-dark);
  font-size: 13px;
  line-height: 1.6;
}
.autofill-tip.ok { background: var(--success-bg); border-color: #a7e0bb; color: var(--success); }
.autofill-tip.warn { background: var(--warn-bg); border-color: #f0c36d; color: var(--warn); }

@media print {
  .autofill-tip { display: none !important; }
}

/* ---- 用户管理：班级下拉（教师 ↔ 班级 关联） ---- */
.class-select {
  min-width: 118px;
  max-width: 150px;
  padding: 5px 6px;
  font-size: 13px;
}
.class-select:disabled { opacity: .6; }

/* ---- 用户管理：班级申请待审核（教师自助申请，管理员通过/驳回） ---- */
.class-cell { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.class-pending { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.class-pending .badge { font-size: 12px; }
.class-pending .btn-sm { padding: 2px 8px; font-size: 12px; }

/* ---- 用户管理：任教班级多选面板（成绩系统多班绑定，2026-11-16） ---- */
.mc-panel { width: 100%; max-width: 420px; padding: 8px 10px; border: 1px solid var(--line, #d8dee6); border-radius: 6px; background: #f7f9fc; }
.mc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; font-size: 13px; }
.mc-grid label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.mc-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mc-actions .form-hint { font-size: 12px; }

/* ============================================================
   因病缺勤追踪（附件 6）—— 屏幕预览 = 打印版式（所见即所得）
   ============================================================ */
.tk-screen-cap {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-soft);
}
/* 追踪表：12 列公文表，比汇总表更紧凑 */
table.tk-table { font-size: 13px; }
table.tk-table th { font-weight: 700; line-height: 1.3; }
table.tk-table th,
table.tk-table td { padding: 4px 5px; }
table.tk-table .tk-th-date { width: 88px; }
table.tk-table .tk-th-return { width: 92px; }
table.tk-table .tk-nowrap { white-space: nowrap; }
table.tk-table .tk-addr { min-width: 130px; }
table.tk-table .tk-treat { min-width: 120px; font-size: 12px; }
/* 表内可编辑控件：默认无边框融入单元格，聚焦时高亮 */
.tk-edit {
  width: 100%;
  min-width: 44px;
  border: 1px dashed transparent;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  text-align: center;
  padding: 2px 3px;
  box-sizing: border-box;
}
.tk-edit:hover { border-color: var(--border-strong, #cbd5e1); }
.tk-edit:focus {
  outline: none;
  border: 1px solid var(--primary);
  background: #fff;
}
select.tk-edit { cursor: pointer; }
input.tk-return { min-width: 108px; }
/* 表底备注行（附件 6 原文） */
table.tk-table .tk-note {
  text-align: left;
  font-size: 11.5px;
  color: var(--text-soft);
  padding: 6px 8px;
}
/* 打印页标题下的班级 / 区间 / 负责人行 */
.tk-print-sub {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 28px;
  justify-content: center;
  align-items: baseline;
  font-size: 15px;
  font-weight: 700;
}

/* ---------------- 打印：追踪表一班一张（A4 横向由全局 @page 控制） ---------------- */
@media print {
  #tk-print, #tk-print * { visibility: visible !important; }
  /* 面板内工具卡片与屏幕预览（#tk-screen）必须 display:none 彻底移除占位：
     visibility:hidden 仍占布局空间，会把 #tk-print 挤到第一页底部，
     导致表头标题与表格被拆成两页 */
  #tab-tracking > *:not(#tk-print) { display: none !important; }
  #tk-print {
    position: static;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    overflow: visible;
  }
  #tk-print .print-page {
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    padding: 0;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  #tk-print .print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  /* 表头（标题 + 班级/区间/签名行）不与表格分页 */
  #tk-print .print-head {
    page-break-after: avoid;
    break-after: avoid;
    page-break-inside: avoid;
  }
  #tk-print .print-title { font-size: 15pt; margin-bottom: 4px; }
  #tk-print .tk-print-sub { font-size: 10.5pt; gap: 6px 20px; }
  #tk-print table.tk-table { font-size: 9pt; }
  #tk-print table.tk-table th,
  #tk-print table.tk-table td {
    border: 1px solid #000 !important;
    padding: 3px 4px;
  }
  #tk-print table.tk-table thead th { background: #fff !important; }
  #tk-print table.tk-table .tk-note { font-size: 8.5pt; color: #000; }
  #tk-print .print-sign { font-size: 10.5pt; }
}

/* ---- 登录页「查看使用帮助」入口 ---- */
.help-link { display:inline-block; margin-top:-6px; margin-bottom:14px; font-size:14px; color:var(--primary); text-decoration:none; }
.help-link:hover { text-decoration:underline; }

/* ---- 登录页广告弹窗（ads.js 动态创建，活动期内进入登录页展示数秒） ----
 * 失败安全原则：可见性绝不依赖 JS 加类/动画时序——
 * 默认状态就是完全可见，动画用 @keyframes 单向播放（不支持时只是没动画，不会消失）；
 * 关闭用 .is-closing + transition 退化（不支持时立即消失，也不会卡住）。
 * 卡片显式定宽，避免收缩计算得 0 宽导致"只见暗遮罩不见图"。 */
.ad-mask {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 28, 42, 0.62);
  animation: ad-fade-in 0.22s ease;
}
.ad-mask.is-closing { opacity: 0; transition: opacity 0.2s ease; }
@keyframes ad-fade-in { from { opacity: 0; } }
.ad-card {
  position: relative;
  width: min(430px, 92vw);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  animation: ad-card-in 0.22s ease;
}
@keyframes ad-card-in { from { transform: translateY(10px); } }
.ad-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 88vh;
  object-fit: contain;
  background: #7a1f1f;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
.ad-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.ad-close:hover { background: rgba(0, 0, 0, 0.68); }
.ad-count {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 12px;
  pointer-events: none;
}
@media (max-width: 480px) {
  .ad-mask { padding: 12px; align-items: flex-start; padding-top: 8vh; }
  .ad-card { width: 100%; border-radius: 10px; }
  .ad-img { max-height: 78vh; }
}
