﻿:root {
  --blue: #073b86;
  --blue-dark: #052b63;
  --orange: #ff6b00;
  --green: #0f9f6e;
  --red: #dc2626;
  --amber: #d97706;
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #dfe7f1;
  --text: #17233d;
  --muted: #6b7890;
  --soft: #eef4ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* 移动端菜单控件（桌面端隐藏） */
.menu-toggle, .menu-close, .sidebar-backdrop { display: none; }

.sidebar {
  width: 288px;
  background: var(--blue-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  flex-shrink: 0;
}

.brand {
  height: 104px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: nowrap;
}

.brand img {
  width: 100px;
  height: 52px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.brand strong { display: block; font-size: 21px; line-height: 1.1; letter-spacing: 0; white-space: nowrap; }
.brand span { display: none; }

nav { padding: 14px 10px; display: grid; gap: 6px; }
.nav-btn {
  border: 0;
  background: transparent;
  color: #c9d6e8;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-btn.active { box-shadow: inset 3px 0 0 var(--orange); }
.side-note { margin-top: auto; padding: 16px 18px; color: #8ea4c2; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; min-width: 0; height: 100vh; overflow: auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.topbar h1 { margin: 0 0 6px; font-size: 24px; }
.topbar p { margin: 0; color: var(--muted); }
.top-actions, .inline-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.page { display: none; padding: 26px 28px 40px; }
.page.active { display: block; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 42, 82, .06);
}
.stat { padding: 20px; }
.stat span { display: block; color: var(--muted); margin-bottom: 8px; }
.stat strong { font-size: 32px; color: var(--blue); }
.card { overflow: hidden; }
.card-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.card-head h2 { margin: 0; font-size: 18px; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 800;
  background: #fff;
  color: var(--text);
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.secondary { background: var(--orange); color: #fff; }
.btn.ghost { border-color: var(--line); background: #fff; color: var(--blue); }
.btn.big { width: 100%; margin-top: 16px; padding: 14px; font-size: 17px; }
.file-btn input { display: none; }

.toolbar { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; flex-wrap: wrap; }
input, select, textarea {
  border: 1px solid #cbd6e5;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  background: #fff;
  min-height: 40px;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7,59,134,.12); }
textarea { resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8fbff; color: #506079; font-weight: 900; white-space: nowrap; }
td { color: #23334d; }
.empty { text-align: center; color: var(--muted); padding: 34px; }

.tag { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-weight: 800; font-size: 12px; }
.tag.green { background: #e8fbf3; color: var(--green); }
.tag.red { background: #fff0f0; color: var(--red); }
.tag.amber { background: #fff7e8; color: var(--amber); }
.tag.blue { background: var(--soft); color: var(--blue); }

.camera-layout { display: grid; grid-template-columns: minmax(420px, 1.2fr) minmax(360px, .8fr); gap: 18px; align-items: start; }
.video-box {
  position: relative;
  margin: 18px;
  background: #0c1a2f;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
}
video, #snapshotCanvas { width: 100%; height: 100%; object-fit: cover; display: block; }
#snapshotCanvas { display: none; }
.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aab8ce;
  font-weight: 800;
}
.snapshot-strip { display: flex; gap: 12px; align-items: center; padding: 0 18px 18px; }
.snapshot-strip img {
  width: 120px;
  height: 76px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f5f9;
  display: none;
}

.form-grid { padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.student-summary {
  margin: 0 18px;
  padding: 14px;
  border-radius: 8px;
  background: #f7faff;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.8;
}
.hint { color: var(--muted); padding: 0 18px 18px; margin: 10px 0 0; font-size: 13px; }

.chips { padding: 18px; display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 999px; background: var(--soft); color: var(--blue); font-weight: 800; }
.chip button { border: 0; background: transparent; color: var(--red); font-weight: 900; }
.add-line { padding: 0 18px 18px; display: flex; gap: 10px; }
.add-line input { flex: 1; }

dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: 0 18px 60px rgba(0,0,0,.22); max-width: 920px; width: calc(100% - 40px); }
dialog::backdrop { background: rgba(6, 22, 45, .45); }
.dialog-card { background: #fff; padding: 20px; }
.dialog-card h2 { margin: 0 0 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 12px; }
.photo-dialog img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; background: #111; }

#toast {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 1000;
  display: grid;
  gap: 10px;
}
.toast {
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
.toast.info { background: var(--blue); }

@media (max-width: 1100px) {
  body { display: block; }
  .sidebar { width: 100%; min-height: auto; }
  .brand { height: auto; }
  nav { grid-template-columns: repeat(3, 1fr); }
  .main { height: auto; }
  .stats-grid, .grid.two, .camera-layout { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .toolbar, .inline-actions, .btn { display: none !important; }
  .main { height: auto; overflow: visible; }
  .page { display: none; padding: 0; }
  #page-records { display: block; }
  .card { box-shadow: none; border: 0; }
}


.face-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 18px 18px;
}
.face-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.face-card span { font-weight: 900; color: var(--blue); }
.face-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #e8eef7;
  border: 1px dashed #b8c7da;
  display: none;
}
.face-card small { color: var(--muted); }
.student-photo-editor {
  margin: 14px 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
}
.student-photo-editor img, .student-photo-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #dbe6f3;
  background: #eef3f8;
}
.student-photo-editor img { width: 96px; height: 96px; display: none; }
.student-photo-editor p { margin: 4px 0 10px; color: var(--muted); font-size: 13px; }
.student-photo-empty {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef3f8;
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
}
.verify-ok { background: #e8fbf3; color: var(--green); }
.verify-warn { background: #fff7e8; color: var(--amber); }


.version-banner {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 10px;
  background: linear-gradient(90deg, #073b86, #0b5ab8);
  color: #fff;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: 0 12px 28px rgba(7, 59, 134, .18);
}
.version-banner strong {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: #ff6b00;
  font-size: 14px;
}
.version-banner span {
  line-height: 1.6;
}


.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-weight: 900;
}
.section-body { padding: 18px; }
.form-grid.flat { padding: 0; }
.hint-line { margin: 0 0 10px; color: var(--muted); line-height: 1.8; }
.login-dialog::backdrop { background: rgba(6, 22, 45, .65); }
.locked { opacity: .48; pointer-events: none; }
.role-pill { display:inline-flex; padding: 4px 9px; border-radius:999px; background:#eef4ff; color:var(--blue); font-weight:900; font-size:12px; }


.login-panel {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(6, 22, 45, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
.login-panel .dialog-card {
  width: min(520px, 100%);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
}


.schedule-note {
  padding: 14px 18px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  line-height: 1.7;
}
.schedule-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
.schedule-day {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  overflow: hidden;
}
.schedule-day h3 {
  margin: 0;
  padding: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  text-align: center;
}
.schedule-list {
  min-height: 180px;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 10px;
}
.schedule-item {
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #dce6f3;
  box-shadow: 0 8px 18px rgba(15, 42, 82, .05);
  display: grid;
  gap: 6px;
}
.schedule-time { color: var(--blue); font-weight: 900; }
.schedule-student { font-weight: 900; color: var(--text); }
.schedule-meta { color: var(--muted); font-size: 13px; line-height: 1.5; }
.schedule-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.schedule-actions .btn { padding: 5px 8px; font-size: 12px; }
.schedule-empty { color: var(--muted); text-align: center; padding: 26px 8px; font-weight: 700; }
.schedule-dialog-hint { padding: 0 18px; }

@media (max-width: 1100px) {
  .brand { justify-content: flex-start; }
  .schedule-grid { grid-template-columns: repeat(7, minmax(170px, 1fr)); }
}


.student-schedule-panel {
  margin: 0 18px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  overflow: hidden;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 0;
  color: var(--blue);
  font-weight: 900;
}
.check-row input { min-height: 0; width: 18px; height: 18px; }
.form-grid.compact { padding: 14px 16px 16px; }

@media (max-width: 760px) {
  .brand img { width: 92px; height: 48px; }
  .brand strong { font-size: 20px; }
}


.stat-link { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.stat-link:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(15, 42, 82, .12); }
.pulse-card { animation: pulseCard 1.1s ease; }
@keyframes pulseCard {
  0%, 100% { box-shadow: 0 10px 24px rgba(15, 42, 82, .06); }
  35% { box-shadow: 0 0 0 4px rgba(255,107,0,.22), 0 16px 34px rgba(15, 42, 82, .16); }
}
.toolbar label, .inline-actions label { color: var(--muted); font-weight: 800; display: grid; gap: 4px; }
.inline-actions label input { min-width: 150px; }

.dashboard-detail-card { margin-top: 18px; }
.stat-link.selected { box-shadow: inset 0 0 0 2px var(--orange), 0 14px 30px rgba(15, 42, 82, .12); }

.auto-check-panel {
  margin: 0 18px 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  display: grid;
  gap: 4px;
  line-height: 1.6;
}
.auto-check-panel strong { color: var(--blue-dark); }
.auto-check-panel.running { border-color: #9eb3ce; background: #f4f7fb; }
.auto-check-panel.ok { border-color: #b8efd4; background: #e8fbf3; color: #0f7b45; }
.auto-check-panel.warn { border-color: #ffd79b; background: #fff7e8; color: #9a5b00; }

/* ================= 移动端适配（≤900px：抽屉菜单 + 单列布局） ================= */
@media (max-width: 900px) {
  body { display: block; }

  /* 汉堡按钮与关闭按钮 */
  .menu-toggle, .menu-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--blue);
    font-size: 24px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 8px;
    min-height: 40px;
    min-width: 44px;
  }
  .menu-close { color: #fff; font-size: 18px; }

  /* 侧边栏：固定抽屉，默认滑出屏幕 */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    min-height: 100vh;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open { overflow: hidden; }

  /* 遮罩层 */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 290;
    background: rgba(6, 22, 45, .5);
  }
  body.sidebar-open .sidebar-backdrop { display: block; }

  /* 抽屉内导航纵向排列 */
  nav { grid-template-columns: 1fr; padding: 10px 10px 20px; }
  .nav-btn { padding: 13px 14px; font-size: 15px; }
  .brand { position: relative; padding-right: 52px; }
  .brand strong { font-size: 18px; }

  /* 主区域独立滚动，顶部栏吸顶 */
  .main { height: 100vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* 顶部栏：紧凑 + 标题行与操作行分离 */
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar-title { display: flex; align-items: center; gap: 4px; min-width: 0; }
  .topbar h1 { font-size: 19px; margin: 0; }
  .topbar p { display: none; }
  .top-actions { width: 100%; justify-content: flex-end; gap: 8px; }
  .top-actions .btn { padding: 8px 10px; font-size: 13px; min-height: 40px; }
  #seedBtn { display: none; }
  .user-badge { min-height: 36px; padding: 0 10px; font-size: 13px; }

  /* 页面与卡片间距 */
  .page { padding: 14px 12px 28px; }
  .card-head { padding: 13px 14px; }
  .card-head h2 { font-size: 16px; }
  .toolbar { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .toolbar label, .toolbar input, .toolbar select { width: 100%; }
  .toolbar .btn { grid-column: 1 / -1; }

  /* 统计卡片 2×2 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px 12px; }
  .stat strong { font-size: 26px; }
  .stat span { font-size: 13px; }

  /* 表格：横向滚动 + 紧凑内边距 */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  th, td { padding: 10px 10px; font-size: 13px; }
  td .btn, td button { white-space: nowrap; padding: 7px 9px; font-size: 12px; min-height: 36px; }

  /* 表单单列 + 控件加大触控区 */
  .form-grid { grid-template-columns: 1fr; padding: 14px; gap: 12px; }
  .form-grid.compact { grid-template-columns: 1fr; }
  input, select, textarea { min-height: 44px; }

  /* 弹窗全宽优化 */
  dialog { width: calc(100% - 16px); max-width: none; }
  .dialog-card { padding: 14px; }
  .dialog-card h2 { font-size: 17px; }
  .dialog-actions .btn { flex: 1; min-height: 44px; }

  /* 签到页 */
  .camera-layout { grid-template-columns: 1fr; gap: 12px; }
  .video-box { margin: 12px 12px 0; }
  .snapshot-strip { flex-wrap: wrap; padding: 0 12px 12px; }
  .snapshot-strip .btn { flex: 1; min-height: 44px; }
  #autoCheckinBtn { flex: 2; }
  .auto-check-panel { margin: 0 12px 12px; }
  .face-compare { grid-template-columns: 1fr; padding: 0 12px 12px; }
  .student-summary { margin: 0 12px; }
  .hint { padding: 0 12px 12px; }
  .btn.big { padding: 14px; font-size: 16px; min-height: 48px; }

  /* 学员照片编辑区单列 */
  .student-photo-editor { grid-template-columns: 1fr; margin: 12px 14px 0; }
  .student-schedule-panel { margin: 0 14px 8px; }
  .check-row { padding: 12px 14px 0; }

  /* 排课横向滚动 */
  .schedule-grid { grid-template-columns: repeat(7, minmax(150px, 1fr)); padding: 12px; }
  .schedule-day { min-width: 150px; }

  /* 卡片间距与横幅 */
  .grid { gap: 12px; }
  .version-banner { padding: 12px 14px; flex-wrap: wrap; }

  /* 登录弹窗 */
  .login-panel { padding: 14px; }
  .login-panel .dialog-card { width: 100%; }

  /* 内联操作按钮占满行 */
  .inline-actions { flex-wrap: wrap; }
  .inline-actions .btn { flex: 1; justify-content: center; }
}
