/* ===================================================================
   wa-desk · 客服工作台样式
   =================================================================== */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f1f3f9;
  --line: #e6e9f1;
  --line-2: #d9dee9;
  --text: #101828;
  --text-2: #475467;
  --muted: #8a94a6;
  --brand: #2f5bea;
  --brand-2: #1e40c4;
  --brand-weak: #ebf0ff;
  --green: #0f8a4f;
  --green-weak: #e6f6ed;
  --amber: #a85a06;
  --amber-weak: #fdf2e2;
  --red: #bd3a30;
  --red-weak: #fdecea;
  --violet: #6d3bd4;
  --violet-weak: #f1ebfd;
  --rail: #0c1526;
  --rail-2: #16213a;
  --rail-text: #aab4c9;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 16px 32px -20px rgba(16, 24, 40, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ------------------------------ 通用控件 ------------------------------ */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px; font-weight: 550;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(47, 91, 234, .3); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--red); border-color: #f2cfcb; background: #fff; }
.btn.danger:hover { background: var(--red-weak); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.on-dark { color: #8e9cb8; }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=tel], .field input[type=date], .field input[type=datetime-local],
.field select, .field textarea, .search, .select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.6; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus,
.search:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 91, 234, .12);
}
.search { height: 34px; font-size: 13px; }
.select { height: 32px; font-size: 13px; padding: 0 8px; cursor: pointer; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--brand); }

.avatar {
  flex: none;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--av, var(--brand));
  color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  user-select: none;
}
.avatar.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; border-radius: 13px; font-size: 15px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.badge.xs { height: 19px; padding: 0 7px; font-size: 11px; }
.badge.blue { background: var(--brand-weak); color: var(--brand-2); }
.badge.green { background: var(--green-weak); color: var(--green); }
.badge.amber { background: var(--amber-weak); color: var(--amber); }
.badge.red { background: var(--red-weak); color: var(--red); }
.badge.violet { background: var(--violet-weak); color: var(--violet); }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }
.badge.outline { background: #fff; border: 1px solid var(--line-2); color: var(--text-2); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag {
  display: inline-flex; align-items: center;
  height: 21px; padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 11px; font-weight: 500;
}

/* ------------------------------ 登录页 ------------------------------ */

.auth {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  height: 100vh;
}
.auth-brand {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  padding: 64px clamp(40px, 6vw, 96px);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(47, 91, 234, .35) 0%, rgba(12, 21, 38, 0) 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(14, 116, 144, .28) 0%, rgba(12, 21, 38, 0) 60%),
    var(--rail);
  color: #fff;
  overflow: hidden;
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(80% 70% at 30% 40%, #000 20%, transparent 100%);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }
.brand-mark {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(150deg, #4a74ff, #1b3fb8);
  box-shadow: 0 10px 30px -8px rgba(47, 91, 234, .8);
  margin-bottom: 22px;
}
.brand-mark svg { width: 28px; height: 28px; color: #fff; }
.auth-brand h1 { font-size: 40px; letter-spacing: -.03em; font-weight: 750; }
.brand-sub { margin-top: 8px; font-size: 15px; color: #b9c5dc; }
.brand-list { margin-top: 40px; display: flex; flex-direction: column; gap: 16px; max-width: 420px; }
.brand-list li {
  padding-left: 18px; position: relative;
  font-size: 13.5px; color: #d3dcea; line-height: 1.5;
}
.brand-list li b { display: block; color: #fff; font-size: 14px; margin-bottom: 2px; }
.brand-list li::before {
  content: ""; position: absolute; left: 0; top: 8px;
  width: 6px; height: 6px; border-radius: 2px; background: #4a74ff;
}
.brand-foot { margin-top: 44px; font-size: 12px; color: #6f7f9c; }

.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 372px; }
.auth-card h2 { font-size: 23px; letter-spacing: -.02em; }
.auth-desc { margin: 6px 0 26px; font-size: 13.5px; color: var(--muted); }
.auth-card .btn { height: 42px; margin-top: 4px; }
.auth-note {
  margin-top: 18px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12.5px; color: var(--text-2); line-height: 1.6;
}
.auth-note code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #fff; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }
.auth-error { margin-bottom: 14px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--red-weak); color: var(--red); font-size: 13px; }

/* ------------------------------ 主框架 ------------------------------ */

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100vh; overflow: hidden; }

.rail {
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  background: var(--rail);
  color: var(--rail-text);
}
.rail-logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.rail-logo-mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #4a74ff, #1b3fb8);
  color: #fff;
}
.rail-logo-mark svg { width: 18px; height: 18px; }
.rail-logo-text { display: flex; flex-direction: column; line-height: 1.2; color: #fff; font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; }
.rail-logo-text small { font-size: 10.5px; font-weight: 500; color: #7d8aa5; letter-spacing: .02em; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; overflow-y: auto; }
.nav-group { padding: 16px 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: #5c6b87; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--rail-text);
  font-size: 13.5px; font-weight: 500;
  text-align: left; width: 100%;
  transition: background .14s, color .14s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #e6ecf7; }
.nav-item.active { background: rgba(74, 116, 255, .16); color: #fff; box-shadow: inset 0 0 0 1px rgba(74, 116, 255, .28); }
.nav-item.active svg { opacity: 1; color: #7d9bff; }
.nav-badge {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 999px; background: #2f5bea; color: #fff;
  font-size: 10.5px; font-weight: 700;
}
.nav-badge.soft { background: rgba(255, 255, 255, .12); color: #cfd8e8; }

.rail-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; gap: 8px; }
.rail-user { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; padding: 4px; }
.rail-user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.rail-user-meta b { font-size: 12.8px; color: #eaf0fa; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-user-meta small { font-size: 10.5px; color: #7d8aa5; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: 66px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-title h2 { font-size: 17px; font-weight: 680; letter-spacing: -.015em; }
.topbar-title p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.wa-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px; color: var(--text-2); font-weight: 550;
}
.wa-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.wa-pill.on .dot { background: #17b26a; box-shadow: 0 0 0 3px rgba(23, 178, 106, .16); }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: 999px; background: var(--green-weak);
  color: var(--green); font-size: 11.5px; font-weight: 650;
}
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.8s infinite; }
.live-pill.off { background: var(--surface-3); color: var(--muted); }
.live-pill.off i { animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.view { flex: 1; min-height: 0; overflow: auto; padding: 22px 24px 30px; }
.view.view-inbox { padding: 0; overflow: hidden; display: flex; }
.view.view-inbox .inbox { flex: 1; min-height: 0; }

/* ------------------------------ 页面通用 ------------------------------ */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h3 { font-size: 15px; font-weight: 680; }
.page-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.head-actions { display: flex; align-items: center; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 13.8px; font-weight: 660; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 8px 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  padding: 14px 15px 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 3px;
  text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.stat:hover { border-color: #c9d4ee; box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat-label i { width: 6px; height: 6px; border-radius: 50%; background: var(--tone, var(--brand)); }
.stat-value { font-size: 26px; font-weight: 720; letter-spacing: -.03em; line-height: 1.15; margin-top: 4px; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-hint { font-size: 11.5px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ------------------------------ 表格 ------------------------------ */

.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .03em;
  color: var(--muted); text-transform: uppercase;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fbfcfe; }
table.data .cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
table.data .txt { display: flex; flex-direction: column; min-width: 0; }
table.data .txt b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
table.data .txt small { font-size: 11.5px; color: var(--muted); }
table.data .actions { display: flex; gap: 6px; justify-content: flex-end; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.load-bar { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; width: 84px; }
.load-bar i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }

/* ------------------------------ 会话工作台 ------------------------------ */

.inbox { display: grid; grid-template-columns: 328px minmax(0, 1fr) 312px; height: 100%; }
.col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list-col { background: var(--surface); border-right: 1px solid var(--line); }
.thread-col { background: var(--surface); border-right: 1px solid var(--line); }
.side-col { background: var(--surface-2); overflow-y: auto; padding: 14px; gap: 12px; }

.col-head { flex: none; padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 9px; }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 9px; }
.seg-btn {
  flex: 1; height: 27px; padding: 0 8px;
  border: 0; border-radius: 7px; background: transparent;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  transition: background .14s, color .14s, box-shadow .14s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--brand-2); box-shadow: var(--shadow-sm); }

.conv-list { flex: 1; overflow-y: auto; overflow-x: hidden; }
.conv-item {
  display: flex; gap: 10px; width: 100%;
  padding: 12px; border: 0; border-bottom: 1px solid #f1f3f9;
  background: transparent; text-align: left;
  transition: background .12s;
  position: relative;
}
.conv-item:hover { background: #fafbfe; }
.conv-item.active { background: var(--brand-weak); }
.conv-item.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.conv-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.conv-top { display: flex; align-items: center; gap: 8px; }
.conv-top b { font-size: 13.2px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-top time { margin-left: auto; font-size: 10.5px; color: var(--muted); flex: none; }
.conv-subject { font-size: 11.8px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.unread-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px; background: var(--brand); color: #fff;
  font-size: 10.5px; font-weight: 700;
}
.conv-item.unread .conv-top b { color: var(--text); }
.conv-item.unread .conv-preview { color: var(--text-2); font-weight: 500; }

.thread-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.thread-id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.thread-id h3 { font-size: 14.5px; font-weight: 660; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-id p { font-size: 11.8px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.messages { flex: 1; overflow-y: auto; padding: 18px 20px 8px; display: flex; flex-direction: column; gap: 3px; background: linear-gradient(#fcfdff, #fafbfe 40%, #f8fafd); }
.msg-row { display: flex; flex-direction: column; max-width: 74%; gap: 3px; margin-bottom: 10px; }
.msg-row.outbound { align-self: flex-end; align-items: flex-end; }
.msg-row.inbound { align-self: flex-start; align-items: flex-start; }
.msg { padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg-row.inbound .msg { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: var(--shadow-sm); }
.msg-row.outbound .msg { background: var(--brand); color: #fff; border-bottom-right-radius: 5px; box-shadow: 0 2px 8px -3px rgba(47, 91, 234, .5); }
.msg-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); padding: 0 3px; }
.msg-status.pending { color: var(--muted); }
.msg-status.sent { color: var(--muted); }
.msg-status.delivered { color: var(--text-2); }
.msg-status.read { color: var(--brand); font-weight: 600; }
.msg-status.failed { color: var(--red); font-weight: 600; }

.day-divider { align-self: center; margin: 10px 0 12px; padding: 2px 10px; border-radius: 999px; background: rgba(16, 24, 40, .06); color: var(--muted); font-size: 10.5px; font-weight: 600; }

.composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea {
  flex: 1; min-height: 38px; max-height: 132px; resize: none;
  padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 11px;
  background: var(--surface-2); outline: none; font-size: 13.5px; line-height: 1.5;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.composer textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(47, 91, 234, .1); }
.composer .btn { height: 38px; border-radius: 11px; padding: 0 18px; }
.notice-bar { flex: none; padding: 11px 16px; border-top: 1px solid var(--line); background: var(--amber-weak); color: var(--amber); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }

.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; }
.side-card h4 { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.side-card h5 { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.profile-head { display: flex; align-items: center; gap: 10px; }
.profile-head b { display: block; font-size: 13.5px; }
.profile-head small { color: var(--muted); font-size: 11.5px; }
.kv { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.kv > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.3px; }
.kv dt { color: var(--muted); flex: none; }
.kv dd { text-align: right; color: var(--text); font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.assign-block { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.assign-block .who { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.assign-block .who b { font-size: 12.8px; font-weight: 620; }
.assign-block .who small { font-size: 11px; color: var(--muted); }
.side-actions { display: flex; gap: 6px; margin-top: 10px; }
.side-actions .btn { flex: 1; justify-content: center; }

.timeline { display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 0 0 12px 16px; font-size: 12.3px; color: var(--text-2); }
.timeline li::before { content: ""; position: absolute; left: 1px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); }
.timeline li::after { content: ""; position: absolute; left: 3.5px; top: 13px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline li.accent::before { background: var(--brand); }
.timeline li .t-line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.timeline li b { color: var(--text); font-weight: 600; }
.timeline li time { color: var(--muted); font-size: 10.5px; margin-left: auto; }
.timeline li p { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.timeline.sm li { font-size: 11.8px; padding-bottom: 10px; }

/* ------------------------------ 分配看板 ------------------------------ */

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { width: 240px; }
.toolbar .select { width: auto; min-width: 128px; }
.toolbar .seg { flex: none; }
.toolbar .seg .seg-btn { flex: none; padding: 0 12px; }
.bulkbar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin-bottom: 12px;
  border: 1px solid #c9d8ff; border-radius: 10px;
  background: var(--brand-weak); color: var(--brand-2); font-size: 12.8px; font-weight: 550;
}
.row-check { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.8px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 3px; }

/* ------------------------------ 成员 / 账号卡片 ------------------------------ */

.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.member-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; }
.member-top { display: flex; align-items: center; gap: 11px; }
.member-top .who { min-width: 0; flex: 1; }
.member-top .who b { display: block; font-size: 14px; font-weight: 650; }
.member-top .who small { font-size: 11.8px; color: var(--muted); }
.member-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.member-stats div { padding: 8px 9px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.member-stats span { display: block; font-size: 10.5px; color: var(--muted); }
.member-stats b { font-size: 15px; font-weight: 680; font-variant-numeric: tabular-nums; }
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.member-foot { display: flex; gap: 6px; margin-top: auto; }

.wa-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 13px; }
.wa-top { display: flex; align-items: flex-start; gap: 11px; }
.wa-top .who { flex: 1; min-width: 0; }
.wa-top .who b { display: block; font-size: 14px; font-weight: 650; }
.wa-top .who small { font-size: 11.8px; color: var(--muted); }
.wa-webhook { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border: 1px dashed var(--line-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.2px; color: var(--text-2); overflow: hidden; }
.wa-webhook span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ------------------------------ 弹窗 ------------------------------ */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(12, 21, 38, .48);
  backdrop-filter: blur(3px);
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 30px 70px -20px rgba(12, 21, 38, .5);
  animation: rise .18s cubic-bezier(.2, .8, .3, 1);
  overflow: hidden;
}
@keyframes rise { from { transform: translateY(12px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; font-weight: 680; letter-spacing: -.01em; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.step { flex: 1; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: center; }
.step.done { background: var(--brand-weak); border-color: #c9d8ff; color: var(--brand-2); }

.agent-picker { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.agent-option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; background: var(--surface);
  transition: border-color .14s, background .14s;
}
.agent-option:hover { border-color: #c3cfea; background: #fbfcff; }
.agent-option:has(input:checked) { border-color: var(--brand); background: var(--brand-weak); box-shadow: 0 0 0 1px var(--brand); }
.agent-option input { accent-color: var(--brand); }
.agent-option .agent-meta { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.agent-option .agent-meta b { font-size: 13px; font-weight: 620; }
.agent-option .agent-meta small { font-size: 11.2px; color: var(--muted); }

.preview-box { margin-top: 14px; padding: 13px 14px; border: 1px dashed var(--line-2); border-radius: 11px; background: var(--surface-2); font-size: 12.5px; color: var(--text-2); }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 14px; }
.preview-grid > div { display: flex; flex-direction: column; gap: 1px; }
.preview-grid span { font-size: 10.8px; color: var(--muted); }
.preview-grid b { font-size: 12.8px; font-weight: 620; color: var(--text); }
.warn-list { margin: 11px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.warn-list li { position: relative; padding-left: 15px; font-size: 11.8px; color: var(--amber); }
.warn-list li::before { content: "!"; position: absolute; left: 0; top: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--amber); color: #fff; font-size: 8px; font-weight: 800; display: grid; place-items: center; margin-top: 3px; }
.preview-box details { margin-top: 10px; }
.preview-box summary { cursor: pointer; font-size: 11.8px; color: var(--brand-2); font-weight: 600; }
.affected { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; max-height: 130px; overflow-y: auto; }
.affected li { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--text-2); padding: 3px 0; border-bottom: 1px dashed var(--line); }
.affected li span { color: var(--muted); white-space: nowrap; }

.perm-group { margin-bottom: 14px; }
.perm-group > h5 { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; }
.perm-row:hover { background: var(--surface-2); }
.perm-row .txt { flex: 1; min-width: 0; }
.perm-row .txt b { display: block; font-size: 12.8px; font-weight: 600; }
.perm-row .txt small { font-size: 11.2px; color: var(--muted); }
.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .18s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, .3); transition: transform .18s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(17px); }
.switch input:disabled + i { opacity: .5; }

/* ------------------------------ Toast / 空状态 ------------------------------ */

.toast-root { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  min-width: 220px; max-width: 380px;
  padding: 11px 14px;
  border-radius: 10px;
  background: #101828; color: #fff;
  font-size: 13px; line-height: 1.5;
  box-shadow: 0 16px 36px -12px rgba(12, 21, 38, .55);
  animation: toastIn .2s ease-out;
  display: flex; gap: 8px; align-items: flex-start;
}
.toast.ok { background: #0d3b2e; }
.toast.err { background: #4a1714; }
.toast.out { animation: toastOut .2s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; opacity: .4; }
.empty b { font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.empty p { font-size: 12.3px; max-width: 280px; }
.empty-lg { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 100%; color: var(--muted); font-size: 13px; }
.empty-lg svg { width: 42px; height: 42px; opacity: .25; }

.skeleton { color: var(--muted); font-size: 12.5px; }

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 1440px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr) 280px; }
}
@media (max-width: 1120px) {
  .inbox { grid-template-columns: 290px minmax(0, 1fr); }
  .side-col { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .rail-logo-text, .nav-item span.label, .rail-user-meta, .nav-group { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .rail { align-items: center; }
  .rail-logo { padding: 4px 0 16px; }
  .inbox { grid-template-columns: 1fr; }
  .list-col { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view { padding: 16px; }
}
