:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e7e9ed;
  --bg: #f4f5f7;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --mine: #dbeafe;
  --mine-ink: #1d4ed8;
  --other: #f1f2f4;
  --other-ink: #6b7280;
  --hall: #fef3c7;
  --hall-ink: #92400e;
  --block: #fee2e2;
  --block-ink: #991b1b;
  --group: #e0e7ff;
  --group-ink: #3730a3;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

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

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

#app { min-height: 100vh; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #f8f9fb; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { color: var(--block-ink); border-color: #fecaca; background: #fff5f5; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }

.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; outline: none;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; color: var(--muted); }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--faint); line-height: 1.6; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); cursor: pointer;
}
.chip.on { background: var(--accent-soft); border-color: #bfdbfe; color: var(--accent); font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #f7f9fc 0%, #eef2f7 100%);
}
.auth-card { width: 100%; max-width: 380px; padding: 30px 26px 24px; }
.auth-brand { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 22px; }
.auth-brand .dot { margin-top: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.auth-title { font-size: 20px; font-weight: 700; }
.auth-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.auth-card h2 { font-size: 17px; margin: 0 0 16px; }
.auth-error {
  background: #fff5f5; border: 1px solid #fecaca; color: var(--block-ink);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px;
}
.auth-note { margin-top: 16px; font-size: 12px; color: var(--faint); text-align: center; line-height: 1.7; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.nav-link { color: var(--muted); padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.nav-link:hover { background: #f5f6f8; color: var(--ink); }
.nav-link.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.avatar-wrap { position: relative; display: flex; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--mine); color: var(--mine-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 600; cursor: pointer;
  border: none;
}
.avatar:hover { filter: brightness(.97); }
.avatar.guest { background: var(--hall); color: var(--hall-ink); }
.avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(37, 99, 235, .16); }
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30;
  min-width: 156px; padding: 6px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.user-menu[hidden] { display: none; }
.user-menu-name {
  max-width: 220px; padding: 6px 10px 9px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-sub { margin-top: 2px; font-size: 11px; color: var(--faint); font-weight: 400; }
.user-menu-item {
  display: block; width: 100%; padding: 9px 10px; border: none; border-radius: 8px;
  background: transparent; color: var(--ink); text-align: left; cursor: pointer;
}
.user-menu-item:hover { background: #f3f4f6; }
.user-menu-item[data-act="change-password"] { color: var(--mine-ink); }
.user-menu-item[data-act="change-password"]:hover { background: #f3f4f6; }
.user-menu-item[data-act="logout"] { color: var(--block-ink); }
.user-menu-item[data-act="logout"]:hover { background: #fff5f5; }

/* ---------- 工具条 ---------- */
.page { padding: 18px 20px 40px; max-width: 1280px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.tb-left { display: flex; align-items: center; gap: 6px; }
.month-label { font-size: 16px; font-weight: 700; margin: 0 6px; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; background: #eef0f3; border-radius: 10px; padding: 3px; }
.seg-item { height: 30px; padding: 0 12px; border-radius: 8px; border: none; background: transparent; color: var(--muted); cursor: pointer; }
.seg-item.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------- 日期条 ---------- */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 14px; }
.day-pill {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px;
  cursor: pointer; text-align: left; position: relative; min-height: 62px;
}
.day-pill:hover { border-color: #c7d2fe; }
.day-pill.sel { border-color: var(--accent); background: var(--accent-soft); border-width: 1.5px; }
.day-pill.out { opacity: .45; }
.dp-week { font-size: 11.5px; color: var(--muted); }
.dp-date { font-size: 17px; font-weight: 700; margin-top: 2px; }

/* ---------- 日历 ---------- */
.cal { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head { display: flex; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 6; }
.head-gutter { width: 74px; flex: none; }
.head-room { flex: 1; padding: 10px 14px; border-left: 1px solid #f1f2f4; }
.head-room b { font-size: 14px; }
.head-room span { font-size: 11px; color: var(--faint); margin-left: 8px; }
.dot-big { background: #2563eb; }
.dot-small { background: #7c3aed; }
.dot-hall { background: #0d9488; }
.head-room .dot { display: inline-block; margin-right: 7px; }

.cal-scroll { position: relative; height: 620px; overflow-y: auto; overscroll-behavior: contain; }
.cal-body { display: flex; position: relative; }
.gutter { width: 74px; flex: none; position: relative; }
.hour-label {
  position: absolute; right: 8px; font-size: 11px; color: var(--faint); transform: translateY(-50%);
  background: #fff; padding: 0 2px;
}
.cols { flex: 1; display: flex; position: relative; }
.room-col { flex: 1; position: relative; border-left: 1px solid #f1f2f4; }
.hour-line { position: absolute; left: 0; right: 0; height: 1px; background: #f3f4f6; }
.half-line { position: absolute; left: 0; right: 0; height: 1px; background: #fafbfc; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 5; }
.now-line::before {
  content: ""; position: absolute; left: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
}
.slot { position: absolute; left: 0; right: 0; cursor: pointer; }
.slot:hover { background: rgba(37, 99, 235, .05); }

.bk {
  position: absolute; left: 4px; right: 4px; border-radius: 7px; padding: 4px 8px;
  font-size: 12px; line-height: 1.35; overflow: hidden; cursor: pointer; z-index: 3;
  border: 1px solid transparent;
}
.bk .t { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk .s { font-size: 11px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk.mine { background: var(--mine); color: var(--mine-ink); border-left: 3px solid var(--accent); }
.bk.other { background: var(--other); color: var(--other-ink); }
.bk.hall { background: var(--hall); color: var(--hall-ink); }
.bk.blocked { background: var(--block); color: var(--block-ink); }
.bk.group { background: var(--group); color: var(--group-ink); border-left: 3px solid #4f46e5; }
.bk.tiny { padding: 1px 7px; font-size: 11px; }
.bk.tiny .s { display: none; }
.bk.cancelled { opacity: .45; text-decoration: line-through; }

.legend { display: flex; align-items: center; gap: 18px; padding: 12px 4px 0; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sw { width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--line); }
.legend .grow { margin-left: auto; color: var(--faint); }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head { padding: 18px 20px 10px; font-size: 16px; font-weight: 700; }
.modal-body { padding: 4px 20px 8px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-foot .spacer { margin-right: auto; }

.toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: all .2s;
  max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #b91c1c; }

/* ---------- 列表 / 我的预约 ---------- */
.section-title { font-size: 15px; font-weight: 700; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--faint); font-weight: 400; font-size: 12.5px; }
.item {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.item .when { font-weight: 600; min-width: 150px; }
.item .room { color: var(--muted); min-width: 80px; }
.item .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.item .tag.gray { background: #f3f4f6; color: var(--muted); }
.item .grow { flex: 1; }
.item.past { opacity: .55; }

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

/* ---------- 管理后台 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 14px; border: none; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.tbl th { background: #f8f9fb; color: var(--muted); font-weight: 600; font-size: 12px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: #f3f4f6; color: var(--muted); }
.badge.on { background: #dcfce7; color: #15803d; }
.badge.off { background: #fee2e2; color: #991b1b; }
.code-big { font-size: 22px; letter-spacing: 4px; font-weight: 700; font-family: ui-monospace, Menlo, monospace; }

/* ---------- 移动端 ---------- */
.mobile-room-tabs { display: none; }

@media (max-width: 760px) {
  .page { padding: 12px 12px 96px; }
  .topbar { padding: 0 12px; height: 54px; }
  .brand { font-size: 15px; }
  .nav-link { padding: 6px 8px; font-size: 13px; }
  .strip { gap: 6px; }
  .day-pill { padding: 7px 8px; min-height: 56px; border-radius: 10px; }
  .dp-date { font-size: 15px; }
  .toolbar { gap: 8px; }
  .month-label { font-size: 15px; }
  .tb-right .seg { display: none; }
  .cal-scroll { height: 68vh; }
  .cal-head .head-room { display: none; }
  .head-gutter { width: 52px; }
  .gutter { width: 52px; }
  .room-col { display: none; border-left: none; }
  .room-col.active { display: block; }
  .mobile-room-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
  .mobile-room-tabs button {
    flex: 1; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
    color: var(--muted);
  }
  .mobile-room-tabs button.on { background: var(--accent-soft); border-color: #bfdbfe; color: var(--accent); font-weight: 600; }
  .item { flex-wrap: wrap; gap: 8px; }
  .item .when { min-width: 0; }
  .modal { max-width: 100%; border-radius: 16px; }
  .fab {
    position: fixed; left: 16px; right: 16px; bottom: 20px; height: 48px; border-radius: 24px;
    background: var(--accent); color: #fff; border: none; font-weight: 600; font-size: 15px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .35); z-index: 30;
  }
  .row3 { grid-template-columns: 1fr 1fr; }
  .row3 > .field:first-child { grid-column: 1 / -1; }
}

.fab { display: none; }
@media (max-width: 760px) { .fab { display: block; } .desktop-only { display: none; } }

/* 游客页 */
.guest-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* ---------- 移动端底部导航 ---------- */
.mobile-nav { display: none; }

@media (max-width: 760px) {
  .topbar .nav-link { display: none; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav a {
    flex: 1; height: 58px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; font-size: 11px; color: var(--muted);
  }
  .mobile-nav a.on { color: var(--accent); font-weight: 600; }
  .mobile-nav .mi { font-size: 16px; line-height: 1; }
  .strip { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 4px; scrollbar-width: none; }
  .strip::-webkit-scrollbar { display: none; }
  .day-pill { flex: 0 0 64px; }
  .fab { bottom: 74px; }
  .page { padding-bottom: 132px; }
  .mobile-room-tabs button {
    height: 44px; font-size: 13px;
  }
}

/* 选日期按钮：整个按钮都能点开日历，避免只有右侧小图标响应 */
#date-jump { width: 100%; height: 100%; }
#date-jump::-webkit-calendar-picker-indicator { pointer-events: none; }
