/* =====================================================================
 * style.css — 客服业绩考核 SaaS · 浅色主题（参照 Gate.io 后台风格）
 * ===================================================================== */
:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --sidebar: #0d1b2e;
  --sidebar-hover: #16294a;
  --sidebar-active: #1f6feb;
  --brand: #1f6feb;
  --brand-soft: #eaf2ff;
  --ink: #1f2933;
  --sub: #7b8794;
  --border: #e4e7eb;
  --grid: #f0f2f5;
  --red: #ef4444;    /* 涨　中国习惯 */
  --green: #10b981;  /* 跌 */
  --orange: #f59e0b;
  --blue: #3b82f6;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 27, 46, 0.06);
  --gutter: 20px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

/* 侧边栏 */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #24344f; border-radius: 3px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #2f7bff, #00c6ff);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
.brand .name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand .name span { display: block; color: #7b93b8; font-size: 11px; font-weight: 500; }

.nav-section { padding: 12px 10px 4px; }
.nav-title { color: #64748b; font-size: 11px; letter-spacing: .06em; padding: 8px 12px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin: 1px 6px;
  color: #cbd5e1; border-radius: 8px; cursor: pointer; font-weight: 500; transition: .15s;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #7dd3fc; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-item .badge { margin-left: auto; background: #ef4444; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 8px; }

.sidebar-foot { margin-top: auto; padding: 12px 14px; border-top: 1px solid #22334d; font-size: 11px; color: #64748b; }

/* 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .crumb { color: var(--sub); font-size: 13px; margin-top: 2px; }
.topbar .spacer { flex: 1; }

.role-switch { display: flex; align-items: center; gap: 8px; background: var(--grid); border-radius: 10px; padding: 4px; }
.role-btn { border: none; background: transparent; padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--sub); cursor: pointer; transition: .15s; }
.role-btn.active { background: var(--panel); color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.sync-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--ink); padding: 7px 13px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
}
.sync-btn:hover { border-color: var(--brand); color: var(--brand); }
.sync-btn.spinning .ic { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.avatar-stack { display: flex; align-items: center; gap: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.avatar .u { text-align: left; line-height: 1.15; }
.avatar .u b { display: block; font-size: 13px; }
.avatar .u small { color: var(--sub); font-size: 11px; }

/* 内容 */
.content { padding: 24px; flex: 1; }
.page-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-actions .t { font-size: 18px; font-weight: 700; }

/* ---------------- 卡片 ---------------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--grid); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .hint { color: var(--sub); font-size: 12px; }
.card-body { padding: 20px; }

.grid { display: grid; gap: 20px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g2 { grid-template-columns: 1fr; } .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; } }

/* 指标卡 */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi .k-label { color: var(--sub); font-size: 13px; }
.kpi .k-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi .k-value .cur { font-size: 15px; font-weight: 700; color: var(--sub); margin-right: 4px; }
.kpi .k-delta { font-size: 12px; display: flex; align-items: center; gap: 4px; color: var(--sub); }
.kpi .k-ico { position: absolute; right: 18px; top: 20px; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; }
.up { color: var(--red); }   /* 涨 */
.down { color: var(--green); }  /* 跌 */

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th { text-align: left; padding: 12px 14px; background: #fafbfc; color: var(--sub); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--grid); color: var(--ink); white-space: nowrap; vertical-align: middle; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tbl .strong { font-weight: 700; }
.tbl .sub { color: var(--sub); font-size: 12px; }
.tbl .mono { font-family: 'SF Mono', 'JetBrains Mono', Consolas, monospace; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* 状态色 */
.st-未交易 { background: #eef1f4; color: #5b6472; }
.st-已交易 { background: #e7f0ff; color: #2563eb; }
.st-活跃 { background: #e6f8f2; color: #0f9d6b; }
.st-沉默 { background: #fef4e6; color: #d99704; }
.st-流失 { background: #fdeaea; color: #d92d2d; }
.st-审核中, .st-待结算 { background: #fef4e6; color: #d99704; }
.st-已通过, .st-已结算 { background: #e6f8f2; color: #0f9d6b; }
.st-已打款, .st-已发放 { background: #e7f0ff; color: #2563eb; }
.st-已驳回 { background: #fdeaea; color: #d92d2d; }

/* 标签 */
.tag { display: inline-block; padding: 1px 8px; border-radius: 5px; background: var(--grid); color: var(--sub); font-size: 11px; margin-right: 4px; }
.tag.gold { background: #fff6e0; color: #b7791f; }

/* ---------------- 按钮 ---------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #1a5fd0; border-color: #1a5fd0; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { background: #fff; border-color: #fca5a5; color: #d92d2d; }
.btn-danger:hover { border-color: #ef4444; color: #ef4444; }

/* 筛选工具栏 */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--grid); }
.filters select, .filters input { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 13px; background: var(--panel); color: var(--ink); }
.filters input { min-width: 150px; }
.filters .label { color: var(--sub); font-size: 12px; }

/* 分段 tab */
.seg { display: inline-flex; background: var(--grid); border-radius: 9px; padding: 3px; }
.seg button { border: none; background: transparent; padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--sub); cursor: pointer; }
.seg button.active { background: var(--panel); color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------------- 空态 / 骨架 ---------------- */
.empty { text-align: center; color: var(--sub); padding: 48px 20px; }
.empty .ic { font-size: 42px; opacity: .5; margin-bottom: 10px; }
.chart-box { min-height: 200px; display: flex; align-items: center; justify-content: center; color: var(--sub); }
.legend-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: var(--sub); }
.legend-row .item { display: inline-flex; align-items: center; gap: 6px; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------------- 弹窗 ---------------- */
.modal-mask { position: fixed; inset: 0; background: rgba(13,27,46,.45); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-mask.show { display: flex; }
.modal { background: var(--panel); border-radius: 14px; width: 480px; max-width: 94vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--grid); }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-x { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--sub); line-height: 1; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--grid); display: flex; justify-content: flex-end; gap: 10px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 13px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,.12); }

.notice { background: #fef4e6; border: 1px solid #fcd9a0; border-radius: 8px; padding: 10px 14px; font-size: 12px; color: #a05a00; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start; }

/* 排行 medallions */
.rank { display: inline-flex; width: 22px; height: 22px; border-radius: 6px; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; background: var(--grid); color: var(--sub); }
.rank.r1 { background: #ffd84d; color: #7a5a00; }
.rank.r2 { background: #e5e7ea; color: #5b6472; }
.rank.r3 { background: #f6c9a0; color: #8a4a08; }

/* toast */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); display: flex; align-items: center; gap: 8px; animation: slidein .25s ease; }
.toast.ok { background: #0f9d6b; }
.toast.err { background: #d92d2d; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 进度环 */
.progress { width: 100%; height: 8px; background: var(--grid); border-radius: 5px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 5px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aab2bd; }

/* =====================================================================
 * 登录 / 注册页（覆盖在 #content 上）
 * ===================================================================== */
.auth-page {
  min-height: calc(100vh - 80px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(ellipse at top left, rgba(31,111,235,.06), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(16,185,129,.05), transparent 60%);
}
.auth-card {
  width: 100%; max-width: 460px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(15, 27, 46, 0.08), 0 2px 6px rgba(15, 27, 46, 0.04);
  padding: 36px 32px 28px;
  border: 1px solid var(--border);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .logo.big {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--brand), #4a8bff);
  color: #fff; font-weight: 800; font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(31,111,235,.30);
}
.auth-brand h2 { font-size: 20px; font-weight: 700; color: var(--ink); }
.auth-brand .sub { margin-top: 4px; font-size: 13px; color: var(--sub); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span { font-size: 12px; color: var(--sub); font-weight: 600; }
.auth-field > span em { color: var(--red); font-style: normal; margin-left: 2px; }
.auth-field > span small { color: #b0b8c2; font-weight: 400; margin-left: 4px; }
.auth-field input, .auth-field select {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 13px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.auth-field input:focus, .auth-field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31,111,235,.15);
}
.auth-field input:invalid:not(:placeholder-shown) { border-color: var(--red); }

.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: flex; align-items: center; gap: 6px;
}
.auth-error::before { content: '⚠️'; }

.btn-block { width: 100%; height: 42px; font-size: 14px; font-weight: 700; }

.auth-foot {
  text-align: center; margin-top: 18px; font-size: 13px; color: var(--sub);
}
.auth-foot a { color: var(--brand); text-decoration: none; font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }

.auth-tip {
  margin-top: 16px; padding: 12px;
  background: #f8fafc; border: 1px dashed var(--border);
  border-radius: 9px; font-size: 12px; color: var(--sub);
  line-height: 1.6;
}
.auth-tip code {
  background: #fff; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border); font-family: 'Menlo', monospace;
  color: var(--ink); font-weight: 600;
}

.empty-state-tip {
  text-align: center; padding: 24px 8px;
  color: var(--ink);
}
.empty-state-tip p { margin: 6px 0; }
.empty-state-tip .sub { color: var(--sub); font-size: 13px; }
.empty-state-tip a.btn { display: inline-block; margin-top: 12px; text-decoration: none; }

/* =====================================================================
 * 顶栏用户区改造
 * ===================================================================== */
.role-chip {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 700; margin-right: 6px;
  background: var(--brand-soft); color: var(--brand);
}
.role-chip.role-admin { background: #fff7ed; color: #c2410c; }
.role-chip.role-leader { background: #ecfeff; color: #0e7490; }
.role-chip.role-cs { background: #f0fdf4; color: #166534; }

.user-tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 18px;
}

.btn-ghost {
  background: transparent;
  color: var(--sub);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--grid);
  color: var(--ink);
}
.btn-sm { padding: 4px 12px; font-size: 12px; }
