:root {
  --brand: #C8102E;
  --brand-soft: #FBEBEE;
  --ink: #15181E;
  --ink2: #4B5462;
  --ink3: #8A92A0;
  --bg: #F4F5F7;
  --card: #fff;
  --line: #E4E7ED;
  --ok: #12805C;
  --ok-soft: #E7F5EF;
  --warn: #C0741A;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-size: 13px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D3D8E0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #BFC6D1; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 12% -10%, #FDEDF0 0%, transparent 60%),
    radial-gradient(700px 400px at 100% 110%, #EEF1F6 0%, transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 388px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 38px 34px 30px; box-shadow: var(--shadow);
}
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center;
  justify-content: center; background: linear-gradient(150deg, var(--brand), #E4526C);
  color: #fff; font-weight: 700; font-size: 19px; letter-spacing: -.02em; margin-bottom: 18px;
}
.login-card h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.login-card .sub { color: var(--ink3); font-size: 13px; margin-top: 4px; margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--ink2); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px;
  background: #FBFBFC; transition: .15s; outline: none;
}
.field input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(200,16,46,.08); }
.btn-primary {
  width: 100%; padding: 11px; background: var(--brand); color: #fff; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px;
  transition: .15s;
}
.btn-primary:hover { background: #A90D26; }
.btn-primary:disabled { background: #D9A3AD; cursor: not-allowed; }
.alert-err {
  background: #FDF2F4; border: 1px solid #F3CCD3; color: #8E0B20; border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; margin-bottom: 16px;
}
.login-foot { margin-top: 20px; font-size: 11.5px; color: var(--ink3); line-height: 1.7; }

/* ---------- 主框架 ---------- */
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 18px; gap: 14px; position: sticky; top: 0; z-index: 20;
}
.topbar .logo {
  width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(150deg, var(--brand), #E4526C);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.topbar .title { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.shop-chip {
  font-size: 11.5px; color: var(--brand); background: var(--brand-soft);
  padding: 3px 9px; border-radius: 20px; font-weight: 600;
}
.topbar .spacer { flex: 1; }
.topbar .meta { font-size: 11.5px; color: var(--ink3); }
.topbar .user { font-size: 12.5px; color: var(--ink2); }
.btn-ghost {
  border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 7px;
  cursor: pointer; color: var(--ink2); transition: .15s;
}
.btn-ghost:hover { border-color: #C9CFD9; background: #FAFBFC; color: var(--ink); }

/* ---------- 筛选 ---------- */
.filters {
  background: #fff; border-bottom: 1px solid var(--line); padding: 12px 18px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; position: sticky; top: 56px; z-index: 19;
}
.filters input, .filters select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  color: var(--ink); outline: none; transition: .15s;
}
.filters input:focus, .filters select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(200,16,46,.07); }
.filters input[type=date] { width: 140px; }
.filters .kw { width: 220px; }
.btn-search {
  background: var(--ink); color: #fff; border: none; padding: 7px 18px; border-radius: 7px;
  cursor: pointer; font-weight: 600;
}
.btn-search:hover { background: #2B3240; }
.sep-v { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
.hint { font-size: 11.5px; color: var(--ink3); margin-left: auto; }

/* ---------- 统计条 ---------- */
.stats { display: flex; gap: 26px; padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.stat .k { font-size: 11.5px; color: var(--ink3); }
.stat .v { font-size: 19px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .v.brand { color: var(--brand); }
.stat .v.ok { color: var(--ok); }

/* ---------- 主体 ---------- */
.main { display: flex; height: calc(100vh - 56px - 53px - 49px); }
.list-col {
  width: 430px; min-width: 340px; border-right: 1px solid var(--line); background: #fff;
  overflow-y: auto; flex-shrink: 0;
}
.detail-col { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.item {
  padding: 12px 16px; border-bottom: 1px solid #F1F3F6; cursor: pointer; transition: .12s;
  border-left: 3px solid transparent;
}
.item:hover { background: #FAFBFD; }
.item.active { background: #FDF7F8; border-left-color: var(--brand); }
.item .r1 { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(140deg, #E9EDF3, #D6DCE6); color: #5B6473;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.item .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r1 .time { margin-left: auto; font-size: 11px; color: var(--ink3); white-space: nowrap; }
.item .r2 { margin-top: 5px; margin-left: 38px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .staff-tag { font-size: 11px; color: var(--ink2); background: #F2F4F7; padding: 1px 7px; border-radius: 10px; }
.item .cnt { font-size: 11px; color: var(--ink3); }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}
.badge.deal { background: var(--ok-soft); color: var(--ok); }
.badge.nodeal { background: #F3F4F6; color: #9AA1AC; }
.badge.prior { background: #FBF1E3; color: #A97322; }
.badge.amt { background: none; color: var(--ok); padding-left: 0; font-variant-numeric: tabular-nums; }

/* ---------- 详情 ---------- */
.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink3); gap: 10px;
}
.empty .big { font-size: 15px; color: var(--ink2); font-weight: 600; }
.detail-head {
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fff;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.detail-head .who { font-weight: 700; font-size: 15px; }
.detail-head .sub { font-size: 12px; color: var(--ink3); }
.detail-body { flex: 1; display: flex; overflow: hidden; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 20px 30px; background: #F7F8FA; }
.side {
  width: 300px; border-left: 1px solid var(--line); background: #fff; overflow-y: auto; padding: 14px;
}
.side h4 { font-size: 12px; color: var(--ink3); font-weight: 600; margin-bottom: 10px; letter-spacing: .02em; }

.msg { margin-bottom: 14px; display: flex; flex-direction: column; }
.msg.customer { align-items: flex-end; }
.msg.service, .msg.robot { align-items: flex-start; }
.msg .who { font-size: 11px; color: var(--ink3); margin-bottom: 3px; }
.bubble {
  max-width: 72%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.62;
}
.msg.customer .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.service .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.robot .bubble { background: #F1F3F6; color: var(--ink2); border-bottom-left-radius: 4px; }
.msg.sys { align-items: center; margin: 10px 0; }
.msg.sys .bubble {
  background: transparent; color: var(--ink3); font-size: 11.5px; padding: 2px 0; max-width: 100%;
}
.msg .t { font-size: 10.5px; color: #A6ADB8; margin-top: 3px; }
mark { background: #FFE9A8; color: inherit; padding: 0 2px; border-radius: 2px; }
.card-sys {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff;
  font-size: 12.5px; color: var(--ink2); max-width: 78%;
}
.card-sys .ttl { font-weight: 600; color: var(--ink); margin-bottom: 3px; }

.order {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; margin-bottom: 9px;
  font-size: 12px; background: #fff;
}
.order.hit { border-color: #B9E0CE; background: #F5FCF9; }
.order .ttl { font-weight: 600; margin-bottom: 5px; line-height: 1.5; color: var(--ink); }
.order .row { display: flex; justify-content: space-between; color: var(--ink3); margin-top: 2px; }
.order .amt { color: var(--ok); font-weight: 700; font-variant-numeric: tabular-nums; }
.side .empty-side { color: var(--ink3); font-size: 12px; padding: 8px 0; }

.pager {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line);
  background: #fff; font-size: 12px; color: var(--ink3);
}
.pager button {
  border: 1px solid var(--line); background: #fff; padding: 4px 10px; border-radius: 6px;
  cursor: pointer; color: var(--ink2);
}
.pager button:disabled { opacity: .45; cursor: not-allowed; }

.loading { padding: 30px; text-align: center; color: var(--ink3); font-size: 13px; }

@media (max-width: 1000px) {
  .main { flex-direction: column; height: auto; }
  .list-col { width: 100%; border-right: none; border-bottom: 1px solid var(--line); max-height: 45vh; }
  .detail-col { min-height: 60vh; }
  .side { width: 240px; }
}
