:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(17, 24, 39, .07);
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid transparent; background: var(--primary); color: #fff;
  cursor: pointer; font-weight: 600; transition: .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.gray { background: #eef1f6; color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.huge { min-height: 64px; font-size: 20px; border-radius: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}

h1, h2, h3 { margin: 0 0 10px; line-height: 1.35; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.right { text-align: right; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; background: #eef1f6; color: var(--muted); }
.pill.ok { background: #e7f7ee; color: var(--ok); }
.pill.bad { background: #fdeaea; color: var(--danger); }
.pill.warn { background: #fdf3e3; color: var(--warn); }
.pill.blue { background: #e8efff; color: var(--primary); }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 28px 22px; }
.login-box h1 { font-size: 26px; text-align: center; margin-bottom: 4px; }
.login-box .sub { text-align: center; color: var(--muted); margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 52px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 10px; outline: none; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.login-box .btn { min-height: 56px; font-size: 19px; }

/* 顶栏与导航 */
.topbar {
  position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar .who { font-size: 13px; color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 57px; z-index: 9; }
.nav a { white-space: nowrap; padding: 8px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 600; }
.nav a.active { background: #e8efff; color: var(--primary); }

.page { max-width: 980px; margin: 0 auto; padding: 16px 14px 90px; }

/* 寝室卡片 */
.dorm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.dorm-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; cursor: pointer; border: 2px solid transparent; position: relative; }
.dorm-card:active { transform: scale(.98); }
.dorm-card.done { border-color: #bfe8cf; }
.dorm-card.dirty { border-color: #f6c2c2; }
.dorm-card .no { font-size: 26px; font-weight: 800; letter-spacing: 1px; }
.dorm-card .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.dorm-card .score { font-size: 15px; font-weight: 700; margin-top: 6px; }
.dorm-card .tags { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }

/* 检查页床位条 */
.bed-list { display: flex; flex-direction: column; gap: 10px; }
.bed-row { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 12px; display: flex; gap: 10px; align-items: center; }
.bed-row .who { flex: 1; min-width: 0; }
.bed-row .who .name { font-size: 20px; font-weight: 700; }
.bed-row .who .bn { font-size: 13px; color: var(--muted); }
.bed-row .act { display: flex; gap: 8px; }
.bed-row .act .btn { min-height: 52px; padding: 0 14px; font-size: 16px; }
.bed-row.locked { opacity: .55; }
.bed-row.hit { background: #fff7f7; border-left: 5px solid var(--danger); }

/* 弹层 */
.sheet-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 20; display: none; }
.sheet-mask.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: #fff;
  border-radius: 18px 18px 0 0; max-height: 86vh; overflow-y: auto;
  padding: 18px 16px calc(46px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease;
}
.sheet.show { transform: translateY(0); }
.sheet h3 { font-size: 20px; margin-bottom: 4px; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 14px 0; }
.item-chip {
  padding: 14px 10px; border-radius: 10px; border: 2px solid var(--line); background: #fff;
  cursor: pointer; font-size: 15px; text-align: center; line-height: 1.35;
}
.item-chip.on { border-color: var(--danger); background: #fff1f1; color: var(--danger); font-weight: 700; }
.item-chip small { display: block; color: var(--muted); font-size: 12px; }

/* 表格 */
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; font-weight: 700; color: #374151; position: sticky; top: 0; }
td.wrap { white-space: normal; min-width: 140px; }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 28px; font-weight: 800; margin-top: 2px; }
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .n { width: 92px; font-weight: 600; font-size: 14px; }
.bar-track { flex: 1; height: 14px; background: #eef1f6; border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); }
.bar-row .s { width: 52px; text-align: right; font-weight: 700; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--primary); color: #fff; border-color: var(--primary); }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 12px 20px; border-radius: 10px; opacity: 0; transition: .2s; z-index: 30; font-size: 15px; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--danger); }

.fabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: #fff;
  border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; max-width: 100%;
}
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid #c7d2fe; border-top-color: var(--primary); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .bed-row .act .btn { min-height: 54px; padding: 0 12px; font-size: 15px; }
  .dorm-card .no { font-size: 24px; }
  .page { padding: 12px 10px 96px; }
}
