:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a9099;
  --line: #e5e7eb;
  --brand: #00a5b5;
  --brand-dark: #008a97;
  --danger: #e34d59;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-size: 17px; font-weight: 600; color: var(--brand-dark); }
nav { display: flex; gap: 4px; }
nav button {
  border: 0; background: transparent; padding: 8px 16px; border-radius: 8px;
  font-size: 14px; color: var(--muted); cursor: pointer; font-family: inherit;
}
nav button.active { background: #e6f7f8; color: var(--brand-dark); font-weight: 500; }
main { max-width: 1100px; margin: 28px auto; padding: 0 24px; }
.page { display: none; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-head h1 { font-size: 20px; font-weight: 600; }
.btn {
  border: 0; border-radius: 8px; padding: 9px 18px; cursor: pointer;
  font-size: 14px; font-family: inherit; font-weight: 500;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: transparent; color: var(--danger); }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 400; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.tag-pill {
  display: inline-block; background: #e6f7f8; color: var(--brand-dark);
  padding: 2px 10px; border-radius: 20px; font-size: 12px; margin: 1px 3px 1px 0;
}
.type-pill { padding: 2px 8px; border-radius: 5px; font-size: 12px; }
.type-contact { background: #f0f5ff; color: #4b6cb7; }
.type-acquisition { background: #fef3e6; color: #b7791f; }
.type-group { background: #eaf7ee; color: #3f7d4f; }
.link-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-cell a { color: var(--brand-dark); text-decoration: none; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stat .num { font-size: 30px; font-weight: 600; color: var(--brand-dark); }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.modal-mask {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 50; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 20px;
}
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 620px; max-width: 100%; padding: 26px 28px; }
.modal h2 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
}
.field textarea { resize: vertical; min-height: 76px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--brand); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.schedule-row { display: grid; grid-template-columns: 92px 92px 1fr 32px; gap: 8px; margin-bottom: 8px; align-items: start; }
.schedule-row input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 8px; font-family: inherit; font-size: 13px; width: 100%; }
.schedule-row .btn { padding: 0; width: 32px; height: 38px; line-height: 1; }
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2329; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.loading { color: var(--muted); text-align: center; padding: 30px; }

/* ---------- 统计 / 回访 扩展 ---------- */
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-family: inherit; font-size: 13px; background: #fff; color: var(--text);
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.btn-line { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.sub { color: var(--muted); font-size: 12px; }
.dim { color: var(--muted); }
.on { color: var(--brand-dark); }
.warn { color: #d97706; font-weight: 600; }
.up { color: var(--brand-dark); }
.down { color: var(--danger); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }

.chart { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.peak { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.hbars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; align-items: end; height: 108px; }
.hb { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.hb-fill { background: #b8e5ea; border-radius: 2px 2px 0 0; min-height: 1px; transition: background .15s; }
.hb:hover .hb-fill { background: var(--brand); }
.hb-lab {
  font-size: 10px; color: var(--muted); text-align: center; margin-top: 4px;
  position: absolute; bottom: -18px; left: 0; right: 0;
}

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 7px 16px; border-radius: 20px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.tabs button.active { background: #e6f7f8; border-color: #b8e5ea; color: var(--brand-dark); font-weight: 500; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.pill-done { background: #eaf7ee; color: #3f7d4f; }
.pill-warn { background: #fdf1e3; color: #b45309; }
.pill-wait { background: #f0f2f5; color: #5b6370; }
.pill-lost { background: #fdecee; color: var(--danger); }

.report {
  background: #f7f9fa; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; font-family: inherit; font-size: 13px; line-height: 1.9;
  white-space: pre-wrap; color: var(--text);
}

/* ---------- 账号与权限 ---------- */
.user-bar { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-bar .who { font-size: 13px; color: var(--text); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-bar .btn { white-space: nowrap; }

.perm-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-height: 340px; overflow-y: auto; padding-right: 4px; }
.perm-group { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.perm-group-title { font-size: 12px; font-weight: 600; color: var(--brand-dark); margin-bottom: 6px; }
.perm-item { display: flex; align-items: flex-start; gap: 7px; font-size: 13px; padding: 3px 0; cursor: pointer; color: var(--text); }
.perm-item input { width: auto; margin-top: 3px; flex: none; }

td.nowrap { white-space: nowrap; }
td.wrap { max-width: 420px; word-break: break-all; }

/* ---------- 选择器 ---------- */
.picker { position: relative; }
.picker-box {
  min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 6px 32px 6px 10px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  cursor: pointer; position: relative;
}
.picker-box:hover { border-color: #cfd4db; }
.picker.open .picker-box { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 165, 181, .12); }
.picker-ph { color: #9aa0a8; font-size: 13.5px; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; background: #e9f8f9; color: #00727d;
  border-radius: 5px; padding: 2px 3px 2px 8px; font-size: 13px; line-height: 1.7;
}
.chip b { cursor: pointer; color: #7ba3a7; font-weight: 400; padding: 0 4px; }
.chip b:hover { color: var(--danger); }
.picker-caret {
  position: absolute; right: 12px; top: 50%; width: 7px; height: 7px;
  border-right: 1.5px solid #9aa0a8; border-bottom: 1.5px solid #9aa0a8;
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.picker-panel {
  display: none; position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 25, 40, .14); padding: 8px;
  max-height: 240px; overflow-y: auto;
}
.picker.open .picker-panel { display: block; }
.picker.up .picker-panel { top: auto; bottom: calc(100% + 4px); }
.picker-search {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
  font-size: 13px; font-family: inherit; margin-bottom: 6px; position: sticky; top: 0;
}
.picker-search:focus { outline: none; border-color: var(--brand); }
.picker-group { font-size: 11.5px; color: #9aa0a8; padding: 7px 8px 2px; }
.picker-opt {
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px;
  cursor: pointer; font-size: 13.5px;
}
.picker-opt:hover { background: #f4f6f8; }
.picker-opt.on { background: #eef9fa; }
.picker-tick { width: 13px; color: var(--brand); font-size: 12px; flex: none; }
.picker-name { flex: 1; }
.picker-opt em { font-style: normal; color: #9aa0a8; font-size: 11.5px; }
.picker-empty { color: #9aa0a8; font-size: 12.5px; padding: 10px 8px; line-height: 1.7; }
.picker-list { display: block; }
.picker-manual {
  display: block; width: 100%; margin-top: 6px; padding: 7px;
  border: 0; border-radius: 6px; background: #f4f6f8; color: #6b7280;
  font-size: 12.5px; font-family: inherit; text-align: center; cursor: pointer;
}
.picker-manual:hover { background: #eceff3; color: var(--text); }
.picker.manual .picker-box { display: none; }
.manual-input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  font-size: 14px; font-family: inherit; color: var(--text);
}
.manual-input:focus { outline: none; border-color: var(--brand); }
.schedule-row .picker { min-width: 0; }

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr; }
  main { padding: 0 14px; }
  header { padding: 0 12px; gap: 12px; overflow-x: auto; }
  nav button { padding: 8px 10px; font-size: 13px; }
  .hbars { height: 84px; }
  .perm-groups { grid-template-columns: 1fr; }
  .user-bar .who { display: none; }
}
