/* ============================================================
   TikTok AI 潜在客户监控系统 - 全局样式
   绿色渐变主题
   ============================================================ */
:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #34d399;
  --primary-grad: linear-gradient(135deg, #10b981, #059669);
  --bg: #f0f4f3;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-w: 230px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

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

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

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

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.logo {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--primary-grad);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
}
.logo-name { display: block; font-weight: 700; color: #fff; font-size: 15px; }
.logo-sub { display: block; font-size: 11px; color: #94a3b8; margin-top: 2px; }

.nav { flex: 1; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active {
  background: var(--primary-grad);
  color: #fff;
  font-weight: 500;
}
.nav-icon { font-size: 16px; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sys-status { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 12px; color: #94a3b8; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.green { background: #10b981; }

/* ===== 主内容区 ===== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px;
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.muted { color: var(--text-secondary); font-size: 13px; }
.avatar {
  width: 36px; height: 36px;
  background: var(--primary-grad);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}

.page { display: none; }
.page.active { display: block; }

/* ===== 统计卡片 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-label { color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-sub { color: var(--text-secondary); font-size: 12px; margin-top: 6px; }

/* ===== 卡片 ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-title {
  font-size: 15px; font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== 表格 ===== */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; color: var(--text-secondary);
  font-weight: 500; padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .3px;
}
.table td { padding: 11px 8px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.table tr:hover td { background: #fafafa; }
.table .score-badge {
  display: inline-block; padding: 3px 8px; border-radius: 20px;
  font-weight: 600; font-size: 12px;
}
.score-high { background: #dcfce7; color: #059669; }
.score-mid { background: #fef3c7; color: #b45309; }
.score-low { background: #f3f4f6; color: #6b7280; }
.status-badge { padding: 3px 8px; border-radius: 20px; font-size: 12px; }
.status-new { background: #dbeafe; color: #2563eb; }
.status-following { background: #fef3c7; color: #b45309; }
.status-contacted { background: #e0e7ff; color: #4f46e5; }
.status-won { background: #dcfce7; color: #059669; }
.status-lost { background: #fee2e2; color: #dc2626; }

/* ===== 按钮 ===== */
.btn {
  border: none; border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary { background: var(--primary-grad); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-secondary { background: #eef2f7; color: var(--text); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ===== 输入 ===== */
.input, .select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border .15s;
}
.input:focus, .select:focus { border-color: var(--primary); }
.input-sm { width: 120px; }
.toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}

/* ===== 图表/列表 ===== */
.chart-box, .list-box { min-height: 200px; }
.empty { color: var(--text-secondary); text-align: center; padding: 60px 0; font-size: 13px; }
.lead-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #f3f4f6;
}
.lead-item:last-child { border-bottom: none; }
.lead-author { font-weight: 600; }
.lead-score { color: var(--primary); font-weight: 700; }
.lead-intent { color: var(--text-secondary); font-size: 12px; }

/* 意图条形图 */
.intent-bar-row { margin-bottom: 12px; }
.intent-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.intent-bar-track { height: 8px; background: #f1f5f9; border-radius: 20px; overflow: hidden; }
.intent-bar-fill { height: 100%; background: var(--primary-grad); border-radius: 20px; transition: width .5s; }

/* ===== 弹窗/模态框 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  cursor: pointer;
  font-size: 20px;
  color: #9ca3af;
  line-height: 1;
}
.modal-close:hover { color: #374151; }
.modal-field {
  padding: 14px 20px;
}
.modal-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #374151;
}
.modal-field textarea {
  resize: vertical;
}
.modal-actions {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== OAuth 提示 ===== */
#oauthHint ol {
  color: var(--text-secondary);
  line-height: 1.8;
}
#oauthHint strong {
  color: var(--primary);
}

/* ===== 博主回复卡片 ===== */
.reply-list { min-height: 200px; }

/* ===== 角色卡片网格（AI 角色页） ===== */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.character-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: #fafafa;
  transition: all .15s;
  cursor: pointer;
}
.character-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(16,185,129,.1);
}
.character-card.selected {
  border-color: var(--primary);
  background: #ecfdf5;
  box-shadow: 0 0 0 2px var(--primary-light);
}
.character-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary-grad);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}
.character-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.character-desc {
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.character-meta {
  margin-top: 8px; font-size: 11px; color: #9ca3af;
}
.character-bind-btn {
  margin-top: 10px; width: 100%;
}

/* ===== 配置表单 ===== */
.config-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.config-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.config-field {
  flex: 1;
}
.config-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #374151;
}
.config-field input {
  font-size: 13px;
}

/* ===== 审批列表 ===== */
.approval-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fafafa;
}
.approval-reply { font-size: 14px; margin-bottom: 8px; line-height: 1.5; }
.approval-meta { color: var(--text-secondary); font-size: 12px; margin-bottom: 10px; }
.approval-actions { display: flex; gap: 8px; }

/* ===== 私信列表 ===== */
.dm-item {
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
}
.dm-item:last-child { border-bottom: none; }
.dm-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
.dm-author { font-weight: 600; }
.dm-time { color: var(--text-secondary); font-size: 12px; }
.dm-content { color: var(--text-secondary); line-height: 1.5; }
