:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d1f26;
  --ink-2: #4b4e57;
  --muted: #868a94;
  --line: #e9ebf0;
  --accent: #fe2c55;
  --accent-soft: #fff0f3;
  --ok: #12a05c;
  --ok-soft: #eaf8f0;
  --warn: #c2760a;
  --warn-soft: #fff6e8;
  --err: #d92d20;
  --err-soft: #fdecea;
  --info: #2c6ecb;
  --info-soft: #eef4fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 30, .04), 0 4px 14px rgba(20, 22, 30, .04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 13px; }

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

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px 18px;
  font-weight: 700; letter-spacing: -.2px; font-size: 15px;
}
.brand i {
  width: 26px; height: 26px; border-radius: 8px; background: var(--accent);
  display: inline-block; position: relative;
}
.brand i::after {
  content: ""; position: absolute; inset: 8px 7px; background: #fff; border-radius: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 8px; color: var(--ink-2);
  font-size: 13.5px; cursor: pointer; transition: background .12s, color .12s;
}
.nav-item:hover { background: #f4f5f7; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ic { width: 16px; text-align: center; opacity: .75; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 11px; color: var(--muted); padding: 8px 11px; }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.page-head h2 { font-size: 19px; margin: 0; letter-spacing: -.3px; }
.page-head p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------- 卡片/网格 ---------- */
.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .hd {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600;
}
.card .hd .sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.card .bd { padding: 16px; }

.stat { padding: 15px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .num { font-size: 26px; font-weight: 700; letter-spacing: -.6px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .num small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfbfc;
}
td { padding: 11px 12px; border-bottom: 1px solid #f1f2f5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: default; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #fafbfc; }
.num-cell { font-variant-numeric: tabular-nums; }

/* ---------- 徽标 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; line-height: 1.7;
  background: #f2f3f5; color: var(--ink-2); white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #c9cbd2; display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(18,160,92,.14); }
.dot.off { background: #c9cbd2; }
.dot.bad { background: var(--err); box-shadow: 0 0 0 3px rgba(217,45,32,.12); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.input, .select, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: var(--ink); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(254,44,85,.08);
}
textarea.input { resize: vertical; min-height: 76px; line-height: 1.7; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline > .field { margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.04); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 抽屉 ---------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(17,19,26,.28);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 40;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 520px; max-width: 94vw;
  background: #fff; box-shadow: -8px 0 30px rgba(20,22,30,.12);
  transform: translateX(102%); transition: transform .22s cubic-bezier(.3,.8,.3,1);
  z-index: 41; display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer .hd { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer .hd h3 { margin: 0; font-size: 15px; flex: 1; }
.drawer .bd { flex: 1; overflow: auto; padding: 16px 18px; }
.drawer .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- 聊天 ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }
.bubble { max-width: 82%; padding: 8px 11px; border-radius: 10px; font-size: 13px; line-height: 1.65; word-break: break-word; position: relative; }
.bubble.in { align-self: flex-start; background: #f2f3f5; color: var(--ink); border-top-left-radius: 3px; }
.bubble.out { align-self: flex-end; background: var(--accent); color: #fff; border-top-right-radius: 3px; }
.bubble .t { display: block; font-size: 10.5px; opacity: .6; margin-top: 3px; }
.bubble.out .t { text-align: right; }

/* ---------- 其他 ---------- */
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  background: #1d1f26; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

.log-list { font: 12px/1.9 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }
.log-list .row { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px dashed #f2f3f5; }
.log-list .row:last-child { border-bottom: 0; }
.log-list .tm { color: var(--muted); flex: 0 0 78px; }
.log-list .lv { flex: 0 0 44px; font-size: 11px; }
.lv.info { color: var(--info); }
.lv.warn { color: var(--warn); }
.lv.error { color: var(--err); }

.funnel { display: flex; gap: 8px; align-items: flex-end; height: 92px; }
.funnel .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.funnel .bar .fill { width: 100%; background: linear-gradient(180deg, #ff6b85, var(--accent)); border-radius: 5px 5px 0 0; min-height: 3px; }
.funnel .bar .cap { font-size: 11px; color: var(--muted); white-space: nowrap; }
.funnel .bar .v { font-size: 12px; font-weight: 600; }

.split { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }
@media (max-width: 1180px) { .split { grid-template-columns: 1fr; } }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13px; border-bottom: 1px dashed #f2f3f5; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 500; text-align: right; }

.phone { font-family: ui-monospace, Menlo, monospace; font-weight: 600; color: var(--ok); letter-spacing: .3px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs .tab { padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.shots img { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: 8px; }
