/* ===== 教室签到请假显示系统 · 样式 ===== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-present: #25a45e;
  --c-full: #f3a8a8; /* 全天请假：座位染色/图例用浅红 */
  --c-full-deep: #e04a4a; /* 全天请假：按钮选中/历史标签等实底场景（配白字） */
  --c-partial: #f5a623;
  --c-overtime: #d63031;
  --c-unknown: #c3cdd4;
}

html, body {
  height: 100%;
  overflow: hidden; /* 页面整体不滚动：全部内容缩放适配一屏 */
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: #f2f4f7;
  color: #26292e;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%; /* 防止 Android/微信自动放大文字破坏布局 */
}

body {
  /* 横屏左右分栏：左侧控制栏（顶栏 + 倒计时 + 左下角按钮），右侧整块座位图 */
  display: grid;
  grid-template-columns: clamp(170px, 20%, 240px) 1fr;
  grid-template-rows: auto 1fr auto;
}

/* ===== 顶栏 ===== */
.topbar {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  overflow-y: auto;
  background: #fff;
  border-bottom: 1px solid #edf0f3;
}

.title {
  font-size: 16px;
  font-weight: 700;
  color: #1f7a4d;
  overflow-wrap: anywhere;
}

/* 颜色状态图例（屏幕左下角）：两列紧凑排布，“未知原因未到”占整行 */
.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 8px;
  font-size: 12px;
  color: #4a5158;
}

.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-wide { grid-column: 1 / -1; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.dot.st-present { background: var(--c-present); }
.dot.st-full_leave { background: var(--c-full); }
.dot.st-partial_leave { background: var(--c-partial); }
.dot.st-overtime { background: var(--c-overtime); }
.dot.st-unknown { background: var(--c-unknown); }

.btn {
  border: none;
  cursor: pointer;
  border-radius: 8px;
  font-size: 14px;
  padding: 7px 16px;
  background: #eef1f4;
  color: #333;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(0.96); }
.btn:active { transform: scale(0.97); }

/* 屏幕左下角：颜色状态图例 + 设置 / 历史记录 按钮 */
.side-actions {
  grid-column: 1;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #edf0f3;
}
.side-btns { display: flex; gap: 8px; }
.side-btns .btn { flex: 1; padding: 7px 4px; font-size: 12.5px; white-space: nowrap; }
.btn-history { background: #1f7a4d; color: #fff; }
.btn-stats { width: 100%; padding: 7px 4px; font-size: 12.5px; background: #3a72b0; color: #fff; }

/* ===== 自习时段列表（左上角）：未到=灰色框体，自习中=绿色框体，已过不显示 ===== */
.period-badge {
  display: flex;
  flex-direction: column; /* 框体等宽：容器收缩到最宽框体，各行自动撑满同宽 */
  gap: 4px;
  max-width: 100%;
  cursor: pointer; /* 点击打开设置 */
}
.pb-time {
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  text-align: right; /* 框体内时间右靠齐 */
}
.pb-time.pb-now { background: #e6f6ec; color: #1f7a4d; border-color: #bfe6cd; }
.pb-time.pb-out { background: #f1f3f6; color: #6a727a; border-color: #e0e5ea; }
.pb-time.pb-break { background: #fdf4e3; color: #9a7b2d; border-color: #f0e0b8; } /* 休息中：浅黄框 */
.pb-time.pb-none { background: #fdf4e3; color: #9a7b2d; border-color: #f0e0b8; }

/* ===== 倒计时条 ===== */
.countdown-bar {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  overflow-y: auto;
  background: #fff;
  font-size: 13.5px;
  scrollbar-width: thin;
}

.cd-title { font-size: 12px; font-weight: 700; color: #98a1a9; letter-spacing: 1px; }
.cd-title-gap { margin-top: 4px; }
.cd-list { display: flex; flex-direction: column; gap: 8px; }

.cd-empty { color: #98a1a9; font-size: 13px; }
.cd-hidden { display: none; }

.cd-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff3d6;
  border: 1px solid #f5d78e;
}

.cd-item .cd-name { font-weight: 600; color: #7a5b00; }
.cd-item .cd-text { color: #b07d00; }

.cd-item.cd-over {
  background: #ffe4e4;
  border-color: #f5a3a3;
  animation: cd-blink 1.6s ease-in-out infinite;
}
.cd-item.cd-over .cd-name { color: #a01d1d; }
.cd-item.cd-over .cd-text { color: #c33; font-weight: 600; }

/* 列表条目快捷操作按钮：已到（绿）/ 未到（灰）/ 已离开（橙） */
.cd-actions { display: flex; gap: 6px; margin-top: 6px; }
.cd-btn {
  padding: 4px 14px;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.cd-btn:hover { filter: brightness(0.94); }
.cd-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.cd-btn-arrive { background: var(--c-present); }
.cd-btn-absent { background: #8a9a92; }
.cd-btn-leave { background: var(--c-partial); }

@keyframes cd-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

/* ===== 座位图 ===== */
.map-area {
  grid-column: 2;
  grid-row: 1 / 4;
  min-height: 0;
  min-width: 0;
  padding: 10px 14px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.map-wrap {
  position: relative;
  width: 100%; /* fitMap() 初始化后会设置为精确像素尺寸，保证完整显示 */
  aspect-ratio: 3408 / 2043; /* JS 初始化前的兜底比例（裁剪后的房间区域图） */
  container-type: inline-size;
}

.map-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

/* 学生按钮 = 染色层：坐标来自 data/seats.json（座位区域）。
   mix-blend-mode: multiply 只把白色底面染成状态色，
   黑色名字笔画相乘后仍为黑色——名字显示原图，不渲染文字 */
.seat {
  position: absolute;
  padding: 0;
  border: none;
  border-radius: 12%;
  background: var(--c-unknown); /* 默认：未知原因未到（淡灰） */
  mix-blend-mode: multiply;
  cursor: pointer;
  transition: background .25s, opacity .25s;
}

.seat:hover { filter: brightness(0.92); }
.seat:active { opacity: 0.72; }

/* 状态配色（multiply 后即为呈现色） */
.seat[data-st="present"] { background: var(--c-present); }
.seat[data-st="full_leave"] { background: var(--c-full); }
.seat[data-st="partial_leave"] { background: var(--c-partial); }
.seat[data-st="overtime"] {
  background: var(--c-overtime);
  animation: seat-pulse 1.5s ease-in-out infinite;
}
.seat[data-st="unknown"] { background: var(--c-unknown); }

/* 非自习时段且未签到：不染色，保持底图白净（仍可点击设置） */
.seat[data-st="idle"] { background: transparent; }
.seat[data-st="idle"]:hover { background: rgba(148, 163, 184, 0.4); }

/* 明日请假：淡化 */
.seat.future { opacity: 0.55; }

@keyframes seat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* 状态角标：迷你圆形徽章，贴在座位右上角外侧，不遮挡名字 */
.seat-badge {
  position: absolute;
  transform: translate(25%, -40%);
  z-index: 3;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  min-width: min(1.15cqw, 14px);
  height: min(1.15cqw, 14px);
  padding: 0;
  border-radius: 999px;
  font-size: 10px;
  font-size: min(0.85cqw, 10px);
  font-weight: 700;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
  background: rgba(70, 78, 88, 0.92);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.seat-badge[data-st="overtime"] { background: rgba(214, 48, 49, 0.96); }
/* 流程进行中（在途/待回来/待离开）：琥珀色“!”角标 */
.seat-badge[data-st="alert"] { background: rgba(230, 152, 0, 0.96); }

/* ===== 弹窗 ===== */
/* 全局修复：[hidden] 必须优先于任何自定义 display（如 .modal-overlay 的 flex），
   否则弹窗设置了 hidden 也关不掉 */
[hidden] { display: none !important; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 26, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: min(88vh, 88%); /* 竖屏旋转模式下 vh 会溢出，用父容器百分比兜底 */
  overflow-y: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: modal-up .22s ease-out;
}
@media (min-width: 640px) {
  .modal { border-radius: 18px; }
}

@keyframes modal-up {
  from { transform: translateY(28px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 宽屏左右分栏弹窗（家长操作 / 设置）：内容一屏可见；
   窄屏（含手机竖屏输入模式）自动恢复上下堆叠 */
.modal-main,
.modal-settings { max-width: min(94vw, 720px); }

.modal-main .modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 16px;
  align-items: start;
}
.modal-main .action-grid { margin-bottom: 0; }
.modal-main .leave-form { border-top: none; padding-top: 0; }
.modal-side { min-width: 0; }

.modal-settings .modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.set-col { min-width: 0; }

@media (max-width: 620px) {
  .modal-main .modal-body { grid-template-columns: 1fr; gap: 0; }
  .modal-main .action-grid { margin-bottom: 14px; }
  .modal-main .leave-form { border-top: 1px dashed #e3e7eb; padding-top: 12px; }
  .modal-settings .modal-body { grid-template-columns: 1fr; gap: 0; }
  .modal-settings .set-col + .set-col .set-section {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px dashed #e3e7eb;
  }
}

.modal-head { position: relative; padding-right: 36px; margin-bottom: 14px; }
.modal-head h2 { font-size: 19px; }
.modal-sub { font-size: 13px; color: #7b838b; margin-top: 3px; }

.modal-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #f0f2f5;
  color: #555;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: #e5e8ec; }

/* 动作按钮组 */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.act-btn {
  padding: 12px 10px;
  border-radius: 12px;
  border: 2px solid #e3e7eb;
  background: #f8fafb;
  font-size: 15px;
  font-weight: 600;
  color: #3a4047;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.act-btn:hover { border-color: #c9d2da; }

.act-btn.selected { color: #fff; }

.act-present.selected { background: var(--c-present); border-color: var(--c-present); }
.act-full.selected { background: var(--c-full-deep); border-color: var(--c-full-deep); }
.act-partial.selected { background: var(--c-partial); border-color: var(--c-partial); }
.act-clear.selected { background: #64707c; border-color: #64707c; }

/* 请假表单 */
.leave-form { border-top: 1px dashed #e3e7eb; padding-top: 12px; margin-bottom: 12px; }

.form-row { margin-bottom: 12px; }
.form-row label {
  display: block;
  font-size: 13px;
  color: #6a727a;
  margin-bottom: 6px;
}

.form-row input[type="text"],
.form-row input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8dee4;
  border-radius: 10px;
  font-size: 16px; /* ≥16px 避免 iOS 聚焦输入框时自动放大页面 */
  background: #fff;
  color: #26292e;
}
.form-row input:focus { outline: 2px solid rgba(31, 122, 77, 0.35); border-color: #1f7a4d; }

.time-range { display: flex; align-items: center; gap: 8px; }
.time-range span { color: #7b838b; font-size: 13px; }

/* 分段按钮（今天/明天） */
.seg { display: inline-flex; background: #eef1f4; border-radius: 10px; padding: 3px; }
.seg-btn {
  border: none;
  background: transparent;
  padding: 7px 22px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #555;
}
.seg-btn.active { background: #fff; color: #1f7a4d; font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.modal-actions .btn { flex: 1; padding: 12px; font-size: 15px; }
.btn-cancel { background: #eef1f4; color: #555; }
.btn-primary { background: #1f7a4d; color: #fff; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

/* ===== 历史记录 ===== */
.modal-history { max-width: 620px; }

/* ===== 统计分析：左侧日历 + 右侧柱状图与实到时间 ===== */
.modal-stats { max-width: min(94vw, 820px); }
.stats-body { display: flex; gap: 14px; align-items: flex-start; }
.stats-cal {
  flex: 0 0 234px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: #f7faf8;
  border: 1px solid #e6ece8;
  border-radius: 12px;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-nav {
  width: 30px;
  height: 26px;
  border: 1px solid #d8e2dc;
  border-radius: 8px;
  background: #fff;
  color: #1f7a4d;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.cal-nav:hover { background: #eef7f1; }
.cal-title { font-size: 14px; font-weight: 700; color: #22302a; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 11px; color: #8a9a92; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-cell {
  position: relative;
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #33413a;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cal-cell:hover:not(:disabled) { background: #e8f3ec; }
.cal-cell.cal-out { visibility: hidden; }
.cal-cell:disabled { color: #c4cdc8; cursor: default; }
.cal-cell.cal-has::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 3px;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #58a97c;
}
.cal-cell.cal-today-mark { box-shadow: inset 0 0 0 1.5px #86bfa0; }
.cal-cell.cal-sel { background: #1f7a4d; color: #fff; font-weight: 700; }
.cal-cell.cal-sel.cal-has::after { background: #fff; }
.cal-today {
  margin-top: 2px;
  padding: 5px 0;
  border: 1px solid #cfe3d8;
  border-radius: 8px;
  background: #fff;
  color: #1f7a4d;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.cal-today:hover { background: #eef7f1; }
.stats-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.stats-date { font-size: 14px; font-weight: 700; color: #22302a; }
.stats-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-card { padding: 8px 6px; text-align: center; background: #f4f8f5; border: 1px solid #e6ece8; border-radius: 10px; }
.stat-card .num { font-size: 20px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card .lbl { margin-top: 2px; font-size: 11px; color: #6b7a72; }
.stat-card.c-present .num { color: #1f7a4d; }
.stat-card.c-full .num { color: #c05555; }
.stat-card.c-partial .num { color: #c98f1b; }
.stat-card.c-unknown .num { color: #7a8790; }
.stats-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 148px;
  padding: 8px 10px 6px;
  background: #fbfdfc;
  border: 1px solid #eef2f0;
  border-radius: 10px;
}
.chart-col { flex: 1; display: flex; flex-direction: column; height: 100%; min-width: 0; }
.chart-stack { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-height: 0; }
.chart-num { font-size: 12px; font-weight: 700; color: #33413a; font-variant-numeric: tabular-nums; }
.chart-bar { width: 62%; max-width: 44px; min-height: 6px; border-radius: 6px 6px 2px 2px; }
.chart-bar.c-present { background: linear-gradient(#3cb371, #1f7a4d); }
.chart-bar.c-full { background: linear-gradient(#e88a8a, #c05555); }
.chart-bar.c-partial { background: linear-gradient(#eab84e, #c98f1b); }
.chart-bar.c-unknown { background: linear-gradient(#c6cfd5, #9fadb6); }
.chart-lbl { margin-top: 4px; font-size: 11px; color: #6b7a72; text-align: center; white-space: nowrap; }
.stats-arrive-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 700; color: #22302a; }
.stats-arrive-note { font-size: 11px; font-weight: 400; color: #8a9a92; }
/* 每人实到时长：横向柱状图（满条 = 当天总自习时长） */
.stats-arrive { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.arr-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 74px; align-items: center; gap: 8px; }
.arr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #33413a; }
.arr-bar-wrap { min-width: 0; height: 12px; background: #eef2f0; border-radius: 6px; overflow: hidden; }
.arr-bar { height: 100%; min-width: 3px; border-radius: 6px; background: linear-gradient(90deg, #3cb371, #1f7a4d); transition: width .25s ease; }
.arr-time { text-align: right; font-size: 12px; font-weight: 600; color: #1f7a4d; font-variant-numeric: tabular-nums; }
.arr-empty { width: 100%; font-size: 12.5px; color: #8a9a92; }
@media (max-width: 639px) {
  .stats-body { flex-direction: column; }
  .stats-cal { flex: none; width: 100%; }
}

/* ===== 自习时间段设置 ===== */
.period-editor { display: flex; flex-direction: column; gap: 10px; }
.period-row { display: flex; align-items: center; gap: 10px; }
/* 时间选择按钮（替代系统时间控件，点击打开自定义滚轮选择器） */
.time-pick {
  padding: 10px 12px;
  border: 1px solid #d8dee4;
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: #b6bec7; /* 未选择时灰色占位 */
  font-variant-numeric: tabular-nums;
  text-align: center;
  cursor: pointer;
  -webkit-appearance: none;
}
.time-pick.has-val { color: #26292e; }
.time-pick:focus { outline: 2px solid rgba(31, 122, 77, 0.35); border-color: #1f7a4d; }
.form-row .time-pick { width: 100%; }
.time-range .time-pick,
.period-row .time-pick { flex: 1; min-width: 0; }
.period-row span { color: #7b838b; font-size: 13px; flex: 0 0 auto; }
/* 行内删除按钮（×）：移除该时间段 */
.row-del {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: #f6ebeb;
  color: #b04545;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.row-del:hover { background: #efd9d9; }
/* “＋ 添加时间段”：动态新增一行（数量不限） */
.add-period {
  margin-top: 10px;
  width: 100%;
  padding: 9px 0;
  border: 1px dashed #b9c4cd;
  border-radius: 10px;
  background: #f7f9fb;
  color: #1f7a4d;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.add-period:hover { background: #eef4f0; border-color: #1f7a4d; }
/* “上午请假 / 下午请假”：一键填入 12 点前后的开放时间段 */
.quick-row { display: flex; gap: 8px; margin-top: 8px; }
.quick-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid #cfe3d8;
  border-radius: 10px;
  background: #eef7f1;
  color: #1f7a4d;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.quick-btn:hover { background: #e2f1e8; border-color: #1f7a4d; }
.period-hint { font-size: 12.5px; color: #98a1a9; margin-top: 10px; }

/* 设置弹窗分节（自习时间段 / 访问密码） */
.set-section { font-size: 14px; font-weight: 700; color: #3a4047; }
/* 分栏布局下左右列标题不带分割线；堆叠时的分割线见 @media (max-width: 620px) */
.set-desc { font-size: 12.5px; color: #8b939b; margin: 4px 0 10px; }

/* 访问密码弹窗 */
.modal-pwd { max-width: 400px; }
.pwd-err { font-size: 13px; color: #d63031; margin-top: -4px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-empty { color: #98a1a9; font-size: 14px; text-align: center; padding: 26px 0; }

.his-item {
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfcfd;
}

.his-line1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.his-time { font-size: 12px; color: #98a1a9; }
.his-student { font-size: 15px; font-weight: 700; }
.his-change { font-size: 13px; color: #4a5158; }
.his-change b { font-weight: 700; }

.his-line2 { margin-top: 4px; font-size: 12.5px; color: #6a727a; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.his-ip { color: #7b6a94; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.tag.st-present { background: var(--c-present); }
.tag.st-full_leave { background: var(--c-full-deep); }
.tag.st-partial_leave { background: var(--c-partial); }
.tag.st-away { background: var(--c-partial); }
.tag.st-overtime { background: var(--c-overtime); }
.tag.st-unknown { background: #9aa3ab; }

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: rgba(30, 34, 40, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 22px;
  z-index: 99;
  animation: modal-up .2s ease-out;
  max-width: 86vw;
  text-align: center;
}

/* ===== 矮屏紧凑模式：横屏手机 / 竖屏被旋转后，给座位图让出更多空间 ===== */
@media (orientation: landscape) and (max-height: 500px),
       (orientation: portrait) and (max-width: 500px) {
  body { grid-template-columns: clamp(150px, 20%, 220px) 1fr; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .title { font-size: 14px; }
  /* 矮屏（手机横屏）下图例单列排布，避免两列放不下 */
  .legend { grid-template-columns: 1fr; font-size: 11.5px; gap: 3px; }
  .legend-wide { grid-column: auto; }
  .dot { width: 9px; height: 9px; }
  .side-actions { padding: 8px 10px; gap: 6px; }
  .side-btns .btn { padding: 5px 4px; font-size: 12px; }
  .countdown-bar { padding: 8px 10px; font-size: 12px; }
  .cd-item { padding: 6px 8px; }
  .map-area { padding: 6px 10px 8px; }
  /* 弹窗紧凑化：矮屏上一屏显示全部内容（配合左右分栏） */
  .modal { max-height: 94%; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .modal-head { margin-bottom: 8px; }
  .modal-head h2 { font-size: 17px; }
  .modal-sub { font-size: 12px; }
  .modal-main .modal-body,
  .modal-settings .modal-body { gap: 12px; }
  .act-btn { padding: 9px 6px; font-size: 14px; }
  .action-grid { gap: 8px; margin-bottom: 10px; }
  .form-row { margin-bottom: 8px; }
  .form-row label { margin-bottom: 4px; font-size: 12px; }
  .time-pick { padding: 8px 10px; font-size: 15px; }
  .modal-actions .btn { padding: 9px; font-size: 14px; }
  .set-section { font-size: 13px; }
  .set-desc { margin: 3px 0 8px; }
  .period-editor { gap: 8px; }
  .add-period { margin-top: 8px; padding: 7px 0; font-size: 13px; }
  .row-del { width: 26px; height: 26px; font-size: 15px; }
}

/* ===== 时间选择器（自定义滚轮，跟随页面方向显示；替代系统时间控件） ===== */
.tp-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 20, 26, 0.5);
}
.tp-panel {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding-bottom: 12px;
  animation: tp-up 0.22s ease;
}
@keyframes tp-up {
  from { transform: translateY(48px); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}
.tp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #edf0f3;
}
.tp-title { font-size: 15px; font-weight: 700; color: #26292e; }
.tp-btn {
  padding: 7px 16px;
  border-radius: 10px;
  border: 1px solid #d8dee4;
  background: #f4f6f8;
  font-size: 14px;
  color: #3a4047;
  cursor: pointer;
}
.tp-ok { background: #1f7a4d; border-color: #1f7a4d; color: #fff; font-weight: 600; }
.tp-wheels {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
}
.tp-wheels::before,
.tp-wheels::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 76px;
  z-index: 3;
  pointer-events: none;
}
.tp-wheels::before { top: 0; background: linear-gradient(#fff 10%, rgba(255, 255, 255, 0)); }
.tp-wheels::after { bottom: 0; background: linear-gradient(rgba(255, 255, 255, 0), #fff 90%); }
.tp-band {
  position: absolute;
  left: 50%;
  top: calc(50% - 20px);
  width: 176px;
  height: 40px;
  transform: translateX(-50%);
  border-radius: 10px;
  background: rgba(31, 122, 77, 0.08);
  border: 1px solid rgba(31, 122, 77, 0.22);
  pointer-events: none;
}
.tp-col {
  width: 74px;
  height: 200px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  z-index: 1;
}
.tp-col::-webkit-scrollbar { display: none; }
/* 上下留白：使首尾项也能滚动到中央高亮区 */
.tp-col::before,
.tp-col::after { content: ''; display: block; height: 80px; }
.tp-item {
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: #b6bec7;
  scroll-snap-align: center;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s;
}
.tp-item.on { color: #1f7a4d; }
.tp-sep { font-size: 20px; font-weight: 700; color: #3a4047; padding-bottom: 2px; }
.tp-hint { font-size: 12.5px; color: #98a1a9; text-align: center; margin-top: -2px; }

/* ===== 竖屏强制横屏（整个页面旋转 90°，内容按横屏铺满） =====
   任何设备竖屏打开时，都按横屏布局渲染；转到横屏后自动恢复正常方向。 */
@media (orientation: portrait) {
  html { overflow: hidden; }
  body {
    position: fixed;
    top: 0;
    left: 100vw;
    width: 100vh;
    height: 100vw;
    left: 100dvw;
    width: 100dvh;
    height: 100dvw;
    transform: rotate(90deg);
    transform-origin: left top;
  }

  /* ===== 输入模式（kb-mode） =====
     系统键盘方向由手机决定（恒按竖屏弹出），网页无法改变，而页面被旋转了 90°，
     两者方向错位。聚焦输入框 / 打开输入类弹窗时临时取消旋转、按竖屏全屏显示，
     让输入框与键盘方向一致（用户把手机转回竖屏即可像普通网页一样打字），
     关闭弹窗后自动恢复横屏浏览。 */
  body.kb-mode {
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    transform: none;
  }
  body.kb-mode > .topbar,
  body.kb-mode > .countdown-bar,
  body.kb-mode > .side-actions,
  body.kb-mode > .map-area { visibility: hidden; }
  /* 弹窗贴顶显示，避免手机键盘遮住输入区域；内容超高时遮罩层可滚动 */
  body.kb-mode .modal-overlay { align-items: flex-start; overflow-y: auto; padding: 12px 0; }
  body.kb-mode .modal { margin: 0 auto; border-radius: 18px; }
}
