* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #1f2d3d;
  --text-2: #8492a6;
  --danger: #d9534f;
  --ok: #28a745;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 70px;
  position: relative;
  box-shadow: 0 0 20px rgba(0,0,0,.06);
}

/* 顶栏 */
.topbar {
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  padding: 18px 16px 22px;
  border-radius: 0 0 18px 18px;
}
.room-name { font-size: 20px; font-weight: 700; }
.room-sub { font-size: 12px; opacity: .85; margin-top: 4px; }

/* 视图切换 */
.view { display: none; padding: 12px; }
.view.active { display: block; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card h2 { font-size: 15px; margin-bottom: 10px; }
.card p, .card li { font-size: 13px; color: #4a5568; line-height: 1.7; }
.notice ul { padding-left: 18px; }
.intro p { line-height: 1.8; }

.loading { text-align: center; color: var(--text-2); font-size: 13px; padding: 20px 0; }

/* 首页 7 天概览 */
.day-row {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0; border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
}
.day-row:last-child { border-bottom: none; }
.day-label { width: 74px; flex-shrink: 0; font-size: 13px; }
.day-label .wk { color: var(--text-2); font-size: 11px; }
.today-badge {
  display: inline-block; background: var(--primary); color: #fff;
  font-size: 10px; border-radius: 4px; padding: 0 4px; margin-left: 3px;
}
.mini-slots { display: flex; gap: 4px; flex: 1; }
.mini-slot {
  flex: 1; height: 8px; border-radius: 4px;
  background: #bfdbfe;
}
.mini-slot.full { background: #e0e4e8; }

/* 日期条 */
.date-strip {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.date-strip::-webkit-scrollbar { display: none; }
.date-item {
  flex-shrink: 0; width: 56px; padding: 8px 0; text-align: center;
  border: 1px solid #e2e8f0; border-radius: 10px; cursor: pointer;
  background: #fff;
}
.date-item .d { font-size: 14px; font-weight: 600; }
.date-item .w { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.date-item.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.date-item.selected .w { color: rgba(255,255,255,.85); }

/* 时段 */
.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot-item {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px;
  cursor: pointer; background: #fff; font-size: 14px;
}
.slot-item.selected { border-color: var(--primary); background: #eff6ff; color: var(--primary-dark); font-weight: 600; }
.slot-item.full { background: #f5f6f8; color: #b0b8c1; cursor: not-allowed; }
.slot-item .tag { font-size: 11px; color: var(--text-2); }
.slot-item.selected .tag { color: var(--primary); }

/* 表单 */
.form label { display: block; font-size: 13px; margin-bottom: 12px; color: #4a5568; }
.form input, .form textarea {
  width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1px solid #dbe2ea; border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fafbfc;
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--primary); background: #fff; }

.btn {
  border: none; border-radius: 8px; padding: 10px 16px;
  font-size: 14px; cursor: pointer; background: #eef1f4; color: var(--text);
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.block { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { background: #fdecea; color: var(--danger); }

/* 我的预约 */
.booking-card { margin-bottom: 12px; }
.booking-card .bc-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.booking-card .bc-date { font-size: 15px; font-weight: 600; }
.badge { font-size: 11px; border-radius: 4px; padding: 2px 6px; }
.badge.booked { background: #dbeafe; color: var(--primary); }
.badge.checked_in { background: #e8f5e9; color: var(--ok); }
.badge.cancelled { background: #f2f3f5; color: #9aa5b1; }
.bc-row { font-size: 13px; color: #4a5568; margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.bc-row .v { font-weight: 600; color: var(--text); }
.copyable { cursor: pointer; border-bottom: 1px dashed var(--primary); }
.bc-actions { display: flex; gap: 8px; margin-top: 12px; }

/* 管理端 */
.stat-row { display: flex; gap: 8px; margin-bottom: 12px; }
.stat-card {
  flex: 1; background: #fff; border-radius: 10px; padding: 12px 6px;
  text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.stat-card .n { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-card .t { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.admin-head h2 { margin-bottom: 0; }
.admin-head input { border: 1px solid #dbe2ea; border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.admin-item {
  border-bottom: 1px solid #f0f2f5; padding: 10px 0; font-size: 13px;
}
.admin-item:last-child { border-bottom: none; }
.admin-item .line1 { display: flex; justify-content: space-between; align-items: center; }
.admin-item .who { font-weight: 600; }
.admin-item .meta { color: var(--text-2); font-size: 12px; margin-top: 4px; }
.admin-item .ops { display: flex; gap: 8px; margin-top: 8px; }

/* 底部 tab */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  display: flex; background: #fff; border-top: 1px solid #e8ecf0;
  z-index: 10;
}
.tab {
  flex: 1; border: none; background: none; padding: 8px 0 10px;
  font-size: 18px; cursor: pointer; color: #9aa5b1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab span { font-size: 11px; }
.tab.active { color: var(--primary); }

/* Toast */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.75); color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 8px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 99; max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: 14px; padding: 20px;
  width: 84%; max-width: 340px;
}
.modal-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 12px; }
.modal-body { font-size: 14px; color: #4a5568; margin-bottom: 16px; }
.modal-body .big {
  font-size: 22px; font-weight: 700; color: var(--primary);
  text-align: center; letter-spacing: 2px; margin: 6px 0;
  cursor: pointer;
}
.modal-body .pwd {
  font-size: 26px; font-weight: 700; color: #d97706;
  text-align: center; letter-spacing: 4px; margin: 6px 0;
}
.modal-body .tip { font-size: 12px; color: var(--text-2); text-align: center; }

/* ---- 学号登录版新增 ---- */
.muted { font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.switch-line { text-align: center; font-size: 13px; color: var(--text-2); margin-top: 12px; }
.switch-line a { color: var(--primary); text-decoration: none; }

.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 10px; background: rgba(255,255,255,.18);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; color: #fff;
}
.user-chip a { color: #fff; opacity: .85; font-size: 12px; }

.contact-line {
  font-size: 17px !important; font-weight: 700; color: var(--primary) !important;
  margin-top: 6px;
}

/* ---- 温度计式概览 ---- */
.thermo {
  flex: 1; height: 12px; border-radius: 6px; background: #eef1f4;
  position: relative; overflow: hidden;
}
.thermo .fill {
  height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, #93c5fd, #2563eb);
  transition: width .3s;
}
.thermo.warm .fill { background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.thermo.hot .fill { background: linear-gradient(90deg, #fca5a5, #dc2626); }
/* 刻度线:10 格 */
.thermo .ticks {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg,
    transparent 0, transparent calc(10% - 1px),
    rgba(255,255,255,.9) calc(10% - 1px), rgba(255,255,255,.9) 10%);
}
.thermo-num { width: 44px; flex-shrink: 0; text-align: right; font-size: 11px; color: var(--text-2); }

/* ---- 小时多选格子 ---- */
.slot-group { margin-bottom: 12px; }
.slot-group:last-child { margin-bottom: 0; }
.slot-group-name {
  font-size: 13px; font-weight: 600; color: #4a5568; margin-bottom: 8px;
}
.hour-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hour-btn {
  border: 1px solid #e2e8f0; border-radius: 10px; background: #fff;
  padding: 10px 0 8px; text-align: center; cursor: pointer; font-size: 16px; font-weight: 600;
}
.hour-btn .h-sub { display: block; font-size: 10px; font-weight: 400; color: var(--text-2); margin-top: 2px; }
.hour-btn.selected { border-color: var(--primary); background: #eff6ff; color: var(--primary-dark); }
.hour-btn.selected .h-sub { color: var(--primary); }
.hour-btn.full { background: #f5f6f8; color: #b0b8c1; cursor: not-allowed; }
.hour-btn.full .h-sub { color: #c3cad2; }

/* ---- 7 天概览:时段格子图 ---- */
.day-cells { display: flex; gap: 4px; flex: 1; }
.day-cell {
  flex: 1; min-width: 0; text-align: center;
  font-size: 11px; font-weight: 600; line-height: 1;
  height: 16px; border-radius: 5px;
  background: #dbeafe; color: var(--primary-dark);
}
.day-cell.taken { background: #4b5563; color: #d1d5db; }
/* 上午/下午/晚上组间空隙 */
.day-cell.g-gap { margin-left: 10px; }
/* 顶部刻度行(尺子):数字标在格子分界线上 */
.scale-row { cursor: default; padding: 0; border-bottom: none; }
.scale-row .day-label { font-size: 11px; color: var(--text-2); }
.day-cell.scale { position: relative; height: 26px; background: transparent; }
.day-cell.scale .tick {
  position: absolute; left: 0; bottom: 0; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.day-cell.scale .tick.end { left: 100%; }
.day-cell.scale .grp {
  position: absolute; left: 0; top: 0;
  font-size: 10px; color: var(--primary); white-space: nowrap;
}

/* ---- 图例 ---- */
.legend {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 11px; color: #4a5568; margin-bottom: 10px;
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-box { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-box.free { background: #dbeafe; border: 1px solid #93c5fd; }
.legend-box.taken { background: #4b5563; }
