/* ============================================================
   卡密自动发货系统 - 后台样式（彩绘现代版，无外部依赖）
   ============================================================ */
:root {
  --primary: #6366f1;
  --primary2: #8b5cf6;
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --grad-soft: linear-gradient(135deg, #eef2ff, #f5f3ff);
  --bg: #f3f4fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #8a93a6;
  --border: #e7e9f2;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(99, 102, 241, .06);
  --shadow-hover: 0 8px 24px rgba(99, 102, 241, .14);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
.hidden { display: none !important; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex: none;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 45%, #4c1d95 100%);
  color: #c7d2fe; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; font-size: 16px; font-weight: 800; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-size: 16px; box-shadow: 0 4px 12px rgba(139,92,246,.45);
}
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 4px;
  color: #c7d2fe; font-size: 14px; border-radius: 10px;
  transition: all .18s ease;
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav a.active {
  background: var(--grad); color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px rgba(139,92,246,.45);
}
.menu-ico { width: 20px; text-align: center; font-size: 15px; flex: none; }
.side-foot {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
}
.admin-chip {
  background: rgba(255,255,255,.12); padding: 5px 10px; border-radius: 20px; color: #fff;
}
.side-foot .logout { color: #fda4af; font-weight: 600; }
.main { flex: 1; padding: 22px 26px 46px; min-width: 0; }
.page-head { margin-bottom: 18px; }
.page-head h1 {
  font-size: 20px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.page-body { display: flex; flex-direction: column; gap: 16px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
  border: 1px solid rgba(231,233,242,.6);
  transition: box-shadow .2s ease;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ''; width: 4px; height: 16px; border-radius: 3px; background: var(--grad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- 统计卡（彩色渐变） ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  border-radius: var(--radius); padding: 18px 16px; color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); position: relative; overflow: hidden;
}
.stat::after { content: ''; position: absolute; right: -18px; top: -18px; width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,.16); }
.stat-num { font-size: 24px; font-weight: 800; text-shadow: 0 1px 3px rgba(0,0,0,.15); }
.stat-label { font-size: 12px; opacity: .92; margin-top: 4px; }
.stat.c1 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat.c2 { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.stat.c3 { background: linear-gradient(135deg, #f59e0b, #f97316); }
.stat.c4 { background: linear-gradient(135deg, #10b981, #059669); }
.stat.c5 { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.stat.c6 { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.stat.c7 { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid #eef0f6; vertical-align: top; }
th {
  background: var(--grad-soft); font-weight: 700; color: #4c3d99;
}
th:first-child { border-radius: 10px 0 0 10px; }
th:last-child { border-radius: 0 10px 10px 0; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: #f8f8ff; }
.strong { font-weight: 700; }
.dim { color: var(--muted); }
.mono { font-family: Consolas, Menlo, monospace; }
.intro-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 彩色标签 ---------- */
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; white-space: nowrap; color: #fff; }
.tag-green { background: linear-gradient(135deg, #10b981, #059669); }
.tag-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.tag-red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.tag-gray { background: linear-gradient(135deg, #9ca3af, #6b7280); }
.tag-orange { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.tag-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.tag-pink { background: linear-gradient(135deg, #ec4899, #db2777); }
.warn-text { color: #ef4444; font-weight: 700; }
.num-plus { color: #059669; font-weight: 600; }
.num-minus { color: #ef4444; font-weight: 600; }

/* ---------- 消息 ---------- */
.msg-line { padding: 11px 16px; border-radius: 10px; margin-bottom: 4px; font-size: 13.5px; }
.msg-line.ok { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.msg-line.err { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
.stat-line { margin-top: 10px; color: #4b5563; }
.stat-line strong { font-size: 15px; }

/* ---------- 表单 ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.form-item { flex: 1; min-width: 130px; }
.form-item.full { flex: 100%; }
.form-item label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 6px; font-weight: 600; }
.form-item input[type=text], .form-item input[type=number], .form-item input[type=password],
.form-item select, .form-item textarea,
.inline-form input[type=text], .inline-form select, .filter-form input, .filter-form select {
  width: 100%; padding: 9px 12px; border: 1.5px solid #e2e5f0; border-radius: 10px;
  font-size: 14px; outline: none; background: #fff; transition: border .15s, box-shadow .15s;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus,
.inline-form input:focus, .filter-form input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.form-item textarea { resize: vertical; font-family: Consolas, Menlo, monospace; }
.check-inline { display: inline-flex !important; align-items: center; gap: 6px; padding-top: 8px; color: var(--text) !important; font-size: 14px !important; }
.inline-form, .filter-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.inline-form input[type=text], .inline-form select { width: auto; min-width: 140px; }
.filter-form input[type=text], .filter-form select, .filter-form input[type=date] { width: auto; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: 0; background: var(--grad); color: #fff;
  padding: 9px 22px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(99,102,241,.3); transition: all .18s ease; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99,102,241,.4); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); box-shadow: none; }
.btn-ghost:hover { background: #f5f3ff; box-shadow: none; }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 4px 12px rgba(239,68,68,.3); }
.btn-danger:hover { box-shadow: 0 6px 16px rgba(239,68,68,.4); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 4px 12px rgba(16,185,129,.3); }
.btn-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); box-shadow: 0 4px 12px rgba(139,92,246,.3); }
.btn-purple:hover { box-shadow: 0 6px 16px rgba(139,92,246,.45); }

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 10px; align-items: center; margin-top: 16px; justify-content: flex-end; font-size: 13px; }
.pagination a { padding: 6px 14px; border: 1.5px solid #e2e5f0; border-radius: 8px; background: #fff; color: var(--primary); }
.pagination a:hover { border-color: var(--primary); text-decoration: none; }
.pg-info { color: var(--muted); }

/* ---------- 卡密详情 ---------- */
.cards-detail summary { color: var(--primary); cursor: pointer; font-size: 12px; }
.cards-detail pre {
  margin-top: 6px; background: #f6f8fb; border-radius: 8px; padding: 8px;
  font-size: 12px; white-space: pre-wrap; word-break: break-all;
  max-width: 320px; max-height: 160px; overflow: auto;
}

/* ---------- 登录页 ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #4c1d95 50%, #6d28d9 100%);
  position: relative; overflow: hidden;
}
.login-body::before, .login-body::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08);
}
.login-body::before { width: 340px; height: 340px; top: -120px; left: -100px; }
.login-body::after { width: 420px; height: 420px; bottom: -160px; right: -120px; }
.login-box {
  position: relative; z-index: 1;
  background: rgba(255,255,255,.96);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 38px 42px; width: 360px;
}
.login-box h1 {
  font-size: 22px; text-align: center; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: 5px; margin: 6px 0 22px; }
.login-box input {
  width: 100%; padding: 12px 14px; margin-bottom: 14px;
  border: 1.5px solid #e2e5f0; border-radius: 10px; font-size: 14px; outline: none;
  transition: border .15s, box-shadow .15s;
}
.login-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.login-box button {
  width: 100%; padding: 12px 0; border: 0; border-radius: 10px;
  background: var(--grad); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(99,102,241,.35); transition: all .18s;
}
.login-box button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(99,102,241,.45); }
.login-box .err { color: #dc2626; font-size: 13px; margin-bottom: 10px; text-align: center; }
.login-tip { font-size: 12px; color: var(--muted); text-align: center; margin-top: 14px; }
.login-tip a { color: var(--primary); }

/* ---------- 客服工作台（微信风格） ---------- */
.wx-layout {
  display: grid; grid-template-columns: 300px 1fr; grid-template-rows: minmax(0, 1fr);
  height: calc(100vh - 190px); min-height: 480px;
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; overflow: hidden;
}
@media (max-width: 900px) { .wx-layout { grid-template-columns: 1fr; } }

/* 左侧会话列表 */
.wx-side { display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: #fff; border-right: 1px solid #e5e5e5; }
.wx-search { padding: 10px 12px; background: #f7f7f7; }
.wx-search input {
  width: 100%; height: 32px; border: none; background: #e5e5e5;
  border-radius: 16px; padding: 0 16px; font-size: 13px; outline: none; color: #191919;
}
.wx-search input::placeholder { color: #9a9a9a; }
.wx-list { flex: 1; overflow-y: auto; }
.wx-cust { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.wx-cust:hover { background: #f2f2f2; }
.wx-cust.active { background: #d9e8f9; }
.wx-cust-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
}
.wx-cust-main { flex: 1; min-width: 0; }
.wx-cust-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.wx-cust-top .nm { font-size: 14px; color: #191919; }
.wx-cust-top .tm { font-size: 11px; color: #b3b3b3; flex: none; }
.wx-cust-prev {
  font-size: 12px; color: #8a8a8a; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wx-badge {
  flex: none; min-width: 18px; height: 18px; border-radius: 9px; background: #fa5151;
  color: #fff; font-size: 11px; line-height: 18px; text-align: center; padding: 0 5px;
}
/* 设备标签（客户列表） */
.wx-dev {
  flex: none; font-size: 10px; line-height: 1; padding: 2px 5px; border-radius: 4px;
  color: #fff; margin-left: 2px;
}
.wx-dev.dev-and { background: #09bb07; }
.wx-dev.dev-ios { background: #8e8e93; }
.wx-dev.dev-pc  { background: #4a90e2; }
.wx-dev.dev-unk { background: #c0c0c0; }
.wx-reg { color: #b0b0b0; font-size: 11px; }
.wx-head-sub { line-height: 1.7; }

/* 右侧聊天窗口 */
.wx-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #f5f5f5; }
.wx-head { padding: 10px 16px; background: #f7f7f7; border-bottom: 1px solid #e5e5e5; text-align: center; }
.wx-head-title { font-size: 15px; color: #191919; }
.wx-head-sub { font-size: 11.5px; color: #999; margin-top: 2px; }

/* 消息区 */
.wx-msgs { flex: 1; overflow-y: auto; min-height: 0; padding: 16px 18px; }
.wx-msg { display: flex; margin-bottom: 16px; align-items: flex-start; gap: 8px; }
.wx-msg.out { justify-content: flex-end; }
.wx-avatar {
  width: 34px; height: 34px; border-radius: 4px; flex: none; color: #fff;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.wx-msg.out .wx-avatar { order: 2; border-radius: 4px; }
.wx-body { max-width: 70%; min-width: 0; }
.wx-msg.out .wx-body { display: flex; flex-direction: column; align-items: flex-end; }
.wx-name { font-size: 11px; color: #999; margin-bottom: 2px; }
.wx-bubble {
  position: relative; padding: 8px 12px; font-size: 13.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-all; color: #191919;
}
.wx-msg.in .wx-bubble { background: #fff; border-radius: 4px 10px 10px 10px; }
.wx-msg.in .wx-bubble::before {
  content: ''; position: absolute; left: -6px; top: 10px;
  border: 6px solid transparent; border-right-color: #fff;
}
.wx-msg.out .wx-bubble { background: #95ec69; border-radius: 10px 4px 10px 10px; }
.wx-msg.out .wx-bubble::before {
  content: ''; position: absolute; right: -6px; top: 10px;
  border: 6px solid transparent; border-left-color: #95ec69;
}
.wx-time { font-size: 10px; color: #b8b8b8; margin-top: 3px; }
.wx-msg.out .wx-time { text-align: right; }
/* 公告居中灰条 */
.wx-msg.bc { justify-content: center; }
.wx-bc {
  max-width: 86%; background: #d8d8d8; color: #6b6b6b;
  padding: 4px 14px; border-radius: 8px; font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-all; text-align: center;
}

/* 底部输入区 */
.wx-inputbar {
  display: flex; gap: 10px; padding: 10px 12px; align-items: flex-end;
  background: #f7f7f7; border-top: 1px solid #e5e5e5;
}
.wx-inputbar textarea {
  flex: 1; resize: none; height: 44px; padding: 9px 12px;
  border: 1px solid #e0e0e0; border-radius: 6px; font-size: 14px; outline: none;
  font-family: inherit; background: #fff; color: #191919;
}
.wx-inputbar textarea:focus { border-color: #07c160; }
.wx-inputbar textarea:disabled { background: #f0f0f0; }
.wx-send {
  flex: none; height: 44px; padding: 0 20px; border: none; cursor: pointer;
  background: #07c160; color: #fff; font-size: 14px; border-radius: 6px;
}
.wx-send:hover { background: #06ad56; }
.wx-send:disabled { background: #a9d8b8; cursor: not-allowed; }
.wx-empty {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #999; font-size: 13px; gap: 6px; text-align: center; line-height: 1.8;
}
.wx-empty-ico { font-size: 30px; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .brand { justify-content: center; padding: 18px 8px; }
  .brand > span:last-child, .nav a { font-size: 0; }
  .nav a { justify-content: center; padding: 12px 0; }
  .menu-ico { font-size: 18px; }
  .side-foot span { display: none; }
  .side-foot { justify-content: center; }
  .main { padding: 16px 12px; }
}
