/* ═══ 楚智生态系统后台 · 样式 ═══ */
/* 品牌色板：Primary #0D8ABC / Secondary #149187 / Accent #4CB848 */

:root {
  --primary: #0D8ABC; --primary-dark: #0A6A96; --primary-deeper: #064E6F;
  --secondary: #149187; --accent: #4CB848;
  --ink: #1C1C1C; --bg: #F8FAFB; --muted: #8892A0;
  --gray-50: #F9FAFB; --gray-100: #F3F4F6; --gray-200: #E5E7EB; --gray-300: #D1D5DB;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05); --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 8px; --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Noto Sans SC", -apple-system, "Source Sans 3", sans-serif; background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; }

/* ── 侧边栏 ── */
.sidebar {
  width: 240px; min-width: 240px; background: linear-gradient(180deg, #064E6F 0%, #0A6A96 100%);
  color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-brand { padding: 24px 20px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.15); }
.brand-icon {
  width: 36px; height: 36px; background: linear-gradient(135deg, #0D8ABC, #4CB848);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.brand-text { font-size: 14px; font-weight: 600; line-height: 1.3; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; font-size: 14px;
  color: rgba(255,255,255,.65); text-decoration: none; cursor: pointer; transition: all .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.12); border-left-color: #4CB848; font-weight: 600; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.15); }
.user-info { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }
.user-name { opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.logout-btn { width: 100%; padding: 6px 0; background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; transition: all .15s; }
.logout-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ── 主内容区 ── */
.main-content { margin-left: 240px; flex: 1; padding: 32px; min-width: 0; overflow-x: hidden; }
.page { animation: fadeIn .2s ease; }
.page.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.page-title { font-size: 22px; font-weight: 700; margin-bottom: 24px; color: var(--ink); }
.page-desc { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ── 加载 ── */
.loading { text-align: center; padding: 80px 0; color: var(--muted); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 统计卡片 ── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 28px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200); }
.stat-value { font-size: 32px; font-weight: 700; color: var(--ink); }
.stat-value.highlight { color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── 图表 ── */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200); }
.chart-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.chart-bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { width: 80px; color: var(--muted); text-align: right; flex-shrink: 0; }
.bar-wrap { flex: 1; min-width: 0; height: 20px; background: var(--gray-100); border-radius: 10px; overflow: hidden; }
.bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 10px; min-width: 4px; transition: width .3s ease; }
.bar-cnt { width: 30px; font-weight: 600; flex-shrink: 0; }

/* ── 工具栏 ── */
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.search-input { padding: 8px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; min-width: 220px; outline: none; transition: border-color .15s; }
.search-input:focus { border-color: var(--primary); }
.filter-select { padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; background: #fff; cursor: pointer; outline: none; }

/* ── 按钮 ── */
.btn { padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; border: 1px solid var(--gray-300); background: #fff; transition: all .15s; }
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 4px 12px; font-size: 13px; }

/* ── 表格 ── */
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 12px 16px; background: var(--gray-50); color: var(--muted); font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable { cursor: pointer; transition: background .1s; }
.data-table tr.clickable:hover { background: #F0F9FF; }
.text-truncate { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }

/* ── 标签 ── */
.tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag-new { background: #E0F2FE; color: #0369A1; } .tag-contacted { background: #FEF3C7; color: #92400E; }
.tag-diagnosed { background: #EDE9FE; color: #6D28D9; } .tag-proposal { background: #FCE7F3; color: #BE185D; }
.tag-won { background: #DCFCE7; color: #166534; } .tag-paused { background: var(--gray-100); color: var(--muted); } .tag-lost { background: #FEE2E2; color: #991B1B; }
.tag-website { background: #DBEAFE; color: #1E40AF; } .tag-ai_chat { background: #E0E7FF; color: #3730A3; }
.tag-referral { background: #FEF3C7; color: #92400E; } .tag-other { background: var(--gray-100); color: var(--muted); }
.tag-source, .tag-stage { font-size: 12px; }

/* ── 分页 ── */
.pagination { display: flex; gap: 12px; align-items: center; padding: 16px 0; justify-content: center; }
.page-info { font-size: 13px; color: var(--muted); }

/* ── 弹窗 ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-md); width: 90%; max-width: 680px; max-height: 85vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--gray-200); }
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--gray-100); font-size: 18px; cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--gray-200); color: var(--ink); }
.modal-body { padding: 24px; }
.modal-body hr { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── 详情 ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-item label { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.detail-item span { font-size: 14px; font-weight: 500; }
.detail-item select { padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; background: #fff; }

.modal-body h4 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

.followup-list { margin-bottom: 16px; }
.followup-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; align-items: flex-start; }
.followup-item:last-child { border: none; }
.fu-action { font-weight: 600; white-space: nowrap; color: var(--primary); min-width: 100px; }
.fu-note { flex: 1; color: var(--ink); min-width: 0; }
.fu-time { color: var(--muted); white-space: nowrap; font-size: 12px; }

.followup-form { display: flex; flex-direction: column; gap: 8px; }
.form-input { padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; outline: none; font-family: inherit; }
.form-input:focus { border-color: var(--primary); }

/* ── 空状态 ── */
.empty-state { text-align: center; color: var(--muted); padding: 32px; font-size: 14px; }

/* ── 响应式 ── */
@media (max-width: 768px) {
  .sidebar { width: 60px; min-width: 60px; }
  .brand-text { display: none; }
  .nav-item span { display: none; }
  .sidebar-footer { padding: 10px; }
  .user-name { display: none; }
  .main-content { margin-left: 60px; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
