:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #1f2328;
  --text-sub: #6b7280;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --sidebar: #1f2937;
  --sidebar-text: #d1d5db;
  --sidebar-hover: #374151;
  --green: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
  --purple: #7c3aed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 220px; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
}
.logo-title { color: #fff; font-weight: 600; font-size: 15px; }
.logo-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 0 24px; }
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  padding: 8px 16px; font-size: 11px; color: #6b7280;
  letter-spacing: .5px; text-transform: uppercase;
}
.nav-item {
  display: block; padding: 8px 16px 8px 20px; cursor: pointer;
  color: var(--sidebar-text); font-size: 13px; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: var(--sidebar-hover); color: #fff;
  border-left-color: var(--primary); font-weight: 500;
}

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.uid-label { font-size: 12px; color: var(--text-sub); }
select, .btn-refresh {
  height: 30px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 10px; background: #fff; color: var(--text); font-size: 12px; cursor: pointer;
}
.btn-refresh:hover { border-color: var(--primary); color: var(--primary); }
.btn-mini {
  height: 26px; border: 1px solid var(--primary); border-radius: 6px;
  padding: 0 14px; background: var(--primary); color: #fff; font-size: 12px; cursor: pointer;
}
.btn-mini:hover { opacity: .88; }
.mock-badge {
  background: #fef3c7; color: #92400e; font-size: 11px;
  padding: 3px 8px; border-radius: 4px; font-weight: 500;
}

/* 顶栏：系统管理员身份（替代原「当前用户」切换） */
.admin-identity {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border: 1px solid var(--border);
  border-radius: 20px; background: #f5f8ff;
}
.admin-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.admin-meta { display: flex; flex-direction: column; line-height: 1.25; }
.admin-name { font-size: 12px; color: var(--text); font-weight: 600; }
.admin-sub { font-size: 10px; color: var(--text-sub); }

.content { flex: 1; overflow: auto; padding: 20px; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.card-label { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.card-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.card-extra { font-size: 11px; color: var(--text-sub); margin-top: 6px; }
.card.blue .card-value { color: var(--primary); }
.card.green .card-value { color: var(--green); }
.card.orange .card-value { color: var(--orange); }
.card.purple .card-value { color: var(--purple); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center;
}
.panel-body { padding: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 9px 12px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
th { background: #f9fafb; color: var(--text-sub); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: #f9fafb; }
td.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
}
.tag-pending  { background: #fef3c7; color: #92400e; }
.tag-paid     { background: #dbeafe; color: #1e40af; }
.tag-doing    { background: #e0e7ff; color: #4338ca; }
.tag-finished { background: #dcfce7; color: #166534; }
.tag-canceled { background: #f3f4f6; color: #6b7280; }
.tag-complaining { background: #fee2e2; color: #991b1b; }
.tag-approved { background: #dcfce7; color: #166534; }
.tag-rejected { background: #fee2e2; color: #991b1b; }
.tag-enterprise { background: #ede9fe; color: #5b21b6; }
.tag-micro { background: #fce7f3; color: #9d174d; }

/* ---------- 待办 ---------- */
.todo-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px dashed var(--border);
}
.todo-item:last-child { border-bottom: none; }
.todo-title { font-size: 13px; }
.todo-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-sub); }
.todo-count {
  background: var(--primary-soft); color: var(--primary);
  padding: 2px 9px; border-radius: 10px; font-weight: 600; min-width: 30px; text-align: center;
}
.todo-count.zero { background: #f3f4f6; color: #9ca3af; }

/* ---------- 图表 ---------- */
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-sub); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* ---------- 其他 ---------- */
.empty { padding: 40px; text-align: center; color: var(--text-sub); font-size: 13px; }
.hint { font-size: 12px; color: var(--text-sub); margin-bottom: 12px; line-height: 1.7; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2328; color: #fff; padding: 10px 20px; border-radius: 6px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- 登录弹窗 ---------- */
.login-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.55);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.login-box {
  width: 320px; background: #fff; border-radius: 14px; padding: 30px 26px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2); text-align: center;
}
.login-title { font-size: 19px; font-weight: 700; color: var(--text); }
.login-sub { font-size: 12px; color: var(--text-sub); margin: 6px 0 20px; }
.login-input {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 14px; font-size: 14px; margin-bottom: 12px; outline: none;
}
.login-input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%; height: 42px; border: none; border-radius: 8px; background: var(--primary);
  color: #fff; font-size: 15px; cursor: pointer; margin-top: 4px;
}
.login-btn:hover { background: #1d4ed8; }
.login-hint { font-size: 12px; color: var(--text-sub); margin-top: 14px; }

/* ---------- 客服中心 ---------- */
.cs-wrap { display: flex; gap: 16px; height: calc(100vh - 160px); }
.cs-list {
  width: 280px; flex-shrink: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; overflow-y: auto; padding: 8px;
}
.cs-item { padding: 12px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid #f0f1f3; }
.cs-item:hover { background: #f7f8fa; }
.cs-item.active { background: var(--primary-soft); }
.cs-item-top { display: flex; justify-content: space-between; align-items: center; }
.cs-name { font-weight: 600; font-size: 14px; }
.cs-item-last { font-size: 12px; color: var(--text-sub); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-unread { background: var(--red); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; }
.cs-main { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.cs-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-sub); font-size: 13px; }
.cs-chat { display: flex; flex-direction: column; height: 100%; }
.cs-head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.cs-body { flex: 1; overflow-y: auto; padding: 18px; background: #f7f8fa; }
.cs-msg { display: flex; flex-direction: column; margin-bottom: 14px; max-width: 70%; }
.cs-msg.left { align-items: flex-start; }
.cs-msg.right { align-items: flex-end; margin-left: auto; }
.cs-bubble { padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.5; word-break: break-all; }
.cs-bubble.peer { background: #fff; border: 1px solid var(--border); }
.cs-bubble.mine { background: var(--primary); color: #fff; }
.cs-time { font-size: 11px; color: #b0b4bb; margin-top: 4px; }
.cs-input { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); }
.cs-input input { flex: 1; height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; outline: none; }
.cs-input input:focus { border-color: var(--primary); }

/* ---------- 小工具 ---------- */
.mut { color: var(--text-sub); font-size: 12px; }
.btn-mini.ok { background: var(--green); }
.btn-mini.bad { background: var(--red); }

/* 超级管理员专属入口（普通客服不可见） */
.super-only { display: none; }
body.is-super .super-only { display: block; }

/* 用户与商户总览弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.modal {
  background: #fff; border-radius: 14px; width: min(860px, 96vw);
  max-height: 86vh; overflow: auto; padding: 24px 28px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--text-sub); font-size: 22px; line-height: 1; padding: 4px 10px; }
.modal-close:hover { color: var(--red); }
.kv { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 12px 0; }
.kv .k { color: var(--text-sub); }
.kv .v { font-weight: 600; }
.credit-two { display: flex; gap: 16px; margin: 12px 0; }
.credit-card { flex: 1; border: 1rpx solid var(--border); border-radius: 10px; padding: 14px 16px; }
.credit-card .ct { color: var(--text-sub); font-size: 12px; }
.credit-card .cs { font-size: 26px; font-weight: 700; }

/* ---------- 商城：商品表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.two { flex-direction: row; gap: 16px; }
.form-row.two > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; color: var(--text-sub); }
.form-input {
  height: 38px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 12px; font-size: 14px; outline: none; background: #fff; color: var(--text);
}
.form-input:focus { border-color: var(--primary); }
.form-textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-size: 14px; outline: none; min-height: 90px; resize: vertical; background: #fff; color: var(--text);
}
.form-textarea:focus { border-color: var(--primary); }
.form-actions { display: flex; gap: 12px; margin-top: 4px; }
.img-thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.img-thumb {
  position: relative; width: 72px; height: 72px; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; background: #f3f4f6;
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-del {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  background: rgba(0,0,0,.6); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; line-height: 1;
}
.img-del:hover { background: var(--red); }
