:root {
  --primary: #ff7a30;
  --primary-dark: #e8621a;
  --primary-light: #fff3ea;
  --text: #2b2b2b;
  --muted: #8a8a8a;
  --border: #ececec;
  --bg: #f6f7f9;
  --card: #ffffff;
  --danger: #e5484d;
  --success: #18a058;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ff9a5a 0%, #ff7a30 45%, #f45b1a 100%);
  padding: 20px;
}
.login-box {
  width: 880px; max-width: 100%; background: #fff; border-radius: 18px; overflow: hidden;
  display: flex; box-shadow: 0 20px 60px rgba(0, 0, 0, .18); min-height: 480px;
}
.login-left {
  flex: 1; background: var(--primary-light); padding: 40px; display: flex; flex-direction: column; justify-content: center;
}
.login-left h1 { font-size: 30px; margin: 0 0 8px; color: var(--primary-dark); }
.login-left p { color: #7a6a5e; line-height: 1.9; margin: 6px 0; }
.login-right { width: 380px; padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.tabs { display: flex; background: #f2f2f2; border-radius: 10px; padding: 4px; margin-bottom: 24px; }
.tabs div { flex: 1; text-align: center; padding: 9px 0; cursor: pointer; border-radius: 8px; color: var(--muted); }
.tabs div.active { background: #fff; color: var(--primary-dark); font-weight: 600; box-shadow: var(--shadow); }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; color: #666; font-size: 13px; }
.field input, .field select {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; outline: none; background: #fff;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.btn {
  height: 42px; border: none; border-radius: 8px; background: var(--primary); color: #fff;
  cursor: pointer; padding: 0 18px; font-weight: 500;
}
.btn:hover { background: var(--primary-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--primary-dark); border: 1px solid var(--primary); }
.btn.gray { background: #f1f1f1; color: #555; }
.btn.danger { background: var(--danger); }
.btn.sm { height: 32px; padding: 0 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
/* 学生管理：批量删除勾选框（手机上加大触控区域） */
.stu-check, #stuCheckAll { width: 18px; height: 18px; vertical-align: middle; cursor: pointer; }
.hint { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.9; background: #fafafa; padding: 12px; border-radius: 8px; }

/* ---------- Web 布局 ---------- */
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 20px; position: fixed; top: 0; left: 0; right: 0; z-index: 20;
}
.logo { font-size: 19px; font-weight: 700; color: var(--primary-dark); display: flex; align-items: center; gap: 8px; }
.logo span.badge { font-size: 12px; background: var(--primary-light); color: var(--primary-dark); padding: 3px 8px; border-radius: 6px; font-weight: 500; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 14px; color: #666; }
.sidebar {
  position: fixed; top: 58px; left: 0; bottom: 0; width: 208px; background: #fff; border-right: 1px solid var(--border);
  padding: 12px 0; overflow-y: auto; z-index: 10;
}
.sidebar .group-title { font-size: 12px; color: var(--muted); padding: 14px 20px 6px; }
.sidebar a {
  display: block; padding: 11px 20px; color: #444; cursor: pointer; border-left: 3px solid transparent;
}
.sidebar a:hover { background: #fafafa; }
.sidebar a.active { background: var(--primary-light); color: var(--primary-dark); border-left-color: var(--primary); font-weight: 600; }
.main { margin-left: 208px; padding: 78px 24px 40px; }
.page-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.page-desc { color: var(--muted); margin-bottom: 18px; font-size: 13px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary-dark); }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; outline: none; background: #fff; }
.toolbar .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #fafafa; color: #666; font-weight: 600; }
tr:hover td { background: #fcfcfc; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #f1f1f1; color: #666; }
.tag.ok { background: #e7f7ee; color: var(--success); }
.tag.warn { background: #fff4e5; color: var(--primary-dark); }
.tag.off { background: #f1f1f1; color: #999; }
.tag.bad { background: #fdecec; color: var(--danger); }

/* ---------- 弹窗 ---------- */
.mask { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 14px; width: 520px; max-width: 92vw; max-height: 88vh; overflow: auto; }
.modal header { padding: 16px 20px; font-weight: 600; border-bottom: 1px solid var(--border); display: flex; }
.modal header .x { margin-left: auto; cursor: pointer; color: var(--muted); }
.modal .body { padding: 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-row { display: flex; gap: 12px; margin-bottom: 14px; }
.form-row > div { flex: 1; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; color: #666; }
.form-row input, .form-row select {
  width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; outline: none;
}

/* ---------- 摄像头 ---------- */
.cam-wrap { position: relative; width: 100%; max-width: 480px; background: #222; border-radius: 12px; overflow: hidden; }
.cam-wrap video { width: 100%; display: block; }
.cam-wrap canvas { position: absolute; left: 0; top: 0; }
.cam-tip { color: var(--muted); font-size: 13px; margin-top: 10px; }
.result-card { display: flex; gap: 16px; align-items: center; padding: 16px; background: var(--primary-light); border-radius: 12px; margin-top: 14px; }
.result-card img { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; background: #eee; }
.result-card .name { font-size: 22px; font-weight: 700; color: var(--primary-dark); }

/* ---------- Toast ---------- */
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; }
.toast-item {
  background: #333; color: #fff; padding: 10px 18px; border-radius: 8px; margin-bottom: 8px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.toast-item.ok { background: var(--success); }
.toast-item.err { background: var(--danger); }

/* ---------- 响应式基础类（手机 / 电脑自适应） ---------- */
/* 表格在窄屏横向滚动的容器：JS 会自动把 #main 内的 table 包进它 */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 顶部汉堡按钮：桌面隐藏，手机显示 */
.menu-btn {
  display: none; width: 40px; height: 40px; margin-right: 10px; flex: 0 0 40px;
  border: none; background: transparent; font-size: 22px; line-height: 1;
  color: var(--primary-dark); cursor: pointer; border-radius: 8px;
}
.menu-btn:active { background: var(--primary-light); }
/* 抽屉遮罩 */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 15; }
/* 手机底部快捷操作栏：桌面隐藏，手机显示 */
.mobile-tabbar { display: none; }
/* 顶栏「返回上一页」按钮：无历史时隐藏 */
.nav-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 12px; margin-right: 12px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  color: #555; cursor: pointer; font-size: 13px;
}
.nav-btn:hover { background: #fafafa; }
.nav-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 手机端「右滑返回」手势：整页跟手拖动 + 左侧返回提示层 */
.swipe-anim { transition: transform .22s cubic-bezier(.22, .61, .36, 1); }
.swipe-hint {
  display: none; position: fixed; top: 58px; bottom: 58px; left: 0; width: 92px;
  align-items: center; justify-content: center; gap: 4px;
  font-size: 13px; font-weight: 600; color: var(--primary-dark);
  background: linear-gradient(90deg, rgba(47, 107, 255, .12), rgba(47, 107, 255, 0));
  opacity: 0; pointer-events: none; z-index: 2;
}
.swipe-hint svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 手动签到：点选式名单 ---------- */
/* 中托 / 晚托 分段切换 */
.seg { display: inline-flex; background: #f2f2f2; border-radius: 9px; padding: 3px; }
.seg button {
  border: none; background: transparent; color: #666; cursor: pointer; font-family: inherit;
  padding: 0 16px; height: 30px; border-radius: 7px; font-size: 13px;
}
.seg button.active { background: #fff; color: var(--primary-dark); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.mc-sum { color: var(--muted); font-size: 13px; }
.mc-sum b { font-weight: 700; }
.mc-tip { color: var(--muted); font-size: 12px; }
/* 学生点名网格：点一下即签到 */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 10px; }
.pick-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
  cursor: pointer; text-align: left; font-family: inherit; transition: background .15s, border-color .15s;
}
.pick-card:hover { border-color: var(--primary); background: var(--primary-light); }
.pick-card:active { transform: scale(.97); }
.pick-card .pc-name { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.pick-card .pc-sub { font-size: 12px; color: var(--muted); }
.pick-card .pc-state { font-size: 11px; color: #c6c6c6; margin-top: 1px; }
.pick-card.done { background: #f1faf4; border-color: #bfe6cd; }
.pick-card.done:hover { background: #e8f6ee; border-color: var(--success); }
.pick-card.done .pc-name { color: #147a42; }
.pick-card.done .pc-state { color: var(--success); }
.pick-card .pc-mark {
  position: absolute; top: 8px; right: 9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--success); color: #fff; font-size: 12px; line-height: 18px; text-align: center;
}
/* 已被搜索过滤掉时隐藏 */
.pick-card.hide { display: none; }

/* ---------- H5 家长端 ---------- */
.h5 { max-width: 480px; margin: 0 auto; background: var(--bg); min-height: 100vh; padding-bottom: 70px; }
.h5-header { background: linear-gradient(135deg, #ff9a5a, #ff7a30); color: #fff; padding: 20px; border-radius: 0 0 18px 18px; }
.h5-header .name { font-size: 20px; font-weight: 700; }
.h5-header .sub { opacity: .9; font-size: 13px; margin-top: 4px; }
.h5-body { padding: 14px; }
.h5-card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.h5-card .row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.h5-card .row:last-child { border-bottom: none; }
.h5-tabs { display: flex; background: #fff; border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.h5-tabs div { flex: 1; text-align: center; padding: 10px 0; border-radius: 9px; color: var(--muted); cursor: pointer; }
.h5-tabs div.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.h5-nav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto; background: #fff; display: flex; border-top: 1px solid var(--border); }
.h5-nav div { flex: 1; text-align: center; padding: 12px 0; color: var(--muted); cursor: pointer; font-size: 13px; }
.h5-nav div.active { color: var(--primary-dark); font-weight: 600; }
.thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; background: #f2f2f2; }
/* ===================== 响应式断点 ===================== */
/* 平板及以下：登录页改为竖排、隐藏营销左栏 */
@media (max-width: 880px) {
  .login-box { flex-direction: column; min-height: auto; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 34px 24px; }
}

/* 手机：管理端侧边栏改为可滑出抽屉，主区占满，控件收紧 */
@media (max-width: 768px) {
  .menu-btn { display: flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 12px; }
  .topbar .right { gap: 8px; }
  .topbar .right #dbInfo,
  .topbar .right #userName { display: none; }
  .logo { font-size: 16px; gap: 6px; }
  .logo span.badge { font-size: 11px; padding: 2px 6px; }
  .nav-btn { padding: 0 9px; margin-right: 8px; font-size: 12px; }
  .nav-btn svg { width: 15px; height: 15px; }
  /* 表格按内容宽度展开、横向滚动，列不再被挤成一条 */
  #main table { white-space: nowrap; }
  /* 环境提示条：更紧凑，且带「不再提示」关闭按钮 */
  #envWarn { font-size: 12px !important; padding: 8px 42px 8px 12px !important; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 220px;
    z-index: 16;
    box-shadow: 2px 0 16px rgba(0, 0, 0, .12);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; }

  .main { margin-left: 0; padding: 70px 12px 80px; }
  /* envWarn 的内联 left:208px 优先级高，这里用 !important 覆盖；bottom 上移避开快捷栏 */
  .envWarn { left: 0 !important; bottom: 58px !important; }

  /* 底部快捷操作栏（App 感） */
  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 18;
    background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 0 7px; font-size: 11px; color: var(--muted); cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-tabbar a.active { color: var(--primary-dark); }
  .mobile-tabbar a svg { width: 22px; height: 22px; display: block; stroke: currentColor; fill: none; stroke-width: 1.8; }

  /* 右滑返回：拖动时左侧露出返回提示 */
  .swipe-hint { display: flex; }
  /* 页面层压在提示层之上，右滑时「揭开」下面的返回提示（仅手机端，桌面不受影响） */
  #main { position: relative; z-index: 3; }

  .card { padding: 14px; }
  .page-title { font-size: 18px; }
  .form-row { flex-direction: column; gap: 10px; }
  .form-row > div { width: 100%; }
  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { flex: 1 1 140px; min-width: 120px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat .num { font-size: 22px; }
  .result-card { flex-wrap: wrap; gap: 12px; }
  .result-card img { width: 64px; height: 64px; }
  .modal { width: auto; margin: 10px; }
  .modal .body { padding: 16px; }

  /* 手动签到点名网格：手机上更紧凑，一屏能点多个人 */
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
  .pick-card { padding: 10px 10px 9px; }
  .pick-card .pc-name { font-size: 14px; }
  .pick-card .pc-sub { font-size: 11px; }
  .seg button { padding: 0 13px; }
}

/* 超小屏：工具栏控件单列铺满 */
@media (max-width: 480px) {
  .topbar .right .btn.sm.gray { padding: 0 8px; }
  /* 底部要留出快捷栏高度，否则最后一行会被挡住 */
  .main { padding: 64px 10px 78px; }
  .card { padding: 12px; }
  .stat .num { font-size: 20px; }
  .toolbar input, .toolbar select { flex: 1 1 100%; }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* 作业提交：科目卡片与作业照片缩略图 */
.hw-subject-card { border: 1px solid #f0f0f0; border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fafafa; }
.hw-subj-input { font-weight: 600; }
.hw-photo { position: relative; width: 68px; height: 68px; border-radius: 8px; overflow: hidden; border: 1px solid #eee; background: #fff; }
.hw-photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.hw-photo .hw-photo-x { position: absolute; top: 3px; right: 3px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 50%; width: 18px; height: 18px; line-height: 18px; text-align: center; font-size: 12px; cursor: pointer; }
