:root {
  --bg: #f1f4f9;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #243044;
  --muted: #7b8798;
  --brand: #3b7cff;
  --brand-dark: #2a5fd8;
  --danger: #e5484d;
  --c-empty: #eef1f5;
  --c-class: #38b26a;
  --c-leave: #f59e0b;
  --c-rest: #4c8df6;
  --c-class-bg: #e5f6ec;
  --c-leave-bg: #fdf0da;
  --c-rest-bg: #e6effe;
  --shadow: 0 6px 24px rgba(30, 50, 90, .08);
}

* { box-sizing: border-box; }
/* 页面整体绝不被内容横向撑宽；宽内容一律走内部滚动容器 */
html { overflow-x: hidden; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}
button, .cell, .tcard, .tab, .brush { touch-action: manipulation; }
/* 禁双击缩放（保留平移/滚动），配合 viewport user-scalable=no 双指捏合也被禁 */
html, body { touch-action: manipulation; }
.hidden { display: none !important; }
/* 弹窗背景滚动锁：body 下存在可见（非 .hidden）的 .modal 时由 app.js 加 .scroll-lock，
   锁住背景页面滚动（防移动端滚动穿透）。保守只用 overflow:hidden，
   不动 position/touch-action，避免破坏 iOS 橡皮筋回弹。 */
body.scroll-lock { overflow: hidden; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.btn:hover { border-color: #c7d2e0; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(0,0,0,.05); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fdecec; border-color: #f5c2c3; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 登录 ---------- */
.login-wrap { height: 100vh; height: 100dvh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 340px; max-width: 92vw; background: var(--card); padding: 34px 30px; border-radius: 16px;
  box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card .sub { color: var(--muted); margin: 0 0 4px; }
.login-card .sub.en-sub { font-size: 12px; margin: 0 0 18px; opacity: .85; }
.login-card .sub.stu-sub { font-size: 12px; margin: -10px 0 16px; opacity: .75; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--brand); }
.login-card .btn { width: 100%; margin-top: 4px; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 20px; gap: 18px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted);
  font-weight: 600; border: none; background: none; font-size: 14px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); background: #eaf1ff; }
.userbox { display: flex; align-items: center; gap: 8px; position: relative; }

/* 帮助按钮（顶栏 userbox 内，老师 / 管理员可见） */
.help-btn {
  border: none; background: transparent; padding: 0; margin: 0; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%; font-size: 17px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s;
}
.help-btn:hover { background: #f0f4fa; }

/* ---------- 头像下拉菜单 ---------- */
.avatar-trigger {
  border: none; background: none; padding: 0; margin: 0; cursor: pointer;
  display: inline-flex; border-radius: 50%; line-height: 0; flex-shrink: 0;
}
.avatar.trigger { width: 34px; height: 34px; font-size: 13px; }
.avatar-trigger:hover .avatar { outline: 2px solid #cfe0ff; outline-offset: 1px; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 210px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 60; display: none;
}
.user-menu.open { display: block; }
.user-menu .um-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.user-menu .um-name { font-weight: 700; font-size: 14px; }
.user-menu .um-role { color: var(--muted); font-size: 12px; margin-top: 2px; }
.user-menu .um-item {
  display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: none;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); text-align: left;
}
.user-menu .um-item:hover { background: #f0f4fa; }
.user-menu .um-item.danger { color: var(--danger); }
.user-menu .um-item.danger:hover { background: #fdecec; }

#main { max-width: 1300px; margin: 0 auto; padding: 20px; }

/* ---------- 头像 ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0; user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }

/* ---------- 布局 ---------- */
/* minmax(0,1fr) + 子项 min-width:0：grid 子项允许收缩到轨道宽度，
   防止内部内容（如横向老师列表的最小宽度）把整页/整栏撑宽 */
.schedule-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; width: 100%; max-width: 100%; }
.schedule-layout > * { min-width: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; box-shadow: 0 1px 3px rgba(30,50,90,.04);
}
.card h3 { margin: 0 0 12px; font-size: 15px; }

/* ---------- 左栏「选择老师」卡片可折叠（管理员默认收起：标题行常驻，点击展开列表） ---------- */
.strip-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px;
  border: none; background: transparent; cursor: pointer;
  font-size: 15px; font-weight: 700; color: var(--text);
  border-radius: 9px; text-align: left; font-family: inherit;
}
.strip-head:hover { background: #f0f4fa; }
.strip-head .fold-arrow { color: var(--brand); font-size: 12px; flex-shrink: 0; }
.strip-head .strip-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 折叠卡片及其内部容器都不许横向撑破面板：内容多时在容器内部滚动/换行 */
.strip-card, .strip-body { min-width: 0; max-width: 100%; }
.teacher-strip { min-width: 0; }
.strip-card .strip-body { padding-top: 4px; }
.strip-card.collapsed .strip-body { display: none; }
.strip-card.collapsed { padding-top: 6px; padding-bottom: 6px; }   /* 收起时仅剩标题行 */

/* 老师学生表：备注列 */
.tbl td .note-cell { white-space: normal; max-width: 260px; }

/* 老师选择列表：纵向超出一屏在面板内部滚动；横向绝不外溢（手机端由媒体查询改内部横滑） */
.teacher-strip { display: flex; flex-wrap: wrap; gap: 10px; max-height: 340px; overflow-y: auto; overflow-x: hidden; margin-top: 6px; }
.tcard {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; width: 66px;
  min-width: 0; max-width: 100%; flex-shrink: 0;
  background: #fff; transition: all .12s;
}
.tcard:hover { border-color: #b9c8dd; }
.tcard.sel { border-color: var(--brand); background: #eaf1ff; box-shadow: 0 0 0 2px #cfe0ff; }
.tcard .tname { font-size: 12px; color: var(--text); max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }

/* 搜索框 */
.searchbox { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; font-size: 14px; margin-bottom: 8px; }
.searchbox:focus { border-color: var(--brand); }

/* ---------- 图例 ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.legend .lg { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; }
.swatch.s-class { background: var(--c-class); }
.swatch.s-leave { background: var(--c-leave); }
.swatch.s-rest { background: var(--c-rest); }
.swatch.s-empty { background: var(--c-empty); border: 1px solid var(--line); }

/* ---------- 单日格子 ---------- */
.day-grid { display: flex; flex-direction: column; }
.dg-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.dg-row .cell { flex: 1; min-width: 0; }
.dg-label { width: 86px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell {
  flex: 1; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--c-empty); cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 13px; transition: all .1s; user-select: none;
}
.cell:hover { filter: brightness(.94); }
.cell.s-class { background: var(--c-class-bg); border-color: #bfe6d0; color: #1f7a48; font-weight: 600; }
.cell.s-leave { background: var(--c-leave-bg); border-color: #f5d9a6; color: #a16207; font-weight: 600; }
.cell.s-rest { background: var(--c-rest-bg); border-color: #c6dcfb; color: #2c66c4; font-weight: 600; }
.cell.ro { cursor: default; }
.cell.ro:hover { filter: none; }

.brush-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.brush {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 6px; font-size: 13px;
}
.brush .sw { width: 12px; height: 12px; border-radius: 3px; }
.brush.active { box-shadow: 0 0 0 2px var(--brand); border-color: var(--brand); }
.brush.erase .sw { background: transparent; border: 1px solid var(--line); }
.dotbtn { border: 1px dashed #c7d2e0; background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.dotbtn:hover { color: var(--brand); border-color: var(--brand); }

/* 页内标题行 */
.sec-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-title .who { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; }
.date-pill {
  background: #eaf1ff; color: var(--brand-dark); padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 13px;
}

/* ---------- 总览矩阵 ---------- */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: separate; border-spacing: 2px; width: max-content; }
table.matrix th, table.matrix td { padding: 0; }
table.matrix th.name { text-align: left; }
table.matrix .mcell {
  width: 26px; height: 26px; border-radius: 5px; text-align: center; cursor: pointer; border: 1px solid transparent; font-size: 0;
}
.mhead { width: 26px; height: 26px; border-radius: 5px; font-size: 10px; color: var(--muted); text-align: center; }
.mcell.s-class { background: var(--c-class); }
.mcell.s-leave { background: var(--c-leave); }
.mcell.s-rest { background: var(--c-rest); }
.mcell.s-empty { background: var(--c-empty); }
.mcell:hover { outline: 2px solid var(--brand); outline-offset: 1px; }
.mini-av { display: inline-flex; margin-right: 8px; vertical-align: middle; }

/* 账号管理 */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; }
.tbl td .uname { font-weight: 600; }
.tbl td .uid { color: var(--muted); font-size: 12px; }

/* 老师账号管理：点头像 / 姓名 → 直接打开该老师课表（管理员排课入口） */
.tbl td.tlink { cursor: pointer; transition: color .12s; }
.tbl td.tlink:hover { color: var(--brand); }
.tbl td.tlink .avatar { outline: 2px solid transparent; outline-offset: 1px; transition: outline-color .12s; }
.tbl td.tlink:hover .avatar { outline-color: #cfe0ff; }

/* 日期导航栏 */
.date-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.date-nav .date-input {
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 15px;
  color: var(--text); background: #fff; outline: none; min-width: 0;
}
.date-nav .date-input:focus { border-color: var(--brand); }

/* 每格备注按钮 */
.note-btn {
  border: 1px dashed #c7d2e0; background: #fff; color: var(--muted);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer; flex-shrink: 0;
  transition: all .12s; white-space: nowrap;
}
.note-btn:hover { color: var(--brand); border-color: var(--brand); }
.note-btn.has { background: #eaf1ff; border: 1px solid #bcd4ff; color: #2a5fd8; font-weight: 600; }

/* 备注输入框 */
.note-area {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-size: 15px; font-family: inherit; resize: vertical; outline: none; min-height: 70px;
}
.note-area:focus { border-color: var(--brand); }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(20,30,50,.45); display: flex;
  align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--card); border-radius: 16px; padding: 24px; width: 360px; box-shadow: var(--shadow);
}
.modal-box h3 { margin: 0 0 16px; font-size: 17px; }
.modal-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; outline: none; font-size: 14px; }
.modal-box input:focus { border-color: var(--brand); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* 使用说明弹层（❓ 帮助） */
.help-box { width: min(560px, 92vw); }
.help-list { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; }
.help-list p { margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; }
.help-list b { font-weight: 700; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #22314a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  z-index: 200; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }

.hint { color: var(--muted); font-size: 13px; }
.center-empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ============================================================
   平板 / 窄屏：左右两栏收成单栏
   ============================================================ */
@media (max-width: 980px) {
  .schedule-layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 14px; row-gap: 6px; }
}

/* ============================================================
   手机（竖屏为主）
   ============================================================ */
@media (max-width: 760px) {

  /* ---------- 顶栏：两行，避免溢出 ---------- */
  .topbar {
    flex-wrap: wrap; height: auto; padding: 10px 12px; row-gap: 8px;
    position: relative;
  }
  .topbar .brand { font-size: 15px; order: 1; flex: 1 1 auto; white-space: nowrap; min-width: 0; }
  .userbox { order: 2; margin-left: auto; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .userbox .hint { display: none; }            /* 手机上省空间 */
  .userbox > span { display: inline-flex; align-items: center; gap: 6px; overflow: hidden; }
  .userbox > span > strong { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---------- 主区留白收小 ---------- */
  #main { padding: 12px; }

  /* ---------- 顶栏布局元素在手机上更紧凑 ---------- */
  .card { padding: 12px; border-radius: 12px; }
  .tab { padding: 8px 12px; font-size: 15px; }

  /* ---------- 登录页 ---------- */
  .login-card { padding: 26px 20px; }
  .login-card input, .login-card .btn { font-size: 16px; padding: 12px; }  /* >=16px 避免 iOS 聚焦放大 */
  input, button { font-size: 16px; }           /* 避免 iOS 自动缩放 */

  /* ---------- 老师列表：一行横滑，省竖向空间 ---------- */
  .teacher-strip {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 6px; margin: 6px -4px 0;
  }
  .tcard { min-width: 68px; }

  /* ---------- 单日格子：竖向一排，行高加大方便手指 ---------- */
  .dg-label { width: 74px; font-size: 13px; }
  .cell { height: 46px; font-size: 15px; border-radius: 10px; }
  .dg-row { padding: 4px 0; }

  /* ---------- 刷子/整日按钮 ---------- */
  .brush, .dotbtn { padding: 10px 14px; font-size: 15px; }
  .brush-row { gap: 8px; }

  /* ---------- 日期标题行换行 ---------- */
  .sec-title { gap: 8px; }
  .sec-title .who { font-size: 15px; flex-wrap: wrap; }
  .date-nav { margin-left: 0; width: 100%; }
  .date-nav .date-input { flex: 1; text-align: center; padding: 8px 6px; }

  /* ---------- 矩阵格子略大，允许横滑 ---------- */
  table.matrix .mcell { width: 30px; height: 30px; }

  /* ---------- 弹窗贴近屏幕 ---------- */
  .modal-box { width: 92vw; max-height: 88vh; overflow-y: auto; }
  .modal-box h3 { font-size: 16px; }

  /* ---------- 表格（账号管理）改小字号防溢出 ---------- */
  .tbl th, .tbl td { padding: 8px; font-size: 14px; }
  .tbl { display: block; overflow-x: auto; white-space: nowrap; }
}

/* 超小屏（<=360）进一步压缩 */
@media (max-width: 380px) {
  #main { padding: 8px; }
  .dg-label { width: 64px; }
}

/* ============================================================
   学生信息页
   ============================================================ */
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.filter-row .searchbox { margin-bottom: 0; flex: 1; min-width: 160px; }
.filter-row select {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
  font-size: 14px; background: #fff; color: var(--text); outline: none; max-width: 100%;
}
.filter-row select:focus { border-color: var(--brand); }

/* 弹窗表单：字段标签 + 下拉框 + 多行文本 */
.flabel { display: block; font-size: 13px; color: var(--muted); margin: 4px 0 6px; font-weight: 600; }
.modal-box select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 10px; outline: none; font-size: 14px; background: #fff; color: var(--text);
}
.modal-box select:focus { border-color: var(--brand); }
.modal-box .note-area { min-height: 56px; margin-bottom: 10px; }

/* ---------- 手机：折叠标题加大触摸区 / 下拉菜单靠右贴边 ---------- */
@media (max-width: 760px) {
  .strip-head { padding: 10px 8px; }
  .user-menu { min-width: 190px; }
  .tbl td .note-cell { max-width: 200px; }
}

/* ============================================================
   点格子设置弹层（学生 / 休息 / 清除）+ 格子学生姓名省略
   ============================================================ */
.slot-picker { text-align: left; }
.slot-picker .sp-title { font-size: 16px; font-weight: 700; }
.slot-picker .sp-sub { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.slot-picker .sp-current {
  display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted);
  background: #f6f8fb; border-radius: 8px; padding: 7px 10px; margin: 8px 0 2px;
}
.slot-picker .sp-current b { color: var(--text); font-weight: 600; }

.sp-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; max-height: 42vh; overflow-y: auto; }
.sp-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 10px; padding: 9px 12px; cursor: pointer; font-size: 14px; text-align: left;
  font-family: inherit; transition: all .12s; flex-shrink: 0;
}
.sp-item:hover { border-color: var(--brand); background: #f6f9ff; }
.sp-item.sel { border-color: var(--brand); background: #eaf1ff; }
.sp-item .avatar { flex-shrink: 0; }
.sp-item .swatch { flex-shrink: 0; }
.sp-item .sp-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item .sp-check { color: var(--brand); font-weight: 700; flex-shrink: 0; }
.sp-item .sp-ico { color: var(--danger); font-weight: 700; flex-shrink: 0; width: 18px; text-align: center; }
.sp-hint, .sp-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }
.sp-empty.err { color: var(--danger); }
.slot-picker .sp-cancel { align-self: center; margin-top: 2px; }

/* 点格操作提示 */
.tap-hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* 格子内文字（学生姓名等）过长省略 */
.day-grid .cell { overflow: hidden; }
.day-grid .cell .cell-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; max-width: 100%; padding: 0 4px;
}

/* 手机：弹层选项更大、更好点 */
@media (max-width: 760px) {
  .sp-item { padding: 12px 14px; font-size: 15px; }
  .sp-list { max-height: 50vh; }
}

/* ============================================================
   教材库（管理员）+ 学生我的教材 / 我的课表 / 工作时间
   ============================================================ */
/* 排课页“当日未设置工作时间”提示 */
.no-hours { padding: 40px 16px; text-align: center; }
.no-hours p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.no-hours .btn { margin: 0 auto; }

/* 管理员教材表：链接截断 */
.tbl td .book-url { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
@media (max-width: 760px) {
  .tbl td .book-url { max-width: 160px; }
}

/* 行内小按钮组（学生账号列等） */
.rowbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.rowbtns .btn { padding: 3px 8px; font-size: 12px; }

/* 学生「我的教材」 */
.book-current {
  background: #f6f8fb; border-radius: 10px; padding: 10px 14px;
  font-size: 14px; margin-top: 4px;
}
.book-current.muted { color: var(--muted); }
.book-current a { color: var(--brand); font-weight: 600; text-decoration: none; }
.book-current a:hover { text-decoration: underline; }

.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.book-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: #fff; display: flex; flex-direction: column; gap: 10px;
  transition: all .12s;
}
.book-card:hover { border-color: #b9c8dd; }
.book-card.sel { border-color: var(--brand); background: #eaf1ff; box-shadow: 0 0 0 2px #cfe0ff; }
.book-card .book-name { font-weight: 700; font-size: 15px; line-height: 1.4; }
.book-card .book-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.book-card .book-using { color: var(--brand); font-weight: 700; font-size: 13px; }

/* 老师「工作时间」表 */
.hours-warn { margin-bottom: 10px; line-height: 1.5; }
.hours-tbl select {
  width: 110px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 14px; outline: none; max-width: 100%;
}
.hours-tbl select:disabled { opacity: .5; background: #f2f4f7; }
.hours-tbl input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
@media (max-width: 760px) {
  .hours-tbl select { width: 96px; padding: 6px; font-size: 15px; }
  .book-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .book-grid { grid-template-columns: 1fr; }
}

/* 会议号：进入会议按钮 / 可复制会议号 / 账号列表里的会议号单元格 */
a.btn.meeting-link { display: inline-block; text-decoration: none; text-align: center; }
.meeting-copy {
  border: 1px dashed var(--line); background: transparent; color: var(--text);
  border-radius: 8px; padding: 3px 8px; font-size: 12px; cursor: pointer; max-width: 100%;
}
.meeting-copy:hover { border-color: var(--brand); color: var(--brand); }
.meeting-text {
  display: inline-block; max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  color: var(--text);
}
a.meeting-text { color: var(--brand); text-decoration: none; }
a.meeting-text:hover { text-decoration: underline; }
/* 会议号实际为 9 位纯数字：tabular-nums 使每位数字等宽 → 任意 9 位占位相同，增删行/换号不引起列宽跳动 */
.meeting-text, a.meeting-text, .meeting-copy { font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .meeting-text { max-width: 120px; }
}
/* 老师账号表：纯数字会议号（3 位分组展示）可点击复制 */
.meeting-text.copyable { cursor: pointer; }
.meeting-text.copyable:hover { color: var(--brand); }
/* 只读输入框（编辑老师弹窗的登录账号展示） */
.modal-box input[readonly] { background: #f4f6f8; color: var(--muted); cursor: not-allowed; }

/* 学生 添加/编辑 弹窗：多选老师的 checkbox 列表 */
.mt-list {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
  max-height: 190px; overflow-y: auto; margin-bottom: 6px;
}
.mt-list label { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.mt-list input[type=checkbox] { width: 16px; height: 16px; flex-shrink: 0; margin: 0; }
.mt-list .avatar { flex-shrink: 0; }
.mt-list .mt-name { font-size: 14px; }

/* ============================================================
   V2 课表：WeekNav（sticky 在顶栏之下）+ 卡片流 + 工作时间矩阵
   ============================================================ */
/* WeekNav 只保证 sticky 顶栏之下；顶部固定感由 topbar(sticky) + 本条 top 偏移实现 */
.weeknav {
  position: sticky; top: 56px; z-index: 12;
  display: flex; flex-direction: column; align-items: stretch; gap: 0;
  margin: 2px 0 12px; padding: 6px 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 4px 14px rgba(30,50,90,.05);
}
/* 本周/下周开关行：独占 7 列 grid 之上的一行，右对齐，不挤压列宽 */
.wn-weekrow { display: flex; justify-content: flex-end; margin-bottom: 2px; }
.wn-wkbtn {
  font-size: 11px; padding: 2px 8px; line-height: 1.4;
  border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-family: inherit;
  transition: background .12s, color .12s;
}
.wn-wkbtn.on { background: #eaf1ff; color: var(--brand-dark); font-weight: 600; }
/* 7 天等宽整行平铺：grid 每列 minmax(0,1fr)，无横向滚动、不设会导致溢出的 min-width */
.wn-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; flex: 1; min-width: 0; width: 100%; }
.wn-day {
  position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 2px 6px; border: 1px solid transparent; background: transparent;
  border-radius: 10px; cursor: pointer; color: var(--muted); transition: all .12s;
  font-family: inherit;
}
.wn-day:hover { background: #f0f4fa; color: var(--text); }
.wn-day .wn-wd { font-size: 13px; font-weight: 600; line-height: 1.2; }
/* 跨周排课（方案 B）：每列日期常显小字，7 列等宽不换行 */
.wn-date { font-size: 9.5px; color: var(--muted); line-height: 1.1; white-space: nowrap; }
/* 今日(B 方案)：仅文字变主题蓝加粗，无底色/无额外元素，与选中态(浅蓝底)区分 */
.wn-day.today .wn-wd { color: var(--brand); font-weight: 700; }
.wn-day.today .wn-date { color: var(--brand); font-weight: 700; }
.wn-day.sel { background: #eaf1ff; color: var(--brand-dark); }
.wn-day.sel:hover { background: #e0ecff; }
.wn-day:disabled { cursor: default; }
.wn-tri {
  position: absolute; bottom: -2px; left: 50%; margin-left: -5px;
  width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--brand);
}

/* 当日标题行 */
.day-head {
  display: flex; align-items: baseline; gap: 10px;
  max-width: 800px; margin: 2px auto 14px; padding: 0 2px;
}
.dh-date { font-size: 16px; font-weight: 800; color: var(--text); }
.dh-sub { font-size: 12px; color: var(--muted); }

/* 卡片流：桌面约 6~7 张一行（居中窄列），窄屏 4 张 */
.slot-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 8px; max-width: 800px; margin: 0 auto;
}
.s-card {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 3px 6px; min-height: 40px; box-shadow: 0 1px 2px rgba(30,50,90,.04);
  transition: all .12s; user-select: none;
}
.s-head { display: flex; align-items: baseline; gap: 3px; min-width: 0; }
.s-time { font-weight: 700; font-size: 12px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.s-main { margin-top: auto; font-weight: 700; font-size: 11px; line-height: 1.2; overflow-wrap: anywhere; min-width: 0; }
.s-main.dim { color: var(--muted); text-decoration: line-through; }
.s-badge {
  position: absolute; top: 2px; right: 4px; font-size: 8px; font-weight: 700;
  line-height: 1.15; padding: 0 4px; border-radius: 999px; border: 1px solid #cfe0ff;
  background: #fff; color: var(--brand-dark); white-space: nowrap;
}
.s-skip { align-self: flex-start; font-size: 8px; font-weight: 600; color: #fff; background: var(--danger); border-radius: 999px; padding: 0 5px; line-height: 1.5; }

/* 卡片状态：可约(灰虚) / 固定(绿实) / 临时(绿虚) / 停一次(淡灰) */
.s-card.free { background: #fbfcfe; border-style: dashed; border-color: #d3dce7; cursor: pointer; }
.s-card.free:hover { border-color: #aebfd6; }
.s-card.booked { cursor: pointer; }
.s-card.fixed, .s-card.lesson { background: var(--c-class-bg); border-color: #b7e2c8; }
.s-card.temp { background: var(--c-class-bg); border-color: #a4d9b9; border-style: dashed; }
.s-card.fixed:hover, .s-card.temp:hover, .s-card.lesson:hover { filter: brightness(.97); }
.s-card.skipped { background: #f4f6f9; border-style: dashed; border-color: #d3dce7; }

/* 学生视角卡：老师名 + 会议号 */
.s-teacher { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 11px; line-height: 1.2; min-width: 0; margin-top: auto; }
.s-teacher > span { min-width: 0; overflow-wrap: anywhere; }
.s-teacher .avatar { flex-shrink: 0; }
.s-card .s-teacher .avatar.sm { width: 18px; height: 18px; font-size: 9px; }
.s-foot { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; padding-top: 3px; border-top: 1px dashed rgba(120,140,170,.35); min-width: 0; }
.s-foot .meeting-copy, .s-foot .meeting-link {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 9px; padding: 1px 6px; border-radius: 6px;
}

/* 学生信息弹层（老师点已约卡） */
.student-info .si-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.student-info .si-name { font-size: 18px; font-weight: 800; word-break: break-word; }
.si-row { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.si-row:last-of-type { border-bottom: none; }
.si-label { width: 62px; color: var(--muted); flex-shrink: 0; }
.si-val { font-weight: 600; color: var(--text); min-width: 0; word-break: break-word; }

/* 工作时间 7×30 矩阵：点一格即时 PUT/DELETE 保存。
   列数由 JS 按 SLOT_COUNT 动态设为 inline grid-template-columns（见 renderHours），此处不再写死 repeat(N)。 */
.hours-matrix { display: flex; flex-direction: column; gap: 8px; }
.hm-row { display: flex; align-items: center; gap: 10px; }
.hm-day { width: 52px; flex-shrink: 0; font-weight: 700; font-size: 13px; }
.hm-chips {
  display: grid; gap: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; min-width: 0;
}
.hm-chip {
  height: 26px; padding: 0; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; color: var(--muted); font-size: 9px; font-family: inherit;
  cursor: pointer; transition: all .12s; font-variant-numeric: tabular-nums;
}
.hm-chip:hover { border-color: var(--brand); color: var(--brand-dark); }
.hm-chip.on { background: var(--c-class-bg); border-color: #9ed6b9; color: #1f7a48; font-weight: 700; }
.hm-chip.busy { opacity: .55; cursor: default; }
.hm-chip:disabled { cursor: default; }

@media (max-width: 980px) {
  .weeknav { top: 96px; }
}
@media (max-width: 760px) {
  .weeknav { top: 8px; margin-bottom: 12px; }
  /* 手机课表卡：一行 4 张（原 2 张），卡宽约 80px，字号略收防溢出 */
  .slot-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .s-card { min-height: 50px; padding: 3px 5px; }
  .s-time { font-size: 11px; }
  .s-main { font-size: 10px; }
  .s-teacher { font-size: 10px; }
  .s-card .s-teacher .avatar.sm { width: 14px; height: 14px; font-size: 8px; }
  .day-head { max-width: none; margin-bottom: 10px; }
  .hm-chip { height: 30px; }
  .hm-day { width: 46px; }
}
@media (max-width: 380px) {
  /* 极窄屏也保持一行 4 张，卡再薄一点 */
  .slot-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .s-card { padding: 3px 4px; }
}

/* 移动端：本周/下周开关缩小，保证 7 列整行放下 */
@media (max-width: 480px) {
  .wn-wkbtn { font-size: 10px; padding: 2px 6px; }
}
/* 极窄屏：WeekNav 7 格仍整行平铺，缩小字号/间距防溢出 */
@media (max-width: 400px) {
  .weeknav { padding: 6px 6px; }
  .wn-days { gap: 2px; }
  .wn-day { padding: 6px 1px 8px; }
  .wn-day .wn-wd { font-size: 12px; }
  .wn-date { font-size: 9px; }
}

/* ============================================================
   管理员排课：点空卡排课弹层（选学生 + 固定/临时课型）
   ============================================================ */
.book-modal { text-align: left; }
.book-modal .bm-who {
  display: flex; align-items: center; gap: 8px;
  background: #f6f8fb; border-radius: 10px; padding: 8px 12px;
  margin: 2px 0 12px; font-size: 13px; color: var(--muted);
  min-width: 0;
}
.book-modal .bm-who b { color: var(--text); }
.book-modal .bm-who span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 课型单选：两枚横排的“胶囊”，选中态与 .sp-item.sel 一致 */
.bm-types { display: flex; gap: 8px; margin: 2px 0 4px; }
.bm-type {
  flex: 1; display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; cursor: pointer; font-size: 13px; line-height: 1.35;
  transition: all .12s; user-select: none;
}
.bm-type:hover { border-color: var(--brand); }
.bm-type.sel { border-color: var(--brand); background: #eaf1ff; }
.bm-type input { width: auto; height: auto; margin: 0; flex-shrink: 0; accent-color: var(--brand); }

/* 管理员点已约卡 → 课程管理弹层 */
.lesson-manage .mng-skipbadge {
  display: block; font-size: 13px; font-weight: 600;
  color: #a16207; background: var(--c-leave-bg);
  border: 1px solid #f5d9a6; border-radius: 10px;
  padding: 8px 12px; margin: 8px 0 2px;
}
/* 管理弹层里的主操作按钮整行排列 */
.lesson-manage .modal-actions { flex-wrap: wrap; }
.lesson-manage .modal-actions .btn.danger { border-color: var(--danger); }

/* ============================================================
   V2 课表页头：本月出勤统计（右对齐小字）
   ============================================================ */
.m-stat { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* 老师课表页：weeknav 与卡片流之间的一行提示（小字号，不撑布局） */
.v2-tip { margin: -6px 0 12px; font-size: 12px; line-height: 1.4; color: var(--muted); }

/* ============================================================
   排课弹层：现场添加新学生输入区（选中「＋ 现场添加」后显示）
   ============================================================ */
.new-stu-box {
  border: 1px dashed #c7d2e0; border-radius: 10px; padding: 2px 12px 8px;
  margin: 0 0 4px; background: #fbfcfe;
}

/* ============================================================
   老师学生信息弹层：课后出席标记区
   ============================================================ */
.si-mark {
  border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.si-mark-badge {
  align-self: flex-start; font-size: 13px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px;
}
.si-mark-badge.att { color: #1f7a48; background: var(--c-class-bg); border: 1px solid #b7e2c8; }
.si-mark-badge.abs { color: var(--danger); background: #fdecec; border: 1px solid #f5c2c3; }
.si-mark-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ============================================================
   管理员「老师注册码」弹层（老师自助注册邀请码）
   ============================================================ */
.inv-box { width: min(680px, 96vw); }
.inv-genrow { display: flex; gap: 8px; margin: 0 0 12px; }
.inv-genrow input { flex: 1; min-width: 0; margin-bottom: 0; }
.inv-genrow .btn { flex-shrink: 0; }
.inv-result {
  border: 1px dashed var(--line); border-radius: 10px; background: #fbfcfe;
  padding: 14px 14px 10px; margin-bottom: 12px; text-align: center;
}
.inv-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
  font-size: 28px; font-weight: 800; letter-spacing: 3px; color: var(--brand-dark);
  font-variant-numeric: tabular-nums; word-break: break-all; line-height: 1.3;
}
.inv-copybtns { justify-content: center; margin-top: 12px; }
.inv-tip {
  color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 14px;
  background: #f6f8fb; border-radius: 8px; padding: 8px 10px;
}
.inv-listwrap { max-height: 40vh; overflow: auto; }
.inv-empty { padding: 18px 0; text-align: center; }
.inv-tbl th, .inv-tbl td { padding: 7px 9px; font-size: 13px; white-space: nowrap; }
.inv-code-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
  font-weight: 700; letter-spacing: 1px;
}
@media (max-width: 760px) {
  .inv-box { width: 94vw; }
  .inv-genrow { flex-wrap: wrap; }
  .inv-genrow .btn { width: 100%; }
}
