/* 客服管理控制台样式：单文件，不引入外部框架，部署零依赖 */

:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #1f2937;
  --soft: #6b7280;
  --primary: #2563eb;
  --primary-soft: #eff4ff;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 骨架 ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.side {
  width: 208px;
  flex: 0 0 208px;
  background: #101728;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .15);
}

.brand strong { display: block; font-size: 14px; color: #fff; }
.brand small  { font-size: 11px; color: #64748b; letter-spacing: .04em; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }

.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #a8b3c7;
  font-size: 13.5px;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.is-active { background: var(--primary); color: #fff; font-weight: 500; }

/* 图标用 CSS 画简单几何形状，避免额外请求字体文件 */
.ico {
  width: 14px; height: 14px;
  border: 1.6px solid currentColor;
  border-radius: 3px;
  opacity: .85;
  flex: 0 0 14px;
}
.ico[data-i="chat"]   { border-radius: 7px 7px 7px 2px; }
.ico[data-i="users"]  { border-radius: 50%; }
.ico[data-i="book"]   { border-left-width: 3px; border-radius: 1px; }
.ico[data-i="tag"]    { border-radius: 2px 7px 7px 2px; transform: rotate(-8deg); }
.ico[data-i="zap"]    { border-radius: 50% 50% 50% 1px; }
.ico[data-i="layers"] { border-radius: 7px 1px 7px 1px; }
.ico[data-i="grid"]   { border-radius: 2px; border-style: dotted; }
/* 质检：星形用旋转两个方块叠出尖角，不引入图标字体 */
.ico[data-i="star"]   { border-radius: 50%; border-style: dashed; transform: scale(.92); }
/* 审计：眼睛——横摆的棱形 */
.ico[data-i="eye"]    { border-radius: 50% 0 50% 0; transform: rotate(45deg); }

.side-foot {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.who strong { display: block; font-size: 13px; color: #fff; }
.who small  { font-size: 11px; color: #64748b; }

.link {
  background: none;
  border: 0;
  color: #94a3b8;
  cursor: pointer;
  font-size: 12.5px;
  padding: 4px 6px;
}
.link:hover { color: #fff; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 20px 24px 40px; }

/* ---------- 提示 ---------- */

.flash {
  margin: 12px 24px 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}
.flash-ok   { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-err  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ---------- 卡片与表格 ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-head h2 { font-size: 14px; margin: 0; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--soft); }
.card-body { padding: 16px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }

table.tbl th {
  text-align: left;
  padding: 10px 14px;
  background: #fafbfd;
  color: var(--soft);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f4f9;
  vertical-align: middle;
}

table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: #fbfcfe; }

.tbl-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--soft);
  font-size: 13px;
}

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.soft { color: var(--soft); }
.nowrap { white-space: nowrap; }
.muted-sm { font-size: 12px; color: var(--soft); }
.wrap { word-break: break-word; white-space: pre-wrap; max-width: 420px; }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.7;
  white-space: nowrap;
}
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-blue   { background: var(--primary-soft); color: #1d4ed8; }
.badge-green  { background: #ecfdf5; color: #047857; }
.badge-amber  { background: #fffbeb; color: #b45309; }
.badge-red    { background: #fef2f2; color: #b91c1c; }

/* ---------- 按钮与表单 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: #c8d3e3; text-decoration: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

form.inline { display: inline; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--soft); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: #9aa4b2; margin-top: 4px; }
.field .req { color: var(--danger); }

input[type="text"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

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

.form-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 14px;
}

.check { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.check input { width: auto; }

/* ---------- 统计卡 ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { font-size: 12px; color: var(--soft); margin-bottom: 6px; }
.stat .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--soft); margin-left: 4px; }

/* ---------- 筛选条 ---------- */

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters .field { margin-bottom: 0; min-width: 130px; }

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

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #334155 100%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 372px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .35);
}

.auth-card h1 { font-size: 18px; margin: 0 0 4px; }
.auth-card .sub { font-size: 12.5px; color: var(--soft); margin-bottom: 20px; }

.auth-err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* ---------- 错误页 ---------- */

.fatal {
  max-width: 620px;
  margin: 60px auto;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 26px;
}
.fatal h1 { font-size: 17px; color: var(--danger); margin: 0 0 10px; }
.fatal pre { background: #f8fafc; border: 1px solid var(--line); padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }
.fatal .path { font-size: 12px; color: var(--soft); margin-top: 10px; }

/* ---------- 详情页 ---------- */

.detail-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 10px; font-size: 13px; }
.kv dt { color: var(--soft); }
.kv dd { margin: 0; word-break: break-word; }

.msg-list { display: flex; flex-direction: column; gap: 10px; }

.msg-row { display: flex; gap: 8px; align-items: flex-start; }
.msg-row.is-right { flex-direction: row-reverse; }

.msg-meta { font-size: 11px; color: var(--soft); margin-bottom: 3px; }
.msg-row.is-right .msg-meta { text-align: right; }

.msg-bubble {
  max-width: 620px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.is-agent .msg-bubble { background: var(--primary-soft); border-color: #dbe4ff; }
.msg-row.is-bot .msg-bubble { background: #f5f3ff; border-color: #e9e5ff; }
.msg-row.is-system { justify-content: center; }
.msg-row.is-system .msg-bubble {
  background: transparent;
  border: 0;
  color: var(--soft);
  font-size: 12px;
  padding: 2px 8px;
}

@media (max-width: 900px) {
  .side { display: none; }
  .content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
