/* 祈求客服台 · 后台样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #2f6bff;
  --brand-dark: #1f52d0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1e2430;
  --sub: #7b8494;
  --line: #e8ecf2;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: var(--brand); text-decoration: none; }
a:hover { opacity: .82; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 60;
}

.logo {
  padding: 20px 20px 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo-dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #4d8bff, #2f6bff);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.logo small { display: block; font-size: 10.5px; color: var(--sub); font-weight: 400; letter-spacing: 0; }

.nav { padding: 4px 10px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: #aab1be; padding: 14px 10px 6px; letter-spacing: .5px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 9px;
  color: #4b5563; font-size: 13.5px; margin-bottom: 2px;
  transition: .15s;
}
.nav a:hover { background: #f4f6fa; opacity: 1; }
.nav a.active { background: #eff4ff; color: var(--brand); font-weight: 600; }
.nav a .ic { width: 17px; text-align: center; font-size: 14px; }
.nav a .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10.5px; padding: 1px 6px; border-radius: 20px; font-weight: 600;
}

.side-foot {
  padding: 12px 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--sub);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.side-foot a { color: var(--sub); font-size: 12px; }

.main { flex: 1; margin-left: 208px; min-width: 0; padding: 22px 26px 40px; }

.page-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.page-head .desc { color: var(--sub); font-size: 12.5px; }
.page-head .spacer { flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03);
  border: 1px solid var(--line);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card-tight { padding: 0; overflow: hidden; }
.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px;
}
.card-head .spacer { flex: 1; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.stat .label { color: var(--sub); font-size: 12.5px; margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.stat .value small { font-size: 12px; font-weight: 400; color: var(--sub); margin-left: 4px; }
.stat .ico {
  position: absolute; right: 14px; top: 14px; width: 34px; height: 34px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: #eff4ff; color: var(--brand);
}
.stat.g .ico { background: #ecfdf5; color: var(--ok); }
.stat.o .ico { background: #fff7ed; color: var(--warn); }
.stat.r .ico { background: #fef2f2; color: var(--danger); }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 15px; }
.form-row label { display: block; font-size: 12.5px; color: #4b5563; margin-bottom: 6px; font-weight: 500; }
.form-row .hint { font-size: 11.5px; color: var(--sub); margin-top: 5px; }

input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; font-size: 13.5px;
  border: 1px solid #dfe4ec; border-radius: 9px; background: #fff;
  color: var(--text); outline: none; transition: .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 107, 255, .1); }
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: .15s; font-family: inherit;
}
.btn:hover { background: var(--brand-dark); opacity: 1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: #dfe4ec; color: #4b5563; }
.btn.ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; color: var(--sub); font-weight: 500;
  padding: 11px 16px; background: #fafbfd; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid #f1f4f8; font-size: 13px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfd; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 500;
}
.tag.weibo { background: #fff1f2; color: #e6162d; }
.tag.taobao { background: #fff4ee; color: #ff5000; }
.tag.meituan { background: #fffbeb; color: #b47d00; }
.tag.ok { background: #ecfdf5; color: var(--ok); }
.tag.off { background: #f3f4f6; color: #9ca3af; }
.tag.warn { background: #fff7ed; color: var(--warn); }
.tag.blue { background: #eff4ff; color: var(--brand); }

/* ---------- 对话 ---------- */
.chat-layout { display: flex; gap: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: calc(100vh - 130px); }

.conv-list { width: 300px; flex: 0 0 300px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.conv-search { padding: 12px; border-bottom: 1px solid var(--line); }
.conv-search input { font-size: 13px; }
.conv-items { flex: 1; overflow-y: auto; }

.conv-item { display: flex; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f4f6fa; transition: .12s; }
.conv-item:hover { background: #fafbfd; }
.conv-item.active { background: #eff4ff; }
.conv-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 600;
}
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.conv-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: #a8b0bd; margin-left: auto; flex: 0 0 auto; }
.conv-preview { font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-unread { background: var(--danger); color: #fff; font-size: 10.5px; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; margin-left: auto; }

.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-top { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-top .name { font-weight: 600; font-size: 14px; }
.chat-top .spacer { flex: 1; }

.chat-msgs { flex: 1; overflow-y: auto; padding: 18px; background: #f7f9fc; }
.chat-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #a8b0bd; gap: 8px; font-size: 13px; }

.msg { display: flex; gap: 9px; margin-bottom: 14px; align-items: flex-start; }
.msg.mine { flex-direction: row-reverse; }
.msg .av { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 600; }
.msg .bubble {
  max-width: 62%; padding: 9px 13px; border-radius: 12px;
  background: #fff; font-size: 13.5px; word-break: break-word;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05); white-space: pre-wrap;
}
.msg.mine .bubble { background: var(--brand); color: #fff; }
.msg .bubble img { max-width: 240px; max-height: 300px; width: auto; height: auto; border-radius: 8px; display: block; object-fit: cover; cursor: zoom-in; }
.msg .meta { font-size: 10.5px; color: #a8b0bd; margin-top: 5px; }
.msg.mine .meta { text-align: right; }

.chat-input { border-top: 1px solid var(--line); padding: 10px 14px 12px; background: #fff; }
.chat-tools { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; flex-wrap: wrap; }
.tool-btn {
  border: 1px solid #e8ecf2; background: #fff; border-radius: 8px;
  padding: 4px 10px; font-size: 12px; color: #5b6472; cursor: pointer; font-family: inherit;
}
.tool-btn:hover { background: #f4f6fa; }
.chat-input-row { display: flex; gap: 9px; align-items: flex-end; }
.chat-input-row textarea { flex: 1; min-height: 42px; max-height: 120px; resize: none; border-radius: 10px; }

.quick-panel { display: none; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; }
.quick-panel.show { display: flex; }
.quick-panel span { background: #f4f6fa; border-radius: 7px; padding: 5px 10px; font-size: 12px; cursor: pointer; color: #4b5563; }
.quick-panel span:hover { background: #e8eeff; color: var(--brand); }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #f4f6fa;
  background-image: radial-gradient(circle at 15% 20%, #e0e9ff 0%, transparent 45%), radial-gradient(circle at 85% 80%, #ffe8e8 0%, transparent 45%);
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 380px; background: #fff;
  border-radius: 18px; padding: 34px 30px 28px;
  box-shadow: 0 10px 40px rgba(16, 24, 40, .09);
  border: 1px solid rgba(255, 255, 255, .8);
}
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box .sub { color: var(--sub); font-size: 12.5px; margin-bottom: 24px; }
.login-box .btn { margin-top: 6px; }
.login-err { background: #fef2f2; color: #dc2626; padding: 9px 12px; border-radius: 9px; font-size: 12.5px; margin-bottom: 14px; }

/* ---------- 工具类 ---------- */
.muted { color: var(--sub); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap { gap: 10px; }
.items-center { align-items: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.copy-box { display: flex; gap: 6px; }
.copy-box input { flex: 1; background: #f7f9fc; font-size: 12.5px; }
.empty { text-align: center; padding: 46px 20px; color: #a8b0bd; font-size: 13px; }

/* ---------- 手机端 ---------- */
.mobile-bar { display: none; }


/* 手机端表格：容器横向滚动，页面本身不撑宽 */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  .main, .card, .card-tight { max-width: 100%; }
  .card-tight { overflow: hidden; }
  .card-tight > div[style*="overflow-x"] { overflow-x: auto !important; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .table { min-width: 600px; }
  .table th, .table td { white-space: nowrap; }
  .card { padding: 14px; }
  .copy-box { flex-wrap: wrap; }
  .copy-box input { min-width: 0; }
  .page-head h1 { font-size: 17px; }
  .stats { gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 21px; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: .22s; box-shadow: 0 10px 40px rgba(0,0,0,.12); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 14px 14px 30px; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 50; margin: -14px -14px 14px;
  }
  .mobile-bar button { border: none; background: none; font-size: 20px; cursor: pointer; color: #4b5563; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { height: calc(100vh - 118px); }
  .conv-list { width: 100%; flex: 1; border-right: none; }
  .chat-layout.show-chat .conv-list { display: none; }
  .chat-layout:not(.show-chat) .chat-panel { display: none; }
  .msg .bubble { max-width: 78%; }
  .table th, .table td { padding: 10px; }
}
