:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8eb;
  --text: #1f2329;
  --muted: #8a9099;
  --primary: #2f6bff;
  --primary-d: #255ad6;
  --ok: #1aa06d;
  --warn: #d9822b;
  --err: #d92d20;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--err); margin-top: 10px; min-height: 18px; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 36px; width: 360px; box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card input { width: 100%; padding: 10px 12px; margin: 18px 0 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }

/* 布局 */
.app { display: flex; height: 100vh; }
.side { width: 200px; background: #1f2329; color: #cfd3da; display: flex; flex-direction: column; padding: 18px 12px; }
.brand { font-weight: 700; color: #fff; font-size: 16px; padding: 6px 10px 18px; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
nav a { color: #cfd3da; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
nav a:hover { background: #2b3138; }
nav a.active { background: var(--primary); color: #fff; }
.main { flex: 1; overflow-y: auto; padding: 24px 28px; }
.main h2 { margin: 0 0 4px; font-size: 20px; }

/* 卡片/网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin: 18px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card .num { font-size: 28px; font-weight: 700; }
.card .lbl { color: var(--muted); margin-top: 4px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input.t, textarea.t, select.t { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--text); min-width: 220px; }
textarea.t { min-height: 72px; width: 100%; }

/* 按钮 */
.btn { border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; background: #eceef1; color: var(--text); }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 表格 */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { background: #fafbfc; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; background: #eef2ff; color: var(--primary); border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 1px; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.pill.ok { background: #e6f5ee; color: var(--ok); }
.pill.warn { background: #fbf0e2; color: var(--warn); }
.pill.err { background: #fbe9e7; color: var(--err); }

/* 简易条形图 */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.bar-label { width: 120px; color: var(--muted); font-size: 13px; }
.bar-track { flex: 1; background: #eef0f3; border-radius: 6px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); }
.bar-val { width: 48px; text-align: right; font-size: 13px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #1f2329; color: #fff; padding: 12px 16px; border-radius: 8px; opacity: .95; z-index: 99; }

/* AI 客服 */
.cs-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-top: 12px; }
.cs-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-height: 70vh; overflow-y: auto; }
.cs-item { padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cs-item:hover { background: #f7f8fa; }
.cs-item.active { background: #eef2ff; }
.cs-name { font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cs-last { color: var(--muted); font-size: 12px; margin-top: 4px; }
.cs-detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.cs-prof { padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.cs-thread { max-height: 40vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bub { max-width: 72%; padding: 8px 12px; border-radius: 10px; }
.bub .bub-t { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bub.cust { background: #f0f2f5; align-self: flex-start; }
.bub.me { background: var(--primary); color: #fff; align-self: flex-end; }
.bub.me .bub-t { color: rgba(255,255,255,.7); }
.bub.draft { background: #fff7e6; align-self: flex-end; }
.bub.sys { background: transparent; color: var(--muted); align-self: center; font-size: 12px; }
