/* ============ 校园喊话系统 · 公共样式（浅色主题） ============ */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e3e8f0;
  --line-strong: #cbd5e1;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --brand: #2563eb;
  --brand-soft: #eff5ff;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --violet: #7c3aed;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB",
    -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- 布局 ---------- */
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  flex: none;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--text-2); }
.topbar .who b { color: var(--text); }

.wrap { max-width: 1320px; margin: 0 auto; padding: 20px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1080px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card > header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px;
}
.card > header .tag { font-weight: 400; }
.card > .body { padding: 18px; }

/* ---------- 表单 ---------- */
label.fld { display: block; margin-bottom: 14px; }
label.fld > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }

.input, select.input, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea.input { resize: vertical; min-height: 72px; line-height: 1.7; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--brand-soft); border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:disabled:hover { border-color: var(--line-strong); color: inherit; }
.btn.primary:disabled:hover { background: var(--brand); }

/* ---------- 徽标 / 状态点 ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line);
}
.pill.on { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.pill.off { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.pill.warn { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.pill.info { background: var(--brand-soft); color: var(--brand); border-color: #bfdbfe; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.16); }
.dot.off { background: #d1d5db; }

/* ---------- 班级选择网格 ---------- */
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.class-chip {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; cursor: pointer; background: #fff; text-align: left;
  display: flex; align-items: center; gap: 7px; transition: all .12s; font-size: 13px;
}
.class-chip:hover { border-color: var(--brand); }
.class-chip.sel { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.class-chip .nm { flex: 1; font-weight: 500; }

.grade-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.grade-row:last-child { border-bottom: none; }
.grade-row > .glabel { width: 74px; flex: none; font-size: 13px; color: var(--text-2); font-weight: 600; padding-top: 6px; }

/* ---------- 快捷物品按钮 ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.word-chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: #fff; cursor: pointer; font-size: 13px; transition: all .12s;
}
.word-chip:hover { border-color: var(--brand); color: var(--brand); }
.word-chip.sel { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 学号键盘 ---------- */
.num-pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.num-pad .num {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff;
  padding: 7px 0; cursor: pointer; font-size: 13px; transition: all .12s; text-align: center;
}
.num-pad .num:hover { border-color: var(--brand); color: var(--brand); }
.num-pad .num.sel { background: var(--violet); border-color: var(--violet); color: #fff; font-weight: 600; }

/* ---------- 列表 ---------- */
.list { max-height: 340px; overflow: auto; }
.list .row {
  display: flex; align-items: center; gap: 10px; padding: 10px 2px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.list .row:last-child { border-bottom: none; }
.list .row .t { color: var(--text-3); font-size: 12px; flex: none; width: 118px; }

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

/* ---------- 提示条 ---------- */
.notice {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.notice.info { background: var(--brand-soft); color: #1e40af; border: 1px solid #bfdbfe; }
.notice.ok { background: var(--green-soft); color: #166534; border: 1px solid #bbf7d0; }
.notice.warn { background: var(--amber-soft); color: #92400e; border: 1px solid #fde68a; }
.notice.err { background: var(--red-soft); color: #991b1b; border: 1px solid #fecaca; }

/* ---------- toast ---------- */
#toast-box { position: fixed; top: 70px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow-lg); animation: slideIn .22s ease;
  max-width: 380px;
}
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 8px 10px; background: var(--panel-2); color: var(--text-2);
  font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl input[type="text"], table.tbl select, table.tbl input[type="time"] {
  width: 100%; padding: 5px 8px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: #fff; outline: none;
}
table.tbl input[type="text"]:focus, table.tbl select:focus { border-color: var(--brand); }

/* ---------- 宽表：固定列宽 + 超长截断 + 横向滚动 ----------
 *
 * 为什么需要这一段（老师反馈的真实问题）：
 *   账号表有 9 列，各列内容长度差异极大 —— 「姓名」「学科」只有两三个字，
 *   而「任教班级」可能是一串「三年级1班、三年级2班、三年级3班…」。
 *   默认的 table-layout:auto 会**按内容**分配宽度，于是：
 *     · 长的那列把卡片撑破（溢出）；
 *     · 短的那些列被压到只剩几个字宽，输入框窄得没法用。
 *   百分比宽度在 auto 布局下只是「建议」，写了也不作数。
 *   改成 table-layout:fixed 后，百分比才真正生效，各列宽度可控。
 *
 * 配套：内容超长时用 .tbl-ellip 截断（鼠标悬停看 title 全文），
 *       窄屏下用 .tbl-scroll 横向滚动，而不是把每列压成一条。
 */
table.tbl.tbl-fixed { table-layout: fixed; }
.tbl-ellip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-scroll > table.tbl { min-width: 1020px; }

/* 表格里放多个按钮的「操作」列。
 * 注意：不要在 <td> 上直接写 display:flex —— td 变成 flex 容器后会脱离
 * 表格布局，在 table-layout:fixed 下表现为该单元格不参与列宽分配，列会错位。
 * 正确做法是 td 保持默认，里面套一个 flex 的 div。 */
.cell-acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
/* 操作列按钮窄一点，四个按钮才排得下且不换行到难看 */
.cell-acts .btn.sm { padding: 4px 8px; font-size: 12px; }

/* ---------- 离线行高亮 ----------
 * 老师的真实需求：一体机断网/关机时，要在一屏表格里**一眼扫到**是哪几台。
 * 只靠一个灰色「离线」小圆点不够 —— 二十几个班里找三个离线班很费眼。
 * 这里给离线行加浅红底 + 左侧红色竖条，在线行保持白底。
 * 注意：用 background 而不是改文字色，避免把输入框里的字也染红。
 */
table.tbl tr.row-off > td { background: var(--red-soft); }
table.tbl tr.row-off > td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table.tbl tr.row-off:hover > td { background: #fee2e2; }
/* 已停用（管理员主动关掉的）不算故障，用中性灰，别和「离线待查」混淆 */
table.tbl tr.row-disabled > td { background: #f1f5f9; }
table.tbl tr.row-disabled > td:first-child { box-shadow: inset 3px 0 0 var(--text-3); }
/* 由于单元格有背景色，表头需要盖住行背景，保持原样 */
table.tbl tr.row-off > td .input,
table.tbl tr.row-disabled > td .input { background: #fff; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  padding: 9px 16px; border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; margin-bottom: -1px;
}
.tabs button:hover { color: var(--brand); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- 视频 ---------- */
.video-box {
  position: relative; background: #0b1220; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 9; display: grid; place-items: center;
}
.video-box video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-box .ph { color: #64748b; font-size: 13px; text-align: center; padding: 20px; }
.video-box .live-tag {
  position: absolute; top: 10px; left: 10px; background: rgba(220,38,38,.92); color: #fff;
  font-size: 11px; padding: 3px 9px; border-radius: 4px; display: flex; align-items: center; gap: 5px;
  font-weight: 600; letter-spacing: .5px;
}
.video-box .live-tag .d { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------- 开关 ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 999px; background: #cbd5e1; position: relative; transition: .18s; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); }

.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---------- 安全上下文提示横幅（http 下麦克风/摄像头不可用） ---------- */
.scs-secure-banner {
  position: sticky; top: 0; z-index: 900;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin: 0;
  background: #fef3c7; color: #78350f;
  border-bottom: 1px solid #fcd34d;
  font-size: 13px; line-height: 1.45;
}
.scs-secure-banner span { flex: 1; }
.scs-secure-banner .btn.sm { flex: none; }
.scs-secure-close {
  flex: none; width: 24px; height: 24px; border: 0; border-radius: 6px;
  background: transparent; color: #78350f; font-size: 17px; line-height: 1;
  cursor: pointer;
}
.scs-secure-close:hover { background: rgba(120, 53, 15, .12); }

/* 微信内置浏览器专用：这条不是「操作失败」而是「环境限制」，
   用中性的蓝色信息条，避免老师以为系统坏了。 */
.scs-secure-banner.wx {
  background: #e0f2fe; color: #075985; border-bottom-color: #7dd3fc;
}
.scs-secure-banner.wx .scs-secure-close { color: #075985; }
.scs-secure-banner.wx .scs-secure-close:hover { background: rgba(7, 89, 133, .12); }

/* ---------- 手机 / 微信内置浏览器适配 ---------- */
/* 老师常把地址发到微信群，直接在微信里点开。这里保证窄屏可用：
   顶栏不换行、页卡可横滑、按钮够大好点、输入框不小于 16px（iOS 不缩放）。 */
@media (max-width: 720px) {
  .topbar { height: auto; min-height: 52px; padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar h1 { font-size: 15px; }
  .topbar .who { display: none; }
  .wrap { padding: 12px; }
  .card > .body { padding: 14px; }
  .tabs { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 4px; }
  .tabs button { white-space: nowrap; flex: none; }
  .input, select.input, textarea.input, .btn { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 32px; font-size: 13px; }
  .class-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .scs-secure-banner { font-size: 12.5px; padding: 8px 10px; }
  .scs-secure-banner .btn.sm { padding: 4px 8px; }
}

/* ---------- 通用确认弹窗 ---------- */
.scs-confirm-mask {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: scsFade .14s ease-out;
}
@keyframes scsFade { from { opacity: 0 } to { opacity: 1 } }
.scs-confirm-box {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
  animation: scsPop .16s ease-out;
}
@keyframes scsPop { from { transform: scale(.96); opacity: .6 } to { transform: scale(1); opacity: 1 } }
.scs-confirm-box h4 { margin: 0 0 10px; font-size: 16px; color: var(--text-1, #0f172a); }
.scs-confirm-box p {
  margin: 0 0 16px; font-size: 13.5px; line-height: 1.6;
  color: var(--text-2, #475569); white-space: pre-wrap;
}
.scs-confirm-row { display: flex; justify-content: flex-end; gap: 8px; }
