:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e4e8ee;
  --text: #1f2733;
  --muted: #7a8494;
  --primary: #2f6bff;
  --primary-weak: #eaf0ff;
  --danger: #e5484d;
  --booked: #fdeeee;
  --booked-text: #4a5568;
  --selected: #2f6bff;
  --shadow: 0 4px 20px rgba(20, 40, 80, 0.08);
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, var(--primary), #5b8bff);
  box-shadow: 0 2px 8px rgba(47, 107, 255, 0.35);
}
.brand h1 { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }

.date-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--card); font-size: 20px; color: var(--text); cursor: pointer; line-height: 1;
}
.icon-btn:hover { background: var(--primary-weak); border-color: var(--primary); }
#dateInput {
  height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; background: var(--card);
}

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 8px 16px;
  font-size: 14px; cursor: pointer; transition: .15s; font-weight: 500;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2557e0; }
.btn-ghost { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f0f3f8; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ce3439; }

/* ---------- 布局 ---------- */
.layout {
  max-width: 1180px;
  margin: 20px auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- 时间轴 ---------- */
.timeline-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.timeline-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.timeline-head h2 { font-size: 15px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.chip { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chip-free { background: #e8f6eb; border: 1px solid #b7e2c1; }
.chip-booked { background: var(--booked); border: 1px solid #f2c7c7; }
.chip-selected { background: var(--selected); }

.timeline-wrap { position: relative; max-height: 62vh; min-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.timeline-body { display: flex; }
.time-col { padding: 0 4px; background: #fafbfc; border-right: 1px solid var(--border); position: sticky; left: 0; z-index: 2; }
.time-label {
  font-size: 12px; color: var(--muted); display: flex;
  align-items: center; justify-content: flex-end; padding-right: 8px; font-variant-numeric: tabular-nums;
}
.grid-col { flex: 1; }

/* 每行一个时段（30 分钟一格） */
.grid-row {
  position: relative; border-bottom: 1px solid #f2f5f9;
}

.slot {
  height: 100%; width: 100%; cursor: pointer; transition: background .1s; position: relative;
}
.slot-free:hover { background: var(--primary-weak); }
.slot-booked {
  cursor: pointer;
  background: var(--booked);       /* 淡红标记已预约时段 */
  outline: 1px solid #f2c7c7;
}
.slot-booked:hover { background: #fbe4e4; }
.block-booked .slot { cursor: default; }

.slot-selected {
  background: var(--selected) !important;
  outline: 2px solid var(--selected);
}

.selected-info { padding: 10px 16px; background: var(--primary-weak); border-radius: 9px; margin-top: 10px; }

/* ---------- 侧栏 ---------- */
.side-col { display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin-bottom: 12px; }
.booking-list { list-style: none; max-height: 300px; overflow: auto; }
.booking-list li { padding: 11px 0; border-bottom: 1px solid #f0f2f6; }
.booking-list li:last-child { border-bottom: none; }
.empty { color: var(--muted); text-align: center; font-size: 13px; border-bottom: none !important; }
.booking-item { cursor: pointer; transition: background .1s; border-radius: 8px; padding: 8px 10px !important; }
.booking-item:hover { background: #f6f8fc; }
.booking-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pt-name { font-size: 14px; font-weight: 600; color: var(--text); }
.booking-time { font-size: 13px; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.booking-time em { font-style: normal; color: var(--primary); font-weight: 700; font-size: 14px; }
.booking-day { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.booking-title { font-size: 13px; margin-top: 2px; }
.booking-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 预约人清单搜索 */
.person-search { display: flex; gap: 8px; margin-bottom: 10px; }
.person-search input { flex: 1; min-width: 0; margin-top: 0; height: 38px; }
.person-search .btn { white-space: nowrap; height: 38px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 25, 40, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: 16px; padding: 24px;
  width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-sm { max-width: 380px; }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal-range { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--text); margin-bottom: 12px; }
label b { color: var(--danger); }
input, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: var(--card); color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--primary-weak); border-color: var(--primary); }
textarea { resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.detail-list { margin: 8px 0 4px; }
.detail-list div { display: flex; padding: 7px 0; border-bottom: 1px solid #f0f2f6; font-size: 13px; }
.detail-list dt { width: 84px; color: var(--muted); flex-shrink: 0; }
.detail-list dd { flex: 1; word-break: break-all; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- 提示 ---------- */
.timeline-tip { color: var(--muted); font-size: 12px; margin-top: 10px; }
.selection-bar {
  margin-top: 8px; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--primary-weak); border-radius: 9px; font-size: 14px;
}
.selection-bar strong { color: var(--primary); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); z-index: 100; max-width: 90vw;
}
.toast[hidden] { display: none; }
.toast.err { background: var(--danger); }
.toast.ok { background: #1fa55d; }

/* ---------- 手机端适配 ---------- */
@media (max-width: 640px) {
  .topbar-inner { padding: 10px 12px; }
  .brand h1 { font-size: 16px; }
  .brand-sub { font-size: 11px; }
  .layout { margin-top: 12px; padding: 0 12px; gap: 14px; }
  .timeline-card { padding: 12px; }
  .date-nav { width: 100%; justify-content: flex-start; }

  /* 触控友好的按钮与格 */
  .btn { min-height: 38px; padding: 8px 14px; }
  .icon-btn { width: 40px; height: 40px; }
  #dateInput { height: 40px; flex: 1; min-width: 0; }

  .timeline-head { flex-direction: column; align-items: flex-start; gap: 6px; }

  .time-label { font-size: 11px; padding-right: 5px; }

  .booking-item { padding: 10px 8px !important; }
  .person-search .btn { min-height: 42px; }

  .selection-bar { flex-wrap: wrap; }
  .selection-bar .btn { flex: 1; text-align: center; }

  .modal { padding: 18px; }
  .modal .btn { min-height: 42px; }
}