/* webkf 客服工作台 */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e8edf5;
  --line-2: #f1f5fa;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --brand: #2b6cf6;
  --brand-dark: #1d54cc;
  --brand-soft: #eef4ff;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 8px 28px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d5dde9; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #c2ccdb; }
::-webkit-scrollbar-track { background: transparent; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% 8%, #e8f0ff 0%, rgba(232, 240, 255, 0) 60%),
    radial-gradient(800px 460px at 88% 92%, #eaf7f1 0%, rgba(234, 247, 241, 0) 62%),
    var(--bg);
}
.login-card {
  width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 22px;
}
.login-logo .mark {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(140deg, #4d84ff, #2b6cf6 60%, #1d54cc);
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 6px 16px rgba(43, 108, 246, .3);
}
.login-logo h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.login-logo p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfe; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(43, 108, 246, .12); }
textarea.input { resize: vertical; min-height: 76px; line-height: 1.6; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cfdaeb; background: #fafbfe; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(43, 108, 246, .25); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5fa; color: var(--ink); }
.btn-danger { color: var(--danger); border-color: #f6d5d5; background: #fff6f6; }
.btn-danger:hover { background: #ffecec; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 4px; }
.login-foot { margin-top: 18px; font-size: 11.5px; color: var(--muted-2); text-align: center; line-height: 1.7; }

/* ---------- 主框架 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.rail {
  width: 64px; flex: 0 0 64px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 12px 0 10px; gap: 6px;
}
.rail .brand {
  width: 36px; height: 36px; border-radius: 11px; margin-bottom: 8px;
  background: linear-gradient(140deg, #4d84ff, #2b6cf6 60%, #1d54cc);
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 5px 14px rgba(43, 108, 246, .28);
}
.rail-btn {
  width: 44px; height: 42px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; position: relative; transition: all .15s;
}
.rail-btn span { font-size: 10px; line-height: 1; }
.rail-btn:hover { background: #f4f7fc; color: var(--ink-2); }
.rail-btn.active { background: var(--brand-soft); color: var(--brand); }
.rail-btn .dot-badge {
  position: absolute; top: 3px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px;
  line-height: 16px; text-align: center; font-weight: 600;
}
.rail-spacer { flex: 1; }
.rail-me {
  width: 38px; height: 38px; border-radius: 50%; background: #e8effd; color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 600; cursor: pointer;
  border: 1px solid #d9e5ff; position: relative;
}
.rail-me .presence {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok); border: 2px solid #fff;
}

/* ---------- 会话列表 ---------- */
.list-col {
  width: 306px; flex: 0 0 306px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0;
}
.list-head { padding: 14px 14px 0; }
.list-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.list-title h2 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.list-title .count { font-size: 12px; color: var(--muted); background: #f2f6fc; padding: 2px 8px; border-radius: 999px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 10px; }
.tab {
  padding: 7px 9px 9px; font-size: 13px; color: var(--muted); background: transparent;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab .n { font-size: 11px; color: var(--muted-2); margin-left: 3px; }
.tab.active .n { color: var(--brand); }
.search { position: relative; margin-bottom: 10px; }
.search input {
  width: 100%; padding: 8px 10px 8px 31px; border: 1px solid var(--line);
  border-radius: 9px; background: #fbfcfe; outline: none; font-size: 13px;
}
.search input:focus { border-color: var(--brand); background: #fff; }
.search svg { position: absolute; left: 10px; top: 9px; color: var(--muted-2); }

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
.conv-item {
  display: flex; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer;
  transition: background .13s; position: relative;
}
.conv-item:hover { background: #f7f9fd; }
.conv-item.active { background: var(--brand-soft); }
.conv-item .av {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  background: #eef2f9; color: #5b6b82; display: flex; align-items: center;
  justify-content: center; font-weight: 600; font-size: 14px; position: relative;
}
.conv-item .av .on {
  position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok); border: 2px solid #fff;
}
.conv-item .av .off { background: #cbd5e1; }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.conv-name { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { margin-left: auto; font-size: 11px; color: var(--muted-2); flex: 0 0 auto; }
.conv-bottom { display: flex; align-items: center; gap: 6px; }
.conv-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.unread {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 600; line-height: 17px; text-align: center; flex: 0 0 auto;
}
.tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 5px; background: #f1f5fa;
  color: var(--muted); flex: 0 0 auto; white-space: nowrap;
}
.tag.wait { background: #fff7e8; color: #b45309; }
.tag.mine { background: #eaf6ee; color: #15803d; }
.tag.site { background: #f1f5fa; color: #64748b; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted-2); font-size: 13px; line-height: 1.9; }

/* ---------- 聊天区 ---------- */
.chat-col { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-head {
  height: 60px; flex: 0 0 60px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
}
.chat-head .who { display: flex; flex-direction: column; min-width: 0; }
.chat-head .who strong { font-size: 14px; font-weight: 650; }
.chat-head .who span { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.chat-head .who span i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); display: inline-block; }
.chat-head .who span.off i { background: #cbd5e1; }
.chat-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.msgs { flex: 1; overflow-y: auto; padding: 18px 20px 8px; }
.day { text-align: center; margin: 10px 0 14px; }
.day span { font-size: 11.5px; color: var(--muted-2); background: #eaeff7; padding: 3px 10px; border-radius: 999px; }
.m { display: flex; gap: 9px; margin-bottom: 12px; align-items: flex-start; }
.m .av {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; display: flex;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.m.them .av { background: #eef2f9; color: #5b6b82; }
.m.me { flex-direction: row-reverse; }
.m.me .av { background: var(--brand-soft); color: var(--brand); }
.m .content { max-width: 66%; min-width: 0; display: flex; flex-direction: column; }
.m.them .content { align-items: flex-start; }
.m.me .content { align-items: flex-end; }
.m .meta { font-size: 11px; color: var(--muted-2); margin-bottom: 3px; display: flex; gap: 6px; align-items: center; }
.m.me .meta { justify-content: flex-end; }
.m .bubble {
  padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow-sm);
  display: inline-block; max-width: 100%;
}
.m.them .bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 4px; }
.m.me .bubble { background: var(--brand); color: #fff; border-top-right-radius: 4px; }
.m.sys { justify-content: center; }
.m.sys .bubble { background: #e9eef6; color: #64748b; font-size: 11.5px; box-shadow: none; border-radius: 999px; padding: 4px 12px; }
.typing-line { font-size: 11.5px; color: var(--muted); margin: -4px 0 8px 39px; height: 16px; }

.composer { flex: 0 0 auto; background: #fff; border-top: 1px solid var(--line); padding: 10px 14px 12px; }
.composer .box {
  border: 1px solid var(--line); border-radius: 11px; background: #fbfcfe; padding: 8px 10px 6px;
  transition: border-color .15s, background .15s;
}
.composer .box:focus-within { border-color: var(--brand); background: #fff; }
.composer textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent;
  font-size: 13.5px; line-height: 1.6; max-height: 132px; min-height: 34px; padding: 2px 0;
}
.composer .bar { display: flex; align-items: center; gap: 6px; padding-top: 4px; }
.composer .bar .hint { font-size: 11px; color: var(--muted-2); margin-left: auto; }
.icon-btn {
  width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.icon-btn:hover { background: #f1f5fa; color: var(--ink); }
.send-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 9px;
  background: var(--brand); color: #fff; border: 0; font-weight: 500; font-size: 13px;
  box-shadow: 0 4px 12px rgba(43, 108, 246, .22); transition: all .15s;
}
.send-btn:hover { background: var(--brand-dark); }
.send-btn:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }

/* 快捷回复弹层 */
.pop {
  position: absolute; z-index: 40; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); width: 340px; max-height: 320px;
  overflow-y: auto; padding: 6px;
}
.pop .item { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pop .item:hover { background: var(--brand-soft); }
.pop .item b { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; margin-bottom: 2px; }
.pop .item span { font-size: 12px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop .empty { padding: 16px; }

/* ---------- 访客信息 ---------- */
.info-col {
  width: 268px; flex: 0 0 268px; background: #fff; border-left: 1px solid var(--line);
  overflow-y: auto; padding: 16px 16px 24px;
}
.info-card { margin-bottom: 20px; }
.info-card h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted-2);
  margin: 0 0 10px; font-weight: 600;
}
.kv { display: flex; gap: 10px; font-size: 12.5px; padding: 5px 0; border-bottom: 1px dashed #f0f4fa; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); flex: 0 0 62px; }
.kv .v { color: var(--ink-2); flex: 1; word-break: break-all; }
.info-actions { display: flex; flex-direction: column; gap: 8px; }
.rating-stars { color: #f59e0b; letter-spacing: 2px; font-size: 14px; }

/* ---------- 管理视图 ---------- */
.admin { flex: 1; overflow-y: auto; padding: 24px 28px 40px; min-width: 0; }
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.admin-head h2 { font-size: 18px; margin: 0; font-weight: 650; }
.admin-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.admin-head .right { margin-left: auto; display: flex; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; box-shadow: var(--shadow-sm);
}
.stat .lab { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .num { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.5px; }
.stat .sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-head .right { margin-left: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 14px; background: #fafbfe; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); font-size: 13px; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: #fcfdff; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; }
.pill.on { background: #eaf6ee; color: #15803d; }
.pill.off { background: #f3f5f9; color: #7b8798; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.switch { position: relative; display: inline-block; width: 38px; height: 21px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d8e0ec; border-radius: 999px; transition: .18s; cursor: pointer; }
.switch span::before {
  content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(17px); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  width: 520px; max-width: 100%; max-height: 88vh; overflow-y: auto; background: #fff;
  border-radius: 16px; box-shadow: var(--shadow-lg);
}
.modal.wide { width: 640px; }
.modal-head { padding: 18px 20px 12px; display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 4px 20px 8px; }
.modal-foot { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.form-row .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; line-height: 1.6; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code-box {
  background: #0f172a; color: #cbd5e1; border-radius: 10px; padding: 13px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px;
  line-height: 1.7; white-space: pre-wrap; word-break: break-all; position: relative;
}
.copy-btn { position: absolute; top: 8px; right: 8px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 42px; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }

/* ---------- 提示条 ---------- */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); animation: toastIn .2s ease;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1180px) {
  .info-col { display: none; }
}
@media (max-width: 900px) {
  .list-col { width: 260px; flex-basis: 260px; }
}
