:root {
  --wine: #7A1622;
  --wine-2: #5C1019;
  --gold: #C9A227;
  --bg: #F6F4F1;
  --card: #FFFFFF;
  --ink: #262220;
  --muted: #8A817C;
  --line: #E8E3DD;
  --a: #C0392B;
  --b: #E08A1E;
  --c: #7E8C99;
  --d: #CFCAC4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  background: linear-gradient(100deg, var(--wine-2), var(--wine) 55%, #8E2430);
  color: #fff;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.mark {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--gold), #A8841A);
  color: var(--wine-2);
  font-size: 21px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.brand h1 { font-size: 19px; margin: 0; letter-spacing: 2px; font-weight: 600; }
.brand .sub { margin: 2px 0 0; font-size: 12px; color: rgba(255, 255, 255, .72); }

.topright { display: flex; align-items: center; gap: 22px; }

.stat { text-align: center; }
.stat b { display: block; font-size: 21px; font-weight: 600; color: var(--gold); }
.stat span { font-size: 11px; color: rgba(255, 255, 255, .7); letter-spacing: 1px; }

.filter-note {
  flex-basis: 100%;
  text-align: right;
  font-size: 12px;
  color: rgba(255, 255, 255, .82);
  margin-top: 4px;
}

.btn-run {
  background: var(--gold);
  color: #3A2A05;
  border: 0;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform .12s, box-shadow .12s;
}
.btn-run:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, .28); }
.btn-run:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------------- 工具栏 ---------------- */

.toolbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 11px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

.filterform { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filterform select,
.filterform input[type=text] {
  border: 1px solid var(--line);
  background: #FCFBFA;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
}
.filterform input[type=text] { width: 210px; }
.filterform select:focus,
.filterform input[type=text]:focus { border-color: var(--wine); background: #fff; }

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover { border-color: var(--wine); color: var(--wine); }

.runinfo { font-size: 12px; color: var(--muted); }
.live { color: var(--wine); font-weight: 600; }
.live::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--a);
  margin-right: 6px;
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------------- 卡片 ---------------- */

main { padding: 18px 28px 40px; max-width: 1500px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--d);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 200px 150px;
  gap: 16px;
  align-items: center;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 5px 20px rgba(80, 50, 30, .09); transform: translateY(-1px); }

.card.lv-A { border-left-color: var(--a); }
.card.lv-B { border-left-color: var(--b); }
.card.lv-C { border-left-color: var(--c); }
.card.lv-D { border-left-color: var(--d); }

.card[data-status=called]  { background: #FBFDFB; }
.card[data-status=quoted]  { background: #FBFCFD; }
.card[data-status=won]     { background: #F6FBF6; }
.card[data-status=dropped] { opacity: .5; }

.rank { text-align: center; }
.badge {
  display: inline-block;
  width: 26px; height: 26px;
  line-height: 26px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--c);
}
.lv-A .badge { background: var(--a); }
.lv-B .badge { background: var(--b); }
.lv-C .badge { background: var(--c); }
.lv-D .badge { background: var(--d); color: #6B625C; }
.score { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.title-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.buyer {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: .3px;
}
.buyer:hover { color: var(--wine); text-decoration: underline; text-underline-offset: 3px; }

.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: #F1EDE8;
  color: var(--muted);
  white-space: nowrap;
}
.tag-intent { background: #FDF3DC; color: #8A6410; }
.tag-dim { background: #EFEFEF; color: #999; }
.tag-state { background: #EAF2EA; color: #3D6B42; }

.ttl {
  font-size: 12.5px;
  color: #6E6660;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.reason {
  font-size: 12px;
  color: var(--wine);
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lv-C .reason, .lv-D .reason { color: var(--muted); }

.meta { text-align: right; }
.phone {
  font-size: 17px;
  font-weight: 600;
  color: var(--wine);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
  display: block;
}
.phone:hover { text-decoration: underline; }
.phone.none { color: var(--d); font-weight: 400; }
.small { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.money { color: #8A6410; font-weight: 600; }
.hot { color: var(--a); font-weight: 600; }
.over { color: #B9B2AC; }
.cool { color: var(--muted); }

.ops { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.op {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11.5px;
  color: #5C5550;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.op:hover { border-color: var(--wine); color: var(--wine); }
.op-link { color: var(--muted); }
.op.on { background: var(--wine); border-color: var(--wine); color: #fff; }

/* ---------------- 空态 ---------------- */

.empty {
  background: #fff;
  border: 1px dashed #DCD5CD;
  border-radius: 12px;
  padding: 54px 30px;
  text-align: center;
  color: var(--muted);
}
.empty-t { font-size: 16px; color: var(--ink); margin: 0 0 10px; font-weight: 600; }
.empty p { margin: 0; font-size: 13px; line-height: 1.8; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 28px 30px;
  font-size: 11.5px;
  color: #A39A93;
  max-width: 1500px;
  margin: 0 auto;
}

/* ---------------- 详情页 ---------------- */

.detail { max-width: 880px; margin: 26px auto; padding: 0 24px 60px; }
.detail .back { font-size: 13px; color: var(--wine); text-decoration: none; }
.detail h2 { font-size: 19px; margin: 14px 0 6px; line-height: 1.5; }
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 18px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.grid2 div span { display: block; font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.grid2 div b { font-size: 15px; font-weight: 600; }
.body {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  white-space: pre-wrap;
  font-size: 13.5px;
  line-height: 1.9;
  color: #3A3430;
  max-height: 60vh;
  overflow: auto;
}
.detail .ops { justify-content: flex-start; margin: 14px 0; }

/* ---------------- 标签页 ---------------- */

.tabs {
  display: flex;
  gap: 2px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
}
.tabs a {
  padding: 10px 20px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--wine); }
.tabs a.active { color: var(--wine); border-bottom-color: var(--wine); font-weight: 600; }

/* ---------------- 客户池表格 ---------------- */

.ctable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.ctable th {
  text-align: left;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  padding: 9px 12px;
  background: #FBFAF8;
  border-bottom: 1px solid var(--line);
  letter-spacing: .5px;
  white-space: nowrap;
}
.ctable td {
  padding: 9px 12px;
  border-bottom: 1px solid #F2EEE9;
  font-size: 13px;
  vertical-align: middle;
}
.ctable tr:last-child td { border-bottom: 0; }
.ctable tbody tr:hover { background: #FDFBF9; }
.ctable tr[data-status=dropped] { opacity: .45; }
.ctable tr[data-status=called]  { background: #FBFDFB; }
.ctable tr[data-status=quoted]  { background: #FBFCFD; }
.ctable tr[data-status=won]     { background: #F6FBF6; }

.badge.b-A { background: var(--a); }
.badge.b-B { background: var(--b); }
.badge.b-C { background: var(--c); }
.badge.b-D { background: var(--d); color: #6B625C; }

.ctable .badge { width: 21px; height: 21px; line-height: 21px; font-size: 11px; border-radius: 5px; }

.cname { font-weight: 600; font-size: 13.5px; line-height: 1.4; }
.csub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.dim { color: var(--muted); font-size: 12px; }

.phone-sm {
  font-size: 14px;
  font-weight: 600;
  color: var(--wine);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.phone-sm:hover { text-decoration: underline; }
.phone-sm.none { color: var(--d); font-weight: 400; }

.ops-sm { gap: 4px; justify-content: flex-start; }
.ops-sm .op { padding: 3px 7px; font-size: 11px; }

.hint { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; }

/* ---------------- 中标供应商 ---------------- */
.winner-line {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--paper-2, #F6F1E7);
  border-left: 3px solid var(--a);
  padding: 5px 9px;
  border-radius: 4px;
}
.winner-line b { color: var(--ink); }
.winner-tip {
  margin: 14px 0 4px;
  padding: 10px 14px;
  background: #FDF6E9;
  border: 1px solid #E8D9B8;
  border-radius: 8px;
  font-size: 13.5px;
  color: #6B4E1E;
}

/* ---------------- 粘贴导入 ---------------- */
.quickadd {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
}
.quickadd textarea {
  flex: 1;
  min-height: 52px;
  resize: vertical;
  border: 1px solid var(--line, #D8CFC0);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #FFFDF8;
}
.quickadd textarea:focus { outline: 2px solid var(--a, #7A1622); }
#qaMsg { max-width: 40%; word-break: break-all; }

/* ---------------- 分配后台 ---------------- */

.tab-right { margin-left: auto; opacity: .85; }
main.admin-main { padding: 18px 28px 40px; display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; color: var(--wine); }
.panel .hint { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.agent-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #FBFAF8; }
.ac-head { display: flex; justify-content: space-between; align-items: center; }
.ac-num { font-size: 30px; font-weight: 700; color: var(--wine); line-height: 1.1; margin: 4px 0 0; }
.ac-sub { color: var(--muted); font-size: 12px; }
.ac-bars { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.chip { background: #EFE7E1; color: var(--wine-2); border-radius: 20px; padding: 2px 9px; font-size: 11.5px; }
.view-agent { margin-top: 4px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.assign-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.assign-bar label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.assign-bar select, .assign-bar input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.assign-bar .ck { flex-direction: row; align-items: center; gap: 6px; }

.ctable.compact td, .ctable.compact th { padding: 7px 10px; }
.ctable .cowner { color: var(--wine-2); font-weight: 600; }
.ok { color: #2E8B57; } .bad { color: var(--a); }

.pool-ops { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.pool-ops select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.fs { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff; max-width: 130px; }

.op.mini { padding: 4px 9px; font-size: 12px; }
.cols-owner { color: var(--wine-2); }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(120deg, var(--wine-2), var(--wine)); }
.login-card { background: #fff; border-radius: 16px; padding: 28px 30px; width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-brand { margin-bottom: 16px; }
.login-brand h1 { font-size: 19px; margin: 0; color: var(--wine); }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.login-form input { padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; }
.runinfo.err { color: var(--a); }

/* ---------------- 窄屏 ---------------- */

@media (max-width: 900px) {
  .card { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; }
  .meta { grid-column: 2; text-align: left; margin-top: 4px; }
  .ops { grid-column: 2; justify-content: flex-start; }
  .topbar, .toolbar, main, footer, .tabs { padding-left: 14px; padding-right: 14px; }
  .filterform input[type=text] { width: 100%; }
  /* 客户表窄屏隐藏「类别」「职务」两列 */
  .ctable th:nth-child(4), .ctable td:nth-child(4),
  .ctable th:nth-child(6), .ctable td:nth-child(6) { display: none; }
  .ctable td, .ctable th { padding: 8px 8px; }
}

/* ============ 联系记录弹窗 ============ */
.modal-ov {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(38, 34, 32, .48);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: mFade .15s ease;
  padding: 16px;
}
.modal-box {
  background: var(--card);
  border-radius: 16px;
  padding: 0 24px 16px;
  width: min(540px, 94vw);
  box-shadow: 0 24px 64px rgba(38, 34, 32, .35), 0 2px 8px rgba(38, 34, 32, .12);
  animation: mPop .2s cubic-bezier(.2, .9, .3, 1.2);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  margin: 0 -24px 16px;
  padding: 16px 20px 14px;
  background: linear-gradient(100deg, rgba(122, 22, 34, .08), rgba(201, 162, 39, .06));
  border-bottom: 1px solid var(--line);
}
.modal-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--wine-2), var(--wine) 60%, #8E2430);
  color: #fff; font-size: 19px; font-weight: 700;
  box-shadow: 0 4px 10px rgba(122, 22, 34, .30);
}
.modal-head-txt { flex: 1; min-width: 0; }
.modal-head h3 { margin: 0; font-size: 17px; color: var(--ink); line-height: 1.3; }
.modal-sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.modal-x {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 20px; line-height: 1;
  transition: background .12s, color .12s;
}
.modal-x:hover { background: rgba(38, 34, 32, .07); color: var(--ink); }
.modal-box textarea {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; line-height: 1.65; font-family: inherit;
  color: var(--ink); background: var(--bg);
  resize: vertical; min-height: 132px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.modal-box textarea::placeholder { color: #B5ACA6; }
.modal-box textarea:focus {
  outline: none; border-color: var(--wine);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(122, 22, 34, .12);
}
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px;
}
.modal-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; }
.modal-btns .btn-ghost { padding: 8px 16px; border-radius: 10px; }
.modal-btns .btn-run {
  padding: 8px 20px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--wine-2), var(--wine) 60%, #8E2430);
  color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 3px 8px rgba(122, 22, 34, .28);
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.modal-btns .btn-run:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(122, 22, 34, .36);
}
.modal-btns .btn-run:disabled { opacity: .6; cursor: default; }
.modal-msg { margin: 8px 0 0; font-size: 13px; color: var(--a); min-height: 16px; }
.modal-hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
@keyframes mFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mPop { from { transform: scale(.94) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
