:root {
  --ink: #1b2a3a;
  --ink-2: #5b6b7c;
  --line: #e2e8f0;
  --brand: #0f6fbf;
  --brand-d: #0b5795;
  --free: #f2f7fc;
  --busy: #d9534f;
  --busy-bg: #fdeceb;
  --closed: #b9c2cc;
  --closed-bg: #f1f3f5;
  --ok: #1a9c6b;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  overflow-x: hidden;
  padding: 0;
  background: #f6f8fa;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--brand), #0a4f88);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(10, 60, 110, .18);
}

.topbar .title { font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.topbar .title small { display: block; font-weight: 400; opacity: .85; font-size: 12px; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }

.linkbtn {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
}
.linkbtn:active { background: rgba(255, 255, 255, .3); }

.notice {
  background: #fff8e6;
  border-bottom: 1px solid #f2e2b8;
  color: #7a5a12;
  padding: 8px 14px;
  font-size: 13px;
}

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 53px;
  z-index: 15;
}

.datebar { display: flex; align-items: center; gap: 4px; }

.datebar button {
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  line-height: 1.1;
}
.datebar button:active { background: #e3ebf3; }

.datebar input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}

.datebar .curdate { font-weight: 600; font-size: 14px; margin: 0 4px; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
}
.seg button {
  border: 0;
  background: #fff;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.seg button.on { background: var(--brand); color: #fff; }

.legend { display: flex; gap: 14px; padding: 8px 14px 0; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .l-free i { background: var(--free); border: 1px solid #cfe0ef; }
.legend .l-busy i { background: var(--busy); }
.legend .l-closed i { background: var(--closed); }

/* ---------- 表格 ---------- */
.wrap { padding: 8px 8px 90px; }

.gridwrap { overflow: auto; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16, 42, 67, .08); background: #fff; -webkit-overflow-scrolling: touch; max-height: calc(100vh - 210px); }

.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; table-layout: fixed; }

.grid th, .grid td { border-bottom: 1px solid #eef2f6; border-right: 1px solid #eef2f6; }

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f7fafc;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  padding: 7px 2px;
  text-align: center;
  line-height: 1.2;
  box-shadow: inset 0 -1px 0 #e6edf4;
}
.grid thead th .sub { display: block; font-weight: 400; color: var(--ink-2); font-size: 11px; }
.grid thead th.weekend { color: #c0392b; }

.grid th.tcol {
  width: 44px;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
  background: #fbfcfd;
  text-align: right;
  padding: 0 6px;
}

.grid td.slot { padding: 0; height: 44px; position: relative; vertical-align: top; }
.grid.compact td.slot, .grid.compact .cell { height: 34px; }

.cell {
  height: 44px;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  cursor: pointer;
  color: #b7c7d6;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}
.cell.free { background: var(--free); }
.cell.free:hover { background: #e6f1fb; }
.cell.free::after { content: "＋"; position: absolute; right: 5px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: 0; color: #a8c4dc; }
.cell.free:hover::after { opacity: 1; }

.cell.busy {
  background: var(--busy-bg);
  border-left: 3px solid var(--busy);
  color: #8c2b28;
  cursor: default;
}
.cell.busy b { font-size: 11.5px; font-weight: 600; display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cell.busy span { font-size: 10.5px; color: #a7504d; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.busy.tiny { padding: 1px 4px; }

.cell.closed { background: var(--closed-bg); color: #8d97a3; cursor: default; font-size: 11px; }

.grid tbody tr:hover th.tcol { background: #f1f6fb; }

.empty { text-align: center; color: var(--ink-2); padding: 40px 10px; font-size: 14px; }

/* ---------- 浮动按钮 ---------- */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f6fbf, #0a4f88);
  color: #fff;
  padding: 13px 22px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(11, 87, 149, .35);
}
.fab:active { transform: translateY(1px); }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 33, 46, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.mask.center { align-items: center; padding: 16px; }
.mask[hidden] { display: none; }

.sheet {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: rise .18s ease-out;
}
.mask.center .sheet { border-radius: 14px; }
@keyframes rise { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet h2 { margin: 0 0 4px; font-size: 17px; }
.sheet .hint { color: var(--ink-2); font-size: 12.5px; margin: 0 0 12px; }

.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; }
.field input[type="text"], .field input[type="date"], .field select, .field input[type="time"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 111, 191, .12); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }

.chips { display: flex; gap: 8px; margin: 2px 0 12px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}
.chips button.on { background: #e8f2fb; border-color: var(--brand); color: var(--brand-d); font-weight: 600; }

.msg { font-size: 13px; border-radius: 8px; padding: 9px 11px; margin-bottom: 10px; display: none; }
.msg.show { display: block; }
.msg.err { background: #fdeceb; color: #a3312d; }
.msg.ok { background: #e8f7f0; color: #12744f; }
.msg.info { background: #eef4fa; color: #235f92; }

.btnrow { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 15px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:disabled { background: #a9c4dc; }
.btn.ghost { background: #f1f5f9; color: var(--ink); }

/* 我的预约列表 */
.mine { list-style: none; margin: 0; padding: 0; }
.mine li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.mine li .t { font-weight: 600; margin-bottom: 3px; }
.mine li .d { color: var(--ink-2); font-size: 12.5px; }
.mine li.done { opacity: .55; }
.mine li .ops { margin-top: 8px; display: flex; gap: 8px; }
.mine li .ops button {
  border: 1px solid #f0c6c3;
  background: #fff5f4;
  color: #a3312d;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12.5px;
}

.tag { display: inline-block; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-left: 6px; }
.tag.on { background: #e8f7f0; color: #12744f; }
.tag.off { background: #f1f3f5; color: #7b8794; }

.foot { text-align: center; color: #9aa8b6; font-size: 12px; padding: 0 10px 60px; }
.foot a { color: #9aa8b6; }

@media (min-width: 720px) {
  .wrap { max-width: 1020px; margin: 0 auto; padding: 14px 14px 90px; }
  .grid td.slot, .cell { height: 42px; }
  .gridwrap { max-height: calc(100vh - 230px); }
  .cell.busy b { font-size: 12px; }
  .cell.busy span { font-size: 11px; }
}
