/* ======= 全局 ======= */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f5f5; color: #333; font-size: 14px; }

:root {
  --primary: #C75B3A;
  --primary-light: #E0704A;
  --primary-dark: #A84A2E;
  --primary-bg: #FFF5F0;
  --success: #2ECC71;
  --warning: #F7931E;
  --danger: #E53935;
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
}

/* ======= 页面容器 ======= */
.page { display: none; }
.page.active { display: block; }

/* ======= 登录页 ======= */
#page-login {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFF5F0, #F7F3EF);
}
#page-login.active { display: flex; }
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo { font-size: 64px; margin-bottom: 16px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.login-sub { font-size: 13px; color: #999; margin-bottom: 32px; }
.login-card .form-group { text-align: left; margin-bottom: 20px; }
.login-card label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; font-weight: 600; }
.login-card input {
  width: 100%; height: 44px; border: 1px solid #ddd; border-radius: var(--radius); padding: 0 16px;
  font-size: 14px; outline: none; transition: border-color .2s;
}
.login-card input:focus { border-color: var(--primary); }
.login-hint { font-size: 12px; color: #bbb; margin-top: 16px; }

/* ======= 主界面 ======= */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid #eee;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 100; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.topbar-brand { font-size: 18px; font-weight: 700; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { font-size: 14px; color: #666; }

/* 侧边栏 */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid #eee; overflow-y: auto; z-index: 50;
  padding: 12px 0;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 24px; cursor: pointer; color: #555; font-size: 14px;
  transition: all .15s; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--primary-bg); color: var(--primary); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; border-left-color: var(--primary); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-divider { height: 1px; background: #eee; margin: 8px 16px; }

/* 导航分组 */
.nav-group-label {
  padding: 16px 24px 6px; font-size: 11px; font-weight: 700; color: #bbb; text-transform: uppercase; letter-spacing: 0.5px;
}

/* 导航角标 */
.nav-tag {
  margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #E8F8F2; color: #1a7a42; font-weight: 600;
  display: none;
}
.nav-tag.warn { background: #FFEBEE; color: #b71c1c; }

/* 头部操作栏 */
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-actions select { height: 36px; border: 1px solid #ddd; border-radius: 6px; padding: 0 12px; font-size: 13px; outline: none; }
.header-actions select:focus { border-color: var(--primary); }

/* 主内容区 */
.content {
  margin-left: var(--sidebar-w); margin-top: var(--topbar-h);
  padding: 24px; min-height: calc(100vh - var(--topbar-h));
}
.content-page { display: none; }
.content-page.active { display: block; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 600; }

/* 卡片标题 */
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 16px; font-weight: 600; margin: 0; }

/* 待处理事项 */
.pending-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5; font-size: 14px;
}
.pending-item:last-child { border-bottom: none; }
.pending-icon { font-size: 20px; }
.pending-item .btn { flex-shrink: 0; }

/* 详情行 */
.detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f5f5f5; }
.detail-row label { width: 80px; font-weight: 600; color: #666; font-size: 13px; flex-shrink: 0; }
.detail-row span { flex: 1; font-size: 14px; }

/* 工具类 */
.text-sm { font-size: 12px; }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.p-10 { padding: 10px; }
.mt-10 { margin-top: 10px; }

/* ======= 客户画像 ======= */

/* 来源分布 */
.source-list { display: flex; flex-direction: column; gap: 16px; }
.source-item {}
.source-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.source-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.source-name { flex: 1; font-size: 14px; color: #555; }
.source-pct { font-size: 14px; font-weight: 700; color: #333; }
.source-bar-bg { width: 100%; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.source-bar { height: 8px; border-radius: 4px; transition: width .3s; }

/* 画像卡片网格 */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-card {
  background: #f9f9f9; border-radius: 8px; padding: 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.profile-card-icon { font-size: 28px; }
.profile-card-label { font-size: 12px; color: #999; }
.profile-card-value { font-size: 14px; font-weight: 700; color: #333; }

/* 商品排行 */
.rank-list { display: flex; flex-direction: column; gap: 16px; }
.rank-item { display: flex; align-items: flex-start; gap: 12px; }
.rank-num {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.rank-top { background: linear-gradient(135deg, #FFD700, #FFA000); color: #fff; }
.rank-normal { background: #f0f0f0; color: #999; }
.rank-body { flex: 1; min-width: 0; }
.rank-name { font-size: 13px; font-weight: 600; color: #333; margin-bottom: 4px; }
.rank-meta { font-size: 12px; color: #999; margin-bottom: 6px; }
.rank-bar-track { height: 4px; background: #f0f0f0; border-radius: 2px; overflow: hidden; }
.rank-bar-fill { height: 4px; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 2px; }

/* 趋势柱状图 */
.trend-chart {}
.chart-wrap { display: flex; align-items: flex-end; justify-content: space-between; height: 180px; padding: 0 8px; }
.chart-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; }
.chart-bar {
  width: 36px; background: linear-gradient(180deg, var(--primary), var(--primary-light));
  border-radius: 4px 4px 0 0; position: relative; min-height: 4px; transition: height .3s;
}
.chart-num { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--primary); font-weight: 700; white-space: nowrap; }
.chart-label { font-size: 11px; color: #999; margin-top: 8px; }

/* ======= 卡片 ======= */
.card { background: #fff; border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.mt-20 { margin-top: 20px; }

/* ======= 统计卡片 ======= */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
  text-align: center;
}
.stat-num { font-size: 36px; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.stat-label { font-size: 14px; color: #999; }

/* ======= 表格 ======= */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 8px; font-size: 12px; color: #999; font-weight: 600;
  border-bottom: 2px solid #eee; white-space: nowrap;
}
.data-table td { padding: 12px 8px; border-bottom: 1px solid #f5f5f5; font-size: 13px; color: #555; vertical-align: middle; }
.data-table tr:hover td { background: #FAFAFA; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 600;
}
.badge-success { background: #E8F8F2; color: #1a7a42; }
.badge-warning { background: #FFF3E0; color: #b76500; }
.badge-danger { background: #FFEBEE; color: #b71c1c; }
.badge-info { background: #E3F2FD; color: #0d47a1; }
.badge-gray { background: #f5f5f5; color: #999; }

/* ======= 按钮 ======= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 36px; padding: 0 20px; border-radius: 6px; cursor: pointer; font-size: 13px;
  font-weight: 600; border: none; transition: all .15s; white-space: nowrap;
}
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-block { width: 100%; height: 44px; }

/* ======= 表单 ======= */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; height: 40px; border: 1px solid #ddd; border-radius: 6px; padding: 0 12px;
  font-size: 14px; outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }
.form-group textarea { height: 80px; padding: 10px 12px; resize: vertical; }
.form-group .input-hint { display: inline-block; margin-left: 12px; font-size: 12px; color: #999; }

/* 佣金规则表格 */
.commission-table {
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
}
.commission-header, .commission-row {
  display: grid;
  grid-template-columns: 80px 1fr 120px 80px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 13px;
}
.commission-header {
  background: #f9f9f9;
  font-weight: 600;
  color: #666;
  border-bottom: 1px solid #eee;
}
.commission-row:not(:last-child) {
  border-bottom: 1px solid #f5f5f5;
}
.commission-type {
  font-weight: 600;
  color: var(--primary);
}
.commission-input {
  width: 60px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ======= 弹窗 ======= */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; width: 520px; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0; font-size: 18px; font-weight: 700;
}
.modal-close { cursor: pointer; font-size: 20px; color: #999; padding: 4px; }
.modal-close:hover { color: #333; }
.modal-body { padding: 20px 24px 24px; }

/* ======= 实用 ======= */
.text-gray { color: #999; }
.text-primary { color: var(--primary); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.p-10 { padding: 10px; }
.mt-16 { margin-top: 16px; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }

/* 标签 */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px;
  margin: 2px; background: #f0f0f0; color: #666;
}
.tag-primary { background: var(--primary-bg); color: var(--primary); }
.tag-success { background: #E8F8F2; color: #1a7a42; }

/* 空状态 */
.empty-state { padding: 60px 0; text-align: center; color: #ccc; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-icon { margin: 0; }
  .sidebar .nav-item span:not(.nav-icon) { display: none; }
  .content { margin-left: 60px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .login-card { width: 90%; }
}
