/* 客户后台（portal）样式 —— 与老后台保持同一套视觉语言：白卡片、浅灰底、蓝色主色 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  background: #f5f6f8; color: #2b2f36;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
a { color: #1677ff; text-decoration: none; }
button { font-family: inherit; }

/* ============ 登录页 ============ */
.lg-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lg-card { width: 400px; background: #fff; border-radius: 14px; padding: 40px 36px 34px; box-shadow: 0 2px 18px rgba(0, 0, 0, .06); }
.lg-logo {
  width: 48px; height: 48px; border-radius: 11px; margin-bottom: 20px;
  background: linear-gradient(135deg, #1b2333, #0b0f16);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .18);
}
.lg-logo img { width: 40%; display: block; }
.lg-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; letter-spacing: .3px; }
.lg-sub { font-size: 13px; color: #999; margin-bottom: 26px; }
.fld { margin-bottom: 14px; }
.fld label { display: block; font-size: 12.5px; color: #666; margin-bottom: 6px; }
.fld input {
  width: 100%; padding: 11px 14px; border: 1px solid #e0e3e8; border-radius: 8px;
  font-size: 14px; outline: none; font-family: inherit; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.fld input:focus { border-color: #1677ff; box-shadow: 0 0 0 3px rgba(22, 119, 255, .08); }
.lg-btn {
  width: 100%; padding: 12px; background: #1677ff; color: #fff; border: none; border-radius: 8px;
  font-size: 14.5px; cursor: pointer; margin-top: 8px; transition: background .15s;
}
.lg-btn:hover { background: #4096ff; }
.lg-btn:disabled { background: #9cc4ff; cursor: default; }
.lg-err {
  background: #fff1f0; border: 1px solid #ffccc7; color: #cf1322;
  font-size: 12.5px; padding: 9px 12px; border-radius: 7px; margin-bottom: 14px; display: none;
}
.lg-err.show { display: block; }

/* ============ 主框架 ============ */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 212px; background: #fff; border-right: 1px solid #eef0f3; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { padding: 18px 18px 15px; border-bottom: 1px solid #f4f5f7; display: flex; gap: 10px; align-items: center; }
.side-brand .bmark {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #1b2333, #0b0f16);
  display: flex; align-items: center; justify-content: center;
}
.side-brand .bmark img { width: 80%; display: block; }
.side-brand .nm { font-size: 13.5px; font-weight: 600; color: #1f2937; line-height: 1.35; word-break: break-all; }
.side-brand .tp { font-size: 11px; color: #9aa1ac; margin-top: 2px; }
.side-nav { padding: 10px 8px; flex: 1; overflow: auto; }
.sn {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 7px;
  font-size: 13.5px; color: #4b5563; cursor: pointer; margin-bottom: 2px; transition: background .12s, color .12s;
}
.sn:hover { background: #f5f7fa; }
.sn.on { background: #eef4ff; color: #1677ff; font-weight: 500; }
.sn .si { font-size: 14px; width: 16px; text-align: center; opacity: .85; }
.side-foot { padding: 12px 16px; border-top: 1px solid #f4f5f7; font-size: 12px; color: #9aa1ac; display: flex; align-items: center; }
.side-foot .q { margin-left: auto; color: #1677ff; cursor: pointer; }

.main { flex: 1; padding: 22px 26px 40px; min-width: 0; }
.pg-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pg-head h1 { font-size: 19px; font-weight: 600; }
.pg-head .hs { font-size: 12.5px; color: #9aa1ac; }
.pg-head .rt { margin-left: auto; }

/* ============ 卡片 / KPI ============ */
.card { background: #fff; border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(16, 24, 40, .04); margin-bottom: 16px; }
.card-hd { display: flex; align-items: center; margin-bottom: 14px; }
.card-hd h3 { font-size: 14.5px; font-weight: 600; }
.card-hd .hi { font-size: 12px; color: #9aa1ac; margin-left: 8px; }
.card-hd .rt { margin-left: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(16, 24, 40, .04); }
.kpi .k { font-size: 12.5px; color: #8b919b; margin-bottom: 8px; }
.kpi .v { font-size: 26px; font-weight: 600; color: #1f2937; line-height: 1.1; letter-spacing: -.5px; }
.kpi .v small { font-size: 13px; font-weight: 400; color: #9aa1ac; margin-left: 3px; }
.kpi .s { font-size: 11.5px; color: #b0b8c4; margin-top: 6px; }
.kpi.hl .v { color: #1677ff; }

/* 趋势条 */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 116px; padding: 0 2px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.bars .b .bar { width: 100%; max-width: 46px; background: #dbe8ff; border-radius: 5px 5px 0 0; min-height: 3px; transition: background .15s; }
.bars .b:hover .bar { background: #1677ff; }
.bars .b .num { font-size: 11px; color: #8b919b; }
.bars .b .lb { font-size: 11px; color: #b0b8c4; }

/* ============ 表格 ============ */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: #8b919b; font-weight: 500; padding: 9px 10px; border-bottom: 1px solid #f0f1f4; white-space: nowrap; }
td { padding: 11px 10px; font-size: 13px; color: #3d434c; border-bottom: 1px solid #f6f7f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
td .b { font-weight: 500; color: #1f2937; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: #4b5563; }
.chip { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 4px; line-height: 18px; }
.chip.blue { background: #e8f1ff; color: #1677ff; }
.chip.gray { background: #f2f3f5; color: #8b919b; }
.chip.green { background: #f0fbf1; color: #2f9e44; }
.chip.orange { background: #fff7e6; color: #d48806; }
.chip.red { background: #fff1f0; color: #cf1322; }

/* ============ 会话记录 ============ */
.conv-wrap { display: flex; gap: 16px; align-items: stretch; min-height: 560px; }
.conv-list { width: 300px; flex-shrink: 0; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .04); display: flex; flex-direction: column; overflow: hidden; }
.conv-list .hd { padding: 13px 14px; border-bottom: 1px solid #f2f3f5; }
.conv-list .hd input {
  width: 100%; padding: 8px 11px; border: 1px solid #e6e8ec; border-radius: 7px;
  font-size: 12.5px; outline: none; font-family: inherit;
}
.conv-list .hd input:focus { border-color: #1677ff; }
.conv-items { flex: 1; overflow: auto; max-height: 640px; }
.ci { padding: 12px 14px; border-bottom: 1px solid #f7f8fa; cursor: pointer; display: flex; gap: 10px; }
.ci:hover { background: #fafbfc; }
.ci.on { background: #f3f8ff; }
.ci .av { width: 34px; height: 34px; border-radius: 50%; background: #eef1f5; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #8b919b; overflow: hidden; }
.ci .av img { width: 100%; height: 100%; object-fit: cover; }
.ci .mid { flex: 1; min-width: 0; }
.ci .r1 { display: flex; align-items: baseline; gap: 6px; }
.ci .nm { font-size: 13px; font-weight: 500; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci .tm { margin-left: auto; font-size: 11px; color: #b0b8c4; flex-shrink: 0; }
.ci .r2 { font-size: 12px; color: #9aa1ac; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci .ch { font-size: 11px; color: #b0b8c4; margin-top: 3px; }

.chat { flex: 1; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .04); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.chat-hd { padding: 13px 18px; border-bottom: 1px solid #f2f3f5; display: flex; align-items: center; gap: 10px; }
.chat-hd .nm { font-size: 14px; font-weight: 600; }
.chat-hd .mt { font-size: 12px; color: #9aa1ac; }
.chat-body { flex: 1; overflow: auto; padding: 18px; background: #fafbfc; max-height: 600px; }
.msg { margin-bottom: 14px; display: flex; }
.msg .bub {
  max-width: 76%; padding: 9px 13px; border-radius: 10px; font-size: 13.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.msg .tail { display: block; font-size: 10.5px; color: #b0b8c4; margin-top: 5px; }
.msg.in { justify-content: flex-start; }
.msg.in .bub { background: #fff; border: 1px solid #eceff3; color: #2b2f36; }
.msg.out { justify-content: flex-end; }
.msg.out .bub { background: #1677ff; color: #fff; }
.msg.out .bub .tail { color: rgba(255, 255, 255, .7); }
.msg .tag { display: inline-block; font-size: 11px; background: #fff4e6; color: #d46b08; border: 1px solid #ffe0b2; padding: 1px 6px; border-radius: 4px; margin-top: 6px; }
.empty { padding: 60px 20px; text-align: center; color: #b0b8c4; font-size: 13px; }

/* ============ 渠道卡 ============ */
.chs { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.chc { background: #fff; border: 1px solid #eef0f3; border-radius: 11px; padding: 16px; }
.chc .t { font-size: 13.5px; font-weight: 600; color: #1f2937; margin-bottom: 10px; line-height: 1.4; }
.chc .row { display: flex; justify-content: space-between; font-size: 12.5px; color: #8b919b; padding: 4px 0; }
.chc .row b { color: #1f2937; font-weight: 600; }
.chc .src { font-size: 11px; color: #c0c4cc; margin-top: 8px; font-family: ui-monospace, monospace; }

/* ============ 工具类 ============ */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: #f2f3f5; border-radius: 7px; padding: 2px; }
.seg span { padding: 5px 12px; font-size: 12.5px; border-radius: 5px; cursor: pointer; color: #6b7280; }
.seg span.on { background: #fff; color: #1677ff; font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.btn { padding: 6px 13px; border-radius: 6px; font-size: 12.5px; cursor: pointer; border: 1px solid #e3e6eb; background: #fff; color: #4b5563; }
.btn:hover { background: #f7f8fa; }
.btn:disabled { opacity: .5; cursor: default; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding-top: 12px; font-size: 12.5px; color: #8b919b; }
.loading { padding: 46px; text-align: center; color: #b0b8c4; font-size: 13px; }
.toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%);
  background: #1f2937; color: #fff; font-size: 13px; padding: 9px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 999;
}
.toast.on { opacity: 1; }

@media (max-width: 900px) {
  .side { width: 64px; }
  .side-brand .nm, .side-brand .tp, .sn span:not(.si), .side-foot span { display: none; }
  .sn { justify-content: center; padding: 11px 0; }
  .conv-wrap { flex-direction: column; }
  .conv-list { width: 100%; }
  .main { padding: 14px; }
}
