/* 客服工作台 · 后台样式 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    color: #20242b; background: #f2f4f7;
}
a { color: #1a73e8; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 4px 0 16px; padding-bottom: 10px; border-bottom: 1px solid #eef1f5; }
h3 { font-size: 15px; margin: 24px 0 10px; }
.muted { color: #8a9099; }
.small { font-size: 12px; }
.empty { color: #98a0aa; padding: 18px; text-align: center; }
.empty.big { padding: 80px 20px; font-size: 15px; }
.nowrap { white-space: nowrap; }
.ok-t { color: #0d8f4f; }
.err-t { color: #d1362f; }

/* 顶栏 */
.top {
    display: flex; align-items: center; gap: 18px; height: 56px;
    background: #fff; border-bottom: 1px solid #e4e8ee; position: sticky; top: 0; z-index: 20;
    padding-left: max(18px, calc((100vw - 1180px) / 2));
    padding-right: max(18px, calc((100vw - 1180px) / 2));
    box-shadow: 0 1px 3px rgba(20, 30, 50, .04);
}
.top .brand { font-weight: 700; font-size: 15px; letter-spacing: .3px; white-space: nowrap; }
.top .nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.top .nav a { padding: 7px 13px; border-radius: 8px; color: #4a5260; white-space: nowrap; font-size: 14px; }
.top .nav a.on { background: #eaf1fe; color: #1a73e8; font-weight: 600; }
.top .nav a:hover { background: #f1f4f9; text-decoration: none; }
.top .me { color: #6b7280; font-size: 13px; white-space: nowrap; }
.top .me .tag { background: #eef1f5; border-radius: 4px; padding: 1px 6px; margin: 0 8px 0 6px; font-size: 12px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 18px 56px; }

/* 提示 */
.flash { padding: 9px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.flash.ok { background: #e8f6ee; color: #0d6b3f; border: 1px solid #c5e8d5; }
.flash.err { background: #fdecea; color: #b3261e; border: 1px solid #f6cbc7; }

/* 居中卡片（安装/登录） */
body.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #eef1f5; }
.card { background: #fff; border-radius: 12px; padding: 26px 28px; width: 560px; max-width: 94vw; box-shadow: 0 8px 30px rgba(20,30,50,.08); }
.card.narrow { width: 380px; }
.card p { margin: 6px 0 14px; font-size: 13px; }

/* 表单 */
label { display: block; font-size: 13px; color: #5a6270; margin: 12px 0 4px; }
label.inline { display: flex; align-items: center; gap: 6px; margin: 14px 0 6px; color: #3c4350; }
input[type=text], input[type=password], input:not([type]), select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #d7dce3; border-radius: 8px;
    font: inherit; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #1a73e8; }
textarea { resize: vertical; }
.form { background: #fff; border: 1px solid #e4e8ee; border-radius: 10px; padding: 6px 18px 18px; }
.form h3 { margin-top: 22px; padding-top: 14px; border-top: 1px solid #eef1f5; }
.form h3:first-of-type { border-top: none; padding-top: 0; }
.f2 { display: flex; gap: 16px; }
.f2 > div { flex: 1; min-width: 0; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form input { width: auto; }
.form.inline-form { display: flex; gap: 8px; align-items: center; padding: 12px 18px; }

.btn {
    display: inline-block; margin-top: 16px; padding: 9px 18px; border: none; border-radius: 8px;
    background: #1a73e8; color: #fff; font: inherit; cursor: pointer;
}
.btn:hover { background: #1565d8; text-decoration: none; }
.btn.small { padding: 4px 10px; margin: 0; font-size: 13px; }
.btn.ghost { background: #eef1f5; color: #3c4350; }
.btn.ghost:hover { background: #e2e7ee; }
.btn.danger { background: #e0524b; }
.btn.danger:hover { background: #cc443d; }
.inline-form .btn { margin-top: 0; }

/* 表格 */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid #e4e8ee; border-radius: 12px; overflow: hidden; }
table.grid.narrow { width: auto; min-width: 460px; }
table.grid th, table.grid td { padding: 11px 14px; border-bottom: 1px solid #f1f4f7; text-align: left; vertical-align: middle; }
table.grid th { background: #f7f9fc; font-size: 13px; color: #5a6270; font-weight: 600; white-space: nowrap; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: #fafbfd; }
input.snippet { width: 100%; min-width: 260px; font-family: Consolas, monospace; font-size: 12px; background: #f7f9fc; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin: 0 3px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { width: 76px; text-align: left; font-weight: 400; color: #8a9099; font-size: 12px; padding: 3px 8px 3px 0; vertical-align: top; white-space: nowrap; }
table.kv td { padding: 3px 0; font-size: 13px; word-break: break-all; }

/* 会话页两栏 */
.cols { display: flex; gap: 14px; align-items: flex-start; }
.col-list { width: 330px; flex: none; }
.col-detail { flex: 1; min-width: 0; background: #fff; border: 1px solid #e4e8ee; border-radius: 10px; overflow: hidden; }
.filters { background: #fff; border: 1px solid #e4e8ee; border-radius: 10px; padding: 8px; margin-bottom: 8px; }
.filters .tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.filters .tabs a { font-size: 13px; padding: 3px 8px; border-radius: 6px; color: #4a5260; }
.filters .tabs a.on { background: #eaf1fe; color: #1a73e8; font-weight: 600; }
.filters .tabs a b { font-weight: 400; color: #98a0aa; margin-left: 2px; }
.filters .row { display: flex; gap: 6px; }
.filters .row select, .filters .row input { flex: 1; min-width: 0; font-size: 13px; padding: 6px 8px; }
.filters .row .btn { margin: 0; padding: 6px 12px; }

/* 登录页验证码 */
.cap-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.cap-row input { flex: 1; }
.cap-row img { height: 48px; border: 1px solid #d9dde3; border-radius: 8px; cursor: pointer; background: #f2f6ff; }

/* 两步验证 */
.totp-box { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.totp-box .kfqr img { width: 150px; height: 150px; border: 1px solid #e4e8ee; border-radius: 10px; padding: 6px; background: #fff; }
.secret-line { font-family: Consolas, monospace; letter-spacing: 1px; word-break: break-all; background: #f7f9fc; border: 1px solid #e4e8ee; border-radius: 8px; padding: 6px 10px; }
.backup-codes { display: flex; flex-wrap: wrap; gap: 8px; }
.backup-codes code { background: #fff; border: 1px dashed #d6e4ff; border-radius: 8px; padding: 6px 10px; font-size: 14px; letter-spacing: 1px; }

/* 安全日志 */
table.grid.sec td { font-size: 13px; }
.tag-fail { color: #b3261e; font-weight: 600; }
.tag-ok { color: #1c6b34; }
.flash.warn { background: #fff6e5; color: #8a5a00; }
.list { background: #fff; border: 1px solid #e4e8ee; border-radius: 10px; overflow: hidden; max-height: calc(100vh - 200px); overflow-y: auto; }
.list .item { display: block; padding: 9px 12px; border-bottom: 1px solid #f1f4f7; color: inherit; }
.list .item:hover { background: #f7f9fc; text-decoration: none; }
.list .item.on { background: #eaf1fe; }
.list .l1 { display: flex; align-items: center; gap: 6px; }
.list .l1 b { font-size: 14px; }
.list .l1 .time { margin-left: auto; color: #98a0aa; font-size: 12px; }
.list .l2 { display: flex; gap: 8px; font-size: 12px; color: #8a9099; margin-top: 2px; }
.list .l2 .st { color: #4a5260; }
.list .l2 .vip { color: #b8860b; }
.badge { background: #e0524b; color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; line-height: 17px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #c6ccd4; }
.dot.s-new { background: #e0524b; }
.dot.s-assigned { background: #7b5cd6; }
.dot.s-taken { background: #f0a020; }
.dot.s-replied { background: #0d8f4f; }
.dot.s-closed { background: #c6ccd4; }

/* 指派组：站点表单里多选、会话详情里改指派 */
.assign-pick { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0 4px; padding: 10px 14px; border: 1px solid #e4e8ee; border-radius: 10px; background: #fafbfc; }
.assign-pick label.inline { margin: 0; }
.assign-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 14px 12px; padding: 8px 14px; border: 1px solid #e4e8ee; border-radius: 10px; background: #fafbfc; font-size: 13px; }
.assign-bar label.inline { margin: 0; }

/* 会话详情 */
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #eef1f5; flex-wrap: wrap; }
.detail-head .site { color: #6b7280; margin: 0 8px; }
.detail-head .st { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #eef1f5; color: #4a5260; }
.detail-head .st.s-new { background: #fdecea; color: #b3261e; }
.detail-head .st.s-assigned { background: #f0ecfd; color: #5538b5; }
.detail-head .st.s-taken { background: #fff5e2; color: #97590a; }
.detail-head .st.s-replied { background: #e8f6ee; color: #0d6b3f; }
.detail-head .esc { background: #fdecea; color: #b3261e; font-size: 12px; padding: 1px 8px; border-radius: 10px; margin-left: 6px; }
.detail-head .acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.detail-head .acts form { display: inline; }
.detail-body { display: flex; gap: 0; }
.chat { flex: 1; min-width: 0; padding: 14px; max-height: calc(100vh - 380px); min-height: 260px; overflow-y: auto; background: #fafbfd; }
.bubble { margin-bottom: 12px; }
.bubble .meta { font-size: 12px; color: #98a0aa; margin-bottom: 3px; }
.bubble .text { display: inline-block; max-width: 78%; padding: 8px 12px; border-radius: 10px; background: #fff; border: 1px solid #e8ebef; word-break: break-word; }
.bubble.b-visitor .text { background: #eaf1fe; border-color: #d5e3fb; }
.bubble.b-agent .text { background: #e8f6ee; border-color: #cdeada; }
.bubble.b-ai .text { background: #f4f1fb; border-color: #e4ddf5; }
.bubble.b-system .meta { display: none; }
.bubble.b-system .text { background: transparent; border: none; color: #98a0aa; font-size: 12px; padding: 0 0 0 2px; }
.side { width: 290px; flex: none; border-left: 1px solid #eef1f5; padding: 12px 14px; background: #fff; }
.side h3 { margin: 4px 0 6px; font-size: 13px; color: #5a6270; }
.reply { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid #eef1f5; background: #fff; align-items: flex-end; }
.reply textarea { flex: 1; height: 62px; }
.reply .btn { margin: 0; height: 38px; }
.reply-ops { display: flex; flex-direction: column; gap: 6px; }
.reply-ops .btn { height: 32px; font-size: 13px; }
.form-ops { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

/* 快捷回复 */
.qr-bar { background: #fff; border: 1px solid #e4e8ee; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.qr-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.qr-head .qr-filter { margin-left: auto; width: 150px; padding: 4px 8px; font-size: 13px; border: 1px solid #d9dde3; border-radius: 8px; }
.qr-list { display: flex; flex-wrap: wrap; gap: 6px; }
.qr-item { background: #f2f6ff; border: 1px solid #d6e4ff; color: #1a4fa0; border-radius: 8px; padding: 5px 10px; font-size: 13px; cursor: pointer; font-family: inherit; }
.qr-item:hover { background: #e6efff; }
.qr-item .qr-share { font-style: normal; font-size: 11px; color: #9aa4b2; margin-left: 4px; }
.l2 .area { color: #8a9099; }

/* 快捷回复列表页 */
table.grid.replies td { vertical-align: top; }

/* 提示框（配置说明） */
.note-box { background: #f4f8ff; border: 1px solid #d6e4ff; border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.note-box code { background: #fff; border: 1px solid #d6e4ff; border-radius: 6px; padding: 2px 8px; word-break: break-all; }

/* 绑定表：窄列不换行（避免“未绑定”被竖排），列宽均衡，仅操作列内的说明可换行 */
table.grid.bindings { table-layout: fixed; }
table.grid.bindings th, table.grid.bindings td { white-space: nowrap; }
table.grid.bindings th:nth-child(1) { width: 18%; }
table.grid.bindings th:nth-child(2) { width: 10%; }
table.grid.bindings th:nth-child(3) { width: 18%; }
table.grid.bindings th:nth-child(4) { width: 14%; }
table.grid.bindings th:nth-child(5) { width: 40%; }
table.grid.bindings td:last-child { white-space: normal; }
table.grid.bindings td:first-child { white-space: normal; }

/* 绑定二维码块 */
.bindbox { margin-top: 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.bindbox .kfqr img { display: block; width: 120px; height: 120px; border: 1px solid #e4e8ee; border-radius: 8px; background: #fff; padding: 4px; }
.bindbox code { font-size: 13px; }

/* 数据库卡片 */
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-stat { background: #fff; border: 1px solid #e4e8ee; border-radius: 10px; padding: 12px 16px; min-width: 170px; }
.card-stat .k { font-size: 12px; color: #8a9099; }
.card-stat .v { font-size: 18px; font-weight: 600; margin-top: 2px; }
.ops { display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid #e4e8ee; border-radius: 10px; padding: 14px 16px; }
.ops .muted { margin-left: 10px; font-size: 12px; }

@media (max-width: 900px) {
    .cols { flex-direction: column; }
    .col-list { width: 100%; }
    .list { max-height: 300px; }
    .detail-body { flex-direction: column; }
    .side { width: 100%; border-left: none; border-top: 1px solid #eef1f5; }
    .chat { max-height: 400px; }
    .f2 { flex-direction: column; gap: 0; }
    .top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
    .top .nav { order: 3; width: 100%; overflow-x: auto; }
}
