/* ================= 基础 ================= */
:root {
  --blue: #1a56db;
  --blue-dark: #1e3a8a;
  --blue-light: #eff4ff;
  --green: #0f9d58;
  --green-light: #e8f6ee;
  --orange: #e8710a;
  --orange-light: #fdf1e3;
  --red: #d93025;
  --red-light: #fdecea;
  --gray-50: #f7f8fa;
  --gray-100: #f0f1f4;
  --gray-200: #e4e6eb;
  --gray-300: #cfd3da;
  --gray-500: #8b909a;
  --gray-700: #4a5058;
  --gray-900: #1c1f24;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --topbar-h: 56px;
  --tabbar-h: 58px;
  --statbar-h: 52px;
}

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; }

/* ================= 登录页 ================= */
.login-wrap {
  min-height: 100%;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px 56px;
  background: linear-gradient(160deg, #1a56db 0%, #1e3a8a 55%, #16233f 100%);
}
.login-card {
  width: 100%; max-width: 400px;
  background: #fff;
  border-radius: 20px;
  padding: 36px 28px 28px;
  box-shadow: var(--shadow-lg);
}
.brand { text-align: center; margin-bottom: 28px; }
.brand-logo {
  display: block;
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.brand h1 { font-size: 21px; letter-spacing: .5px; }
.brand-sub { color: var(--gray-500); font-size: 13px; margin: 6px 0 0; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; color: var(--gray-700); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  outline: none;
  transition: border-color .15s, background .15s;
  color: var(--gray-900);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue); background: #fff;
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
.field .hint { font-size: 12px; color: var(--gray-500); margin-top: 5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:active { opacity: .75; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); }
.btn-outline { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px; font-size: 16px; font-weight: 600; letter-spacing: 2px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.error-tip {
  background: var(--red-light); color: var(--red);
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
}
.login-hint {
  margin-top: 24px; padding-top: 18px;
  border-top: 1px dashed var(--gray-200);
  font-size: 12.5px; color: var(--gray-500); line-height: 1.9;
}
.login-hint p { margin: 0; }
.login-hint strong { color: var(--gray-700); }
.login-slogan {
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: var(--gray-600);
}
.tl-del {
  margin-left: auto;
  border: none; background: none;
  font-size: 12px; color: var(--red, #d64545);
  cursor: pointer; padding: 2px 4px;
}
.tl-del:active { opacity: .6; }

/* ================= 布局 ================= */
.app { min-height: 100%; padding-bottom: calc(var(--tabbar-h) + 16px); }

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-700); font-size: 19px;
}
.icon-btn:active { background: var(--gray-100); }
.avatar-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: 17px;
  background: var(--blue-light); color: var(--blue);
  font-size: 13px; font-weight: 600;
}

/* 数据总览条 */
.stat-bar {
  position: sticky; top: var(--topbar-h); z-index: 49;
  height: var(--statbar-h);
  background: var(--blue);
  display: flex; align-items: center;
}
.stat-item { flex: 1; text-align: center; color: #fff; position: relative; }
.stat-item + .stat-item::before {
  content: ''; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 1px; background: rgba(255,255,255,.22);
}
.stat-num { font-size: 18px; font-weight: 700; line-height: 1.15; display: block; }
.stat-num small { font-size: 12px; font-weight: 400; opacity: .75; }
.stat-label { font-size: 11.5px; opacity: .82; }

main { padding: 12px; }

/* ================= 卡片 / 客户项 ================= */
.searchbar {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.searchbar input {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--gray-200); border-radius: 22px;
  background: #fff; outline: none;
}
.searchbar input:focus { border-color: var(--blue); }

.filter-chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 10px; margin-bottom: 4px;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 15px; border-radius: 18px;
  background: #fff; border: 1.5px solid var(--gray-200);
  font-size: 13px; color: var(--gray-700); white-space: nowrap;
}
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 500; }

/* 列表分页 */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 0 26px;
}
.pager-btn {
  padding: 8px 16px; border-radius: 18px;
  background: #fff; border: 1.5px solid var(--gray-200);
  font-size: 13px; color: var(--gray-700); cursor: pointer;
}
.pager-btn:not(:disabled):active { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.pager-btn:disabled { opacity: .45; cursor: default; }
.pager-info { font-size: 12.5px; color: var(--gray-500); white-space: nowrap; }

/* 客户总览（管理中心） */
.ov-summary { display: flex; gap: 8px; margin-bottom: 12px; }
.ov-item {
  flex: 1; text-align: center; padding: 10px 4px;
  background: var(--gray-100); border-radius: 10px;
}
.ov-num { display: block; font-size: 19px; font-weight: 600; line-height: 1.25; }
.ov-label { display: block; font-size: 11.5px; color: var(--gray-500); margin-top: 2px; }

.ov-groups { margin-top: 4px; }
.ov-group { border: 1px solid var(--gray-200); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.ov-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px; background: #fff; cursor: pointer;
}
.ov-head:active { background: var(--gray-100); }
.ov-head-main { flex: 1; min-width: 0; }
.ov-name { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.ov-head-sub { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
.ov-arrow { color: var(--gray-500); font-size: 13px; }

.ov-body { padding: 4px 12px 10px; background: var(--gray-100); }
.ov-sec-title { font-size: 12px; color: var(--gray-500); padding: 8px 0 5px; }
.ov-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; background: #fff; border-radius: 8px; margin-bottom: 6px;
  cursor: pointer;
}
.ov-row:active { background: var(--blue-light); }
.ov-row-main { flex: 1; min-width: 0; }
.ov-row-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.ov-row-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; line-height: 1.5; }
.ov-row-kind { font-size: 11.5px; color: var(--gray-500); flex-shrink: 0; }

.customer-card {
  background: #fff; border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s;
}
.customer-card:active { transform: scale(.985); }

.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cc-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.cc-phone { font-size: 13px; color: var(--gray-500); font-variant-numeric: tabular-nums; }

.cc-info { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--gray-700); }
.cc-info span { display: inline-flex; align-items: center; gap: 3px; }

.cc-foot {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--gray-500);
  gap: 8px; flex-wrap: wrap;
}

/* 徽标 */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge-pool { background: var(--green-light); color: var(--green); }
.badge-claimed { background: var(--blue-light); color: var(--blue); }
.badge-mine { background: var(--orange-light); color: var(--orange); }
.badge-warn { background: var(--red-light); color: var(--red); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* 客户类别标识：买=蓝，租=橙（房产中介行业习惯配色） */
.badge-trade { background: #e8f0fe; color: #1a56db; font-weight: 600; }
.badge-rent { background: #fff3e0; color: #c2610a; font-weight: 600; }
.badge-outline { background: #fff; border: 1px solid var(--gray-200); color: var(--gray-700); }

/* 无效客户标识 */
.badge-invalid { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }
.badge-red { background: var(--red); color: #fff; }

/* 无效客户卡片：整体降饱和，视觉上"归档" */
.card-invalid { opacity: .78; background: #fafafa; }
.card-invalid .cc-name { color: var(--gray-700); }

/* 无效原因选择器：四个选项一行两项 */
.type-picker-4 { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ================= 站内通知 ================= */
.notify-list { max-height: 58vh; overflow-y: auto; margin: 4px 0 12px; }
.notify-item {
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--gray-50); margin-bottom: 8px;
  cursor: pointer; border-left: 3px solid transparent;
}
.notify-item.unread { background: var(--blue-light); border-left-color: var(--blue); }
.notify-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.notify-title { font-size: 13.5px; font-weight: 600; color: var(--gray-900); }
.notify-unread-dot {
  width: 6px; height: 6px; border-radius: 3px;
  background: var(--blue); display: inline-block;
}
.notify-content { font-size: 13px; color: var(--gray-700); line-height: 1.6; }
.notify-foot { font-size: 11.5px; color: var(--gray-500); margin-top: 6px; }

/* 通知红点（顶部铃铛 + 底部标签） */
#notifyBtn { position: relative; }
.notify-dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 8px; height: 8px; border-radius: 4px;
  background: var(--red); display: block;
}
.tab { position: relative; }
.tab-dot {
  position: absolute; top: 6px; right: calc(50% - 18px);
  width: 7px; height: 7px; border-radius: 4px; background: var(--red);
}

/* ================= 详情 ================= */
.detail-section {
  background: #fff; border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.detail-section h3 {
  font-size: 14px; color: var(--gray-700);
  margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;
}
.detail-row { display: flex; padding: 7px 0; font-size: 14px; }
.detail-row .k { width: 78px; color: var(--gray-500); flex-shrink: 0; font-size: 13.5px; }
.detail-row .v { flex: 1; color: var(--gray-900); word-break: break-word; }
.phone-reveal {
  display: inline-flex; align-items: center; gap: 8px;
}
.phone-reveal .masked { font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.btn-reveal { font-size: 12px; color: var(--blue); text-decoration: underline; }
.btn-copy { font-size: 12px; color: var(--gray-500); }

.notice {
  border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 13px; line-height: 1.6; margin-bottom: 12px;
}
.notice-info { background: var(--blue-light); color: var(--blue-dark); }
.notice-warn { background: var(--orange-light); color: #8a4b06; }
.notice-danger { background: var(--red-light); color: #a02219; }
.notice-green { background: var(--green-light); color: #0a6b3c; }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--gray-200);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: -21px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue); border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px var(--gray-200);
}
.tl-item.type-客需::before { background: var(--blue); }
.tl-item.type-约看::before { background: var(--orange); }
.tl-item.type-带看::before { background: var(--green); }
.tl-item.type-带看回访::before { background: #7b5fd6; }

.tl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.tl-user { font-size: 13.5px; font-weight: 600; }
.tl-time { font-size: 12px; color: var(--gray-500); margin-left: auto; }
.tl-content { font-size: 13.5px; color: var(--gray-700); line-height: 1.6; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--gray-500);
}
.empty-ico { font-size: 40px; opacity: .3; margin-bottom: 12px; }
.empty p { margin: 6px 0; font-size: 14px; }

/* ================= 底部导航 ================= */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: var(--tabbar-h);
  background: #fff;
  border-top: 1px solid var(--gray-200);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--gray-500);
  transition: color .15s;
}
.tab-ico { font-size: 18px; line-height: 1; }
.tab.active { color: var(--blue); font-weight: 500; }

.fab {
  position: fixed; right: 18px;
  bottom: calc(var(--tabbar-h) + 18px); z-index: 61;
  width: 54px; height: 54px; border-radius: 27px;
  background: var(--blue); color: #fff;
  font-size: 30px; font-weight: 300; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(26,86,219,.4);
}
.fab:active { transform: scale(.94); }

/* ================= 弹层 ================= */
.sheet-mask, .modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,24,32,.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
.modal-mask { align-items: center; padding: 20px; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  width: 100%; max-width: 560px;
  max-height: 88vh;
  background: #fff;
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  animation: slideUp .22s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}
.sheet-full { max-height: 92vh; }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6 } to { transform: translateY(0); opacity: 1 } }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.sheet-title { font-size: 16px; font-weight: 600; }
.sheet-close {
  width: 30px; height: 30px; border-radius: 50%;
  color: var(--gray-500); font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.sheet-close:active { background: var(--gray-100); }
.sheet-body { padding: 16px 18px 24px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.modal {
  width: 100%; max-width: 340px;
  background: #fff; border-radius: 16px;
  padding: 22px 20px 18px;
  animation: popIn .2s cubic-bezier(.22,1,.36,1);
}
@keyframes popIn { from { transform: scale(.94); opacity: .5 } to { transform: scale(1); opacity: 1 } }
.modal h3 { font-size: 16px; margin-bottom: 10px; }
.modal p { margin: 0 0 14px; font-size: 13.5px; color: var(--gray-700); line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* 跟进类型选择 */
.type-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.type-opt {
  flex: 1; min-width: 72px;
  padding: 10px 6px; text-align: center;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  background: var(--gray-50); font-size: 13.5px; color: var(--gray-700);
}
.type-opt.active {
  border-color: var(--blue); background: var(--blue-light);
  color: var(--blue); font-weight: 600;
}

/* ================= 提示 ================= */
.toast-wrap {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  background: rgba(28,31,36,.92); color: #fff;
  padding: 10px 18px; border-radius: 20px;
  font-size: 13.5px; max-width: 80vw; text-align: center;
  animation: toastIn .2s ease;
  box-shadow: var(--shadow-lg);
}
.toast.success { background: rgba(15,157,88,.94); }
.toast.error { background: rgba(217,48,37,.94); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: translateY(0) } }

/* ================= 管理页 ================= */
.admin-block {
  background: #fff; border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.admin-block h3 { font-size: 14px; margin-bottom: 12px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--gray-100); gap: 10px;
}
.user-row:last-child { border-bottom: none; }
.user-main { flex: 1; min-width: 0; }
.user-name { font-size: 14.5px; font-weight: 500; }
.user-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.log-row { padding: 9px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.log-row:last-child { border-bottom: none; }
.log-time { color: var(--gray-500); font-size: 11.5px; }
.log-detail { color: var(--gray-700); margin-top: 2px; }

/* 加载 */
.loading { text-align: center; padding: 40px; color: var(--gray-500); font-size: 14px; }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 12px;
  border: 2.5px solid var(--gray-200); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* 桌面端适配 */
@media (min-width: 700px) {
  .app { max-width: 860px; margin: 0 auto; }
  .topbar { border-radius: 0; }
  .tabbar { max-width: 860px; left: 50%; transform: translateX(-50%); border-radius: 12px 12px 0 0; }
  main { padding: 16px; }
}

/* 备案号：固定在登录页底部居中 */
.login-icp {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  text-align: center;
  margin: 0;
}
.login-icp a { color: rgba(255,255,255,0.55); font-size: 12px; text-decoration: none; }
.login-icp a:hover { color: rgba(255,255,255,0.85); }
