/* ============ 设计变量 ============ */
:root {
  --brand: #1677ff;
  --brand-soft: #e8f1ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a1f29;
  --text-2: #5b6675;
  --text-3: #98a2b3;
  --line: #e8ecf2;
  --ok: #12b76a;
  --ok-soft: #e6f7ef;
  --warn: #ff8f1f;
  --warn-soft: #fff3e3;
  --danger: #f04438;
  --danger-soft: #feeceb;
  --purple: #7c5cff;
  --purple-soft: #f0edff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 16px -8px rgba(16, 24, 40, .12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

.hidden { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ============ 骨架 ============ */
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(80px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  background: rgba(244, 246, 250, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-main { flex: 1; min-width: 0; }

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  color: var(--text-2);
  flex: 0 0 auto;
}
.icon-btn.is-on { color: var(--brand); border-color: #bfd8ff; background: var(--brand-soft); }

.view { padding: 14px 16px 8px; }

/* ============ 周导航 ============ */
.weekbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.weekbar .range {
  flex: 1; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--text);
}
.weekbar button {
  height: 32px; min-width: 32px; padding: 0 10px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2);
  font-size: 13px;
}
.weekbar button.is-primary { color: var(--brand); border-color: #bfd8ff; background: var(--brand-soft); font-weight: 600; }

/* ============ 日分组 ============ */
.day-block { margin-bottom: 18px; }

.day-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 0 2px 8px;
}
.day-head .d {
  font-size: 14px; font-weight: 650; color: var(--text);
}
.day-head .w { font-size: 12px; color: var(--text-3); }
.day-head .tag {
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--brand); color: #fff; font-weight: 600;
}
.day-head .cnt { margin-left: auto; font-size: 12px; color: var(--text-3); }

/* ============ 行程卡片 ============ */
.slot {
  display: flex; gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--text-3);
  position: relative;
}
.slot.k-travel { border-left-color: var(--purple); }
.slot.k-training { border-left-color: var(--brand); }
.slot.k-onsite { border-left-color: var(--warn); }
.slot.k-call { border-left-color: var(--ok); }
.slot.k-meeting { border-left-color: #5b6b7f; }
.slot.k-available { border-left-color: var(--ok); background: linear-gradient(0deg, #fff, #fff); border: 1px dashed #a6e3c4; border-left: 3px solid var(--ok); }
.slot.k-busy { border-left-color: var(--text-3); }

.slot .time {
  flex: 0 0 48px;
  font-variant-numeric: tabular-nums;
  font-size: 13px; font-weight: 600; color: var(--text);
  line-height: 1.35;
}
.slot .time .sep {
  display: block;
  width: 14px;
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.slot .body { flex: 1; min-width: 0; }
.slot .title { font-size: 14.5px; font-weight: 600; margin-bottom: 3px; word-break: break-word; }
.slot .meta {
  font-size: 12.5px; color: var(--text-2);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.slot .meta .dot { color: var(--text-3); }
.slot .note { margin-top: 5px; font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 2px 8px; border-radius: 6px;
  background: var(--bg); color: var(--text-2); font-weight: 500;
}
.chip.ok { background: var(--ok-soft); color: #087443; }
.chip.warn { background: var(--warn-soft); color: #b25a00; }
.chip.brand { background: var(--brand-soft); color: #0b57c4; }
.chip.danger { background: var(--danger-soft); color: #b42318; }
.chip.purple { background: var(--purple-soft); color: #5438c9; }

.slot .acts { display: flex; gap: 6px; margin-left: 4px; align-items: flex-start; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 8px; padding: 4px 9px; font-size: 12px;
}
.mini-btn.danger { color: var(--danger); border-color: #f8c9c5; }

/* 预约叠加显示在行程卡片内 */
.booked-line {
  margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line);
  font-size: 12.5px; color: var(--text-2);
}
.booked-line .who { color: var(--text); font-weight: 600; }

/* ============ 空状态 ============ */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-3);
  font-size: 13.5px;
}
.empty .big { font-size: 32px; margin-bottom: 10px; opacity: .35; }

/* ============ 预约页 ============ */
.daystrip {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}
.daystrip::-webkit-scrollbar { display: none; }
.dchip {
  flex: 0 0 auto;
  min-width: 56px; padding: 8px 6px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2);
  text-align: center; line-height: 1.25;
}
.dchip .dw { font-size: 11px; color: var(--text-3); }
.dchip .dd { font-size: 15px; font-weight: 650; color: var(--text); }
.dchip.is-active { background: var(--brand); border-color: var(--brand); }
.dchip.is-active .dw, .dchip.is-active .dd { color: #fff; }
.dchip .n { font-size: 10px; color: var(--ok); font-weight: 600; }
.dchip.is-active .n { color: #d9e8ff; }

.section-title {
  font-size: 13px; font-weight: 650; color: var(--text-2);
  margin: 4px 2px 8px; display: flex; align-items: center; gap: 6px;
}
.section-title .hint { font-weight: 400; color: var(--text-3); font-size: 12px; }

.slotpick {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px;
}
.slotpick button {
  border: 1px solid #bfd8ff; background: var(--brand-soft); color: #0b57c4;
  border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.slotpick button.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

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

.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px;
}
.field .req { color: var(--danger); }
.field input[type=text], .field input[type=tel], .field input[type=time],
.field input[type=date], .field select, .field textarea {
  width: 100%; padding: 10px 11px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfd; color: var(--text);
  outline: none; transition: border-color .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); background: #fff;
}
.field textarea { resize: vertical; min-height: 68px; }
.field .row2 { display: flex; gap: 10px; }
.field .row2 > * { flex: 1; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 9px 4px; border-radius: 10px;
  border: 1px solid var(--line); background: #fbfcfd; color: var(--text-2);
  font-size: 13px;
}
.seg button.is-active { border-color: var(--brand); background: var(--brand-soft); color: #0b57c4; font-weight: 600; }

/* ============ 沟通方式选择（三色区分） ============ */
.channel-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.ch-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 10px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card);
  text-align: left; transition: border-color .15s, background .15s;
}
.ch-card .ch-name { font-size: 14px; font-weight: 650; color: var(--text); }
.ch-card .ch-desc { font-size: 11.5px; color: var(--text-3); }

.ch-card.ch-phone.is-active { border-color: var(--ok); background: var(--ok-soft); }
.ch-card.ch-phone.is-active .ch-name { color: #087443; }
.ch-card.ch-dingtalk.is-active { border-color: var(--brand); background: var(--brand-soft); }
.ch-card.ch-dingtalk.is-active .ch-name { color: #0b57c4; }
.ch-card.ch-onsite.is-active { border-color: var(--warn); background: var(--warn-soft); }
.ch-card.ch-onsite.is-active .ch-name { color: #b25a00; }

/* 渠道色标（列表里复用同一套颜色） */
.chip.ch-tag-phone { background: var(--ok-soft); color: #087443; }
.chip.ch-tag-dingtalk { background: var(--brand-soft); color: #0b57c4; }
.chip.ch-tag-onsite { background: var(--warn-soft); color: #b25a00; }

/* ============ 现场支持：上午 / 下午 ============ */
.halfday-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.half-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 12px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fbfcfd;
  text-align: left; transition: border-color .15s, background .15s;
}
.half-card .hd-label { font-size: 16px; font-weight: 650; color: var(--text); }
.half-card .hd-time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.half-card .hd-state { font-size: 12px; color: var(--ok); font-weight: 600; }
.half-card.is-soft .hd-state { color: var(--warn); }
.half-card.is-blocked { opacity: .5; }
.half-card.is-blocked .hd-state { color: var(--text-3); }
.half-card.is-active { border-color: var(--brand); background: var(--brand-soft); }
.half-card:disabled { cursor: not-allowed; }

/* 软冲突 / 风险提示 */
.warning-box {
  background: var(--warn-soft); color: #8a4500;
  border-left: 3px solid var(--warn);
  border-radius: 10px; padding: 11px 13px;
  font-size: 13px; line-height: 1.65;
}

.btn-primary {
  width: 100%; padding: 13px; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font-weight: 650; font-size: 15px;
  box-shadow: 0 6px 16px -8px rgba(22, 119, 255, .8);
}
.btn-primary:disabled { background: #b6c6dd; box-shadow: none; }
.btn-ghost {
  width: 100%; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  font-weight: 600; margin-top: 8px;
}

/* ============ 记录页 ============ */
.seg-tabs {
  display: flex; gap: 4px; background: #eceff4; border-radius: 11px; padding: 3px;
  margin-bottom: 14px;
}
.seg-tabs button {
  flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 9px;
  font-size: 13.5px; color: var(--text-2); font-weight: 600;
}
.seg-tabs button.is-active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16,24,40,.08); }

.booking {
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 9px; box-shadow: var(--shadow);
  border-left: 3px solid var(--warn);
}
.booking.s-confirmed { border-left-color: var(--ok); }
.booking.s-rejected { border-left-color: var(--text-3); opacity: .65; }
.booking .bhead { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.booking .bname { font-weight: 650; font-size: 14.5px; }
.booking .btime {
  font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text);
  font-weight: 600;
}
.booking .btopic { font-size: 13px; color: var(--text-2); margin-top: 3px; word-break: break-word; }
.booking .bfoot { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

/* ============ 底部 tab ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: flex; gap: 4px;
  padding: 6px 10px calc(6px + var(--safe-bottom));
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar .tab {
  flex: 1; border: 0; background: transparent;
  padding: 7px 0 5px; border-radius: 10px;
  font-size: 12.5px; color: var(--text-3); font-weight: 600;
}
.tabbar .tab.is-active { color: var(--brand); background: var(--brand-soft); }

.fab {
  position: fixed; z-index: 25;
  right: max(16px, calc(50vw - 280px + 16px));
  bottom: calc(74px + var(--safe-bottom));
  width: 50px; height: 50px; border-radius: 50%;
  border: 0; background: var(--brand); color: #fff;
  font-size: 25px; line-height: 1;
  box-shadow: 0 8px 22px -6px rgba(22, 119, 255, .6);
  display: grid; place-items: center;
}

/* ============ 弹层 ============ */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16, 24, 40, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease;
}
.sheet.hidden { display: none; }
.sheet-panel {
  width: 100%; max-width: 560px;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  max-height: 90vh; overflow-y: auto;
  animation: rise .2s cubic-bezier(.2,.8,.3,1);
}
.sheet-title {
  font-size: 16px; font-weight: 650; margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
}
.sheet-title .close {
  margin-left: auto; border: 0; background: var(--bg);
  width: 28px; height: 28px; border-radius: 50%; color: var(--text-2); font-size: 16px;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }

/* 预约成功卡片 */
.success-hero { text-align: center; padding: 8px 0 16px; }
.success-hero .ico {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 12px;
  background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center; font-size: 26px;
}
.success-hero h3 { margin: 0 0 4px; font-size: 17px; }
.success-hero p { margin: 0; color: var(--text-2); font-size: 13px; }
.code-box {
  background: var(--bg); border-radius: 12px; padding: 14px;
  text-align: center; margin: 12px 0;
}
.code-box .lbl { font-size: 12px; color: var(--text-3); }
.code-box .code {
  font-size: 30px; font-weight: 700; letter-spacing: 6px;
  font-variant-numeric: tabular-nums; color: var(--brand); margin: 2px 0 4px;
}
.code-box .tip { font-size: 12px; color: var(--text-2); line-height: 1.6; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 10px);
  z-index: 80; max-width: 82vw;
  background: rgba(26, 31, 41, .92); color: #fff;
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.skeleton {
  height: 62px; border-radius: var(--radius);
  background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  margin-bottom: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.divider { height: 1px; background: var(--line); margin: 14px 0; }

.helper { font-size: 12px; color: var(--text-3); line-height: 1.6; margin-top: 6px; }
