:root {
  --teal: #1a4040;
  --teal-light: #2a5959;
  --teal-dark: #112e2e;
  --gold: #c9a227;
  --gold-light: #e0be4d;
  --bg: #f4f6f6;
  --card: #ffffff;
  --text: #1d2b2b;
  --muted: #6b7f7f;
  --line: #e2e8e8;
  --danger: #c0392b;
  --success: #27865a;
  --info: #2d6da3;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 64px;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* 顶部栏 */
.topbar {
  background: var(--teal);
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar h1 { font-size: 1.05rem; font-weight: 600; letter-spacing: .5px; }
.topbar h1 .logo-gold { color: var(--gold-light); }
.topbar .back { color: #fff; text-decoration: none; font-size: .9rem; opacity: .85; }
.topbar .back:active { opacity: .6; }

/* 容器 */
.page { max-width: 640px; margin: 0 auto; padding: 14px; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(26,64,64,.06);
}
.card h2 { font-size: .95rem; color: var(--teal); margin-bottom: 12px; font-weight: 600; }

/* 统计块 */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-box {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(26,64,64,.06);
}
.stat-box .num { font-size: 1.5rem; font-weight: 700; color: var(--teal); }
.stat-box .num.gold { color: var(--gold); }
.stat-box .num.green { color: var(--success); }
.stat-box .lbl { font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* 阶段分布条 */
.stage-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 10px 0; }
.stage-bar i { display: block; height: 100%; }
.stage-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .75rem; color: var(--muted); }
.stage-legend span { display: inline-flex; align-items: center; gap: 4px; }
.stage-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* 徽章 */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-new { background: #e8eef2; color: #4a6274; }
.badge-contacted { background: #e3f0fb; color: var(--info); }
.badge-replied { background: #fff3d6; color: #9a7b10; }
.badge-sample { background: #f3e5f7; color: #8e44ad; }
.badge-quoted { background: #ffe8d6; color: #c0671a; }
.badge-won { background: #dcf3e7; color: var(--success); }
.badge-lost { background: #f2dcd9; color: var(--danger); }
.badge-src { background: var(--teal); color: #fff; font-weight: 500; opacity: .85; }

/* 客户列表 */
.cust-item {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.cust-item:active { background: #f0f4f4; }
.cust-item .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cust-item .name { font-weight: 600; font-size: .98rem; }
.cust-item .company { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.cust-item .meta { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.cust-item .follow-warn { font-size: .72rem; color: var(--danger); font-weight: 600; }
.cust-item .follow-ok { font-size: .72rem; color: var(--gold); }

/* 筛选条 */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px;
  background: var(--card);
  position: sticky;
  top: 51px;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: .8rem;
  color: var(--muted);
  cursor: pointer;
}
.chip.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* 搜索框 */
.search-box { margin: 12px 14px 0; }
.search-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .9rem;
  background: #fff;
  outline: none;
}
.search-box input:focus { border-color: var(--teal); }

/* 表单 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .92rem;
  background: #fff;
  outline: none;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--teal); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 按钮 */
.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:active { background: var(--teal-dark); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-outline { background: #fff; color: var(--teal); border: 1px solid var(--teal); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm { width: auto; padding: 7px 16px; font-size: .82rem; display: inline-block; }

/* 底部导航 */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 60;
  box-shadow: 0 -2px 10px rgba(0,0,0,.05);
}
.tabbar a {
  flex: 1;
  text-align: center;
  padding: 8px 0 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: .68rem;
}
.tabbar a .ico { font-size: 1.25rem; display: block; line-height: 1.4; }
.tabbar a.active { color: var(--teal); font-weight: 600; }
.tabbar a.add-btn { color: var(--gold); }
.tabbar a.add-btn .ico { font-size: 1.6rem; line-height: 1.2; }

/* 详情页 */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.detail-head h3 { font-size: 1.15rem; }
.detail-head .sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.info-list { list-style: none; }
.info-list li { display: flex; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .88rem; gap: 12px; }
.info-list li:last-child { border-bottom: none; }
.info-list .k { width: 78px; flex-shrink: 0; color: var(--muted); font-size: .8rem; padding-top: 1px; }
.info-list .v { word-break: break-word; }
.info-list .v a { color: var(--info); text-decoration: none; }

/* 跟进记录 */
.note {
  border-left: 3px solid var(--gold);
  background: #fbf8ef;
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 10px;
}
.note .nt { font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.note .nc { font-size: .88rem; white-space: pre-wrap; }

/* 空状态 */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .e-ico { font-size: 2.6rem; margin-bottom: 10px; }
.empty p { font-size: .88rem; margin-bottom: 16px; }

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--teal-dark) 0%, var(--teal) 60%, var(--teal-light) 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 26px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-card .logo { text-align: center; margin-bottom: 24px; }
.login-card .logo .mark {
  width: 56px; height: 56px; margin: 0 auto 12px;
  background: var(--teal);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-light); font-size: 1.6rem; font-weight: 700;
}
.login-card .logo h1 { font-size: 1.2rem; color: var(--teal); }
.login-card .logo p { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.login-err { color: var(--danger); font-size: .82rem; text-align: center; margin-bottom: 10px; min-height: 1.2em; }

/* toast */
#toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17,46,46,.95);
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: .85rem;
  z-index: 999;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
#toast.show { opacity: 1; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff;
  width: 100%;
  max-width: 640px;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 28px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { font-size: 1rem; color: var(--teal); margin-bottom: 14px; }

.section-gap { margin-top: 20px; }
.muted { color: var(--muted); font-size: .8rem; }
.text-center { text-align: center; }
.mt12 { margin-top: 12px; }

/* 修复移动端横向溢出 */
* { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100vw; }
.page { overflow-x: hidden; max-width: 100vw; }
.card { overflow: hidden; }

/* 星级选择器：手机上自适应换行+缩小 */
#ratingPicker, #editRatingPicker {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
}
#ratingPicker .chip, #editRatingPicker .chip {
  white-space: nowrap;
  font-size: 1rem !important;
  padding: 6px 10px !important;
  flex: 0 0 auto;
}

/* 星级筛选带说明 */
.rating-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 8px;
  padding: 8px 12px 4px;
}
.rating-filter-grid .rf-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  background: #fff;
  cursor: pointer;
  font-size: .78rem;
  transition: all .15s;
}
.rating-filter-grid .rf-chip.active {
  background: #1a4040;
  color: #fff;
  border-color: #1a4040;
}
.rating-filter-grid .rf-chip .stars { font-size: .7rem; white-space: nowrap; }
.rating-filter-grid .rf-chip .desc { font-size: .72rem; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rating-filter-grid .rf-chip.active .desc { color: #ccc; }
.rating-filter-grid .rf-chip.all { grid-column: 1 / -1; }
