/* ============ 销售管理系统 全局样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2378ff;
  --primary-dark: #1e66e0;
  --sidebar-bg: #131722;
  --sidebar-text: #9aa0b5;
  --sidebar-active: #2456f0;
  --bg: #f5f6fa;
  --border: #e8eaf0;
  --text: #333;
  --text-2: #666;
  --text-3: #999;
  --green: #2fbf71;
  --orange: #ff943e;
  --red: #f56c6c;
  --yellow: #e6a23c;
}

html, body { height: 100%; font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============ 通用布局 ============ */
.btn {
  display: inline-block; padding: 7px 16px; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; color: var(--text-2); font-size: 13px; cursor: pointer; transition: all .15s;
  white-space: nowrap; line-height: 1.5;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger-plain { color: var(--red); }
.btn-danger-plain:hover { border-color: var(--red); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ 表格 ============ */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: auto; }
table.data-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.data-table th {
  background: #f7f8fb; color: var(--text-2); font-weight: 500; text-align: left;
  padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 13px;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f2f3f7; color: var(--text); font-size: 13px; }
.data-table tbody tr:hover { background: #f8faff; }
.data-table .ops a { margin-right: 10px; white-space: nowrap; }
.data-table .ops a:last-child { margin-right: 0; }

/* 复选框 */
input[type="checkbox"].cbk { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px; background: #fff; border-top: 0; }
.pagination .pg-btn { min-width: 30px; height: 30px; border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: pointer; color: var(--text-2); }
.pagination .pg-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .pg-btn:disabled { color: #ccc; cursor: not-allowed; }

/* ============ 筛选栏 ============ */
.filter-bar {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px;
}
.filter-bar select, .filter-bar input[type="text"], .filter-bar input[type="date"] {
  height: 32px; border: 1px solid var(--border); border-radius: 4px; padding: 0 10px; font-size: 13px; color: var(--text);
  outline: none; background: #fff;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); }
.filter-bar .spacer { flex: 1; }

/* ============ 标签 ============ */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 12px; margin-right: 5px; margin-bottom: 2px; color: #fff;
}
.tag-plain { background: #f0f2f8; color: var(--text-2); }

/* 意向度色块 */
.intent { display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; color: #fff; font-size: 12px; }
.intent-A { background: var(--red); }
.intent-B { background: var(--orange); }
.intent-C { background: #409eff; }
.intent-D { background: #b9bdc9; }

/* 跟进阶段 */
.stage-dot { display: inline-flex; align-items: center; gap: 6px; }
.stage-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #c3c8d4; }
.stage-dot.s-active::before { background: var(--primary); }
.stage-dot.s-done::before { background: var(--green); }

/* 客户名称单元格 */
.cust-cell { display: flex; align-items: center; gap: 8px; }
.cust-avatar {
  width: 34px; height: 34px; border-radius: 6px; background: linear-gradient(135deg, #6a8dff, #38b6ff);
  color: #fff; font-size: 15px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cust-name { color: var(--text); }
.cust-src { font-size: 12px; margin-left: 4px; }
.cust-src.src-wechat { color: var(--green); }
.cust-src.src-other { color: var(--orange); }

/* ============ 弹窗 ============ */
.modal-mask {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  align-items: flex-start; justify-content: center; overflow: auto; padding: 60px 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 8px; width: 520px; max-width: 96vw; box-shadow: 0 8px 40px rgba(0,0,0,.18);
  animation: modalIn .18s ease;
}
.modal.modal-lg { width: 720px; }
@keyframes modalIn { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-close { cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; border: none; background: none; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); text-align: right; }
.modal-foot .btn { margin-left: 10px; }

/* 表单 */
.form-item { margin-bottom: 16px; }
.form-item label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; }
.form-item label em { color: var(--red); font-style: normal; margin-left: 2px; }
.form-item input[type="text"], .form-item input[type="password"], .form-item input[type="date"],
.form-item input[type="number"], .form-item select, .form-item textarea {
  width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 4px; padding: 0 10px;
  font-size: 13px; outline: none; background: #fff; color: var(--text);
}
.form-item textarea { height: 90px; padding: 8px 10px; resize: vertical; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-row { display: flex; gap: 14px; }
.form-row .form-item { flex: 1; }
.form-tip { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ============ 消息提示 ============ */
#toast {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%); z-index: 999;
  background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.16); border-radius: 6px; padding: 12px 22px;
  font-size: 14px; display: none; align-items: center; gap: 8px; max-width: 60vw;
}
#toast.ok { border-left: 3px solid var(--green); }
#toast.err { border-left: 3px solid var(--red); }

/* 确认弹窗复用modal */
.danger-text { color: var(--red); }

/* ============ 页面头部（内容区标题行） ============ */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { font-size: 17px; font-weight: 600; }
.page-head .remain { margin-right: auto; margin-left: 24px; font-size: 13px; color: var(--text-2); }
.page-head .remain b { color: var(--primary); font-size: 16px; margin: 0 2px; }
.page-head .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge-dot { position: relative; }
.badge-dot::after { content: ""; position: absolute; top: -2px; right: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }

/* 统计卡片（仪表盘） */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px;
}
.stat-card .sc-label { color: var(--text-3); font-size: 13px; margin-bottom: 8px; }
.stat-card .sc-value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-card .sc-value small { font-size: 13px; color: var(--text-3); font-weight: normal; margin-left: 4px; }
.stat-card.blue .sc-value { color: var(--primary); }
.stat-card.green .sc-value { color: var(--green); }
.stat-card.orange .sc-value { color: var(--orange); }

/* 面板 */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; }
.panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--text); }
@media (max-width: 1100px) { .panel-grid, .panel-grid.three { grid-template-columns: 1fr; } }

/* 简易条形图 */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .bar-label { width: 72px; color: var(--text-2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; height: 14px; background: #f2f3f7; border-radius: 7px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: linear-gradient(90deg, #4d8bff, #2378ff); border-radius: 7px; min-width: 2px; transition: width .4s; }
.bar-row .bar-val { width: 60px; color: var(--text-2); font-size: 12px; }

/* 折线趋势图（SVG由JS生成） */
.line-chart-wrap { width: 100%; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* 空状态 */
.empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 13px; }
.empty::before { content: "📭"; display: block; font-size: 34px; margin-bottom: 10px; filter: grayscale(1); opacity: .5; }

/* 加载中 */
.loading-mask { position: fixed; inset: 0; background: rgba(255,255,255,.5); display: none; align-items: center; justify-content: center; z-index: 200; }
.loading-mask.show { display: flex; }
.loading-mask span { color: var(--text-3); font-size: 13px; }

/* 时间线（跟进记录） */
.timeline { max-height: 360px; overflow: auto; padding-left: 6px; }
.timeline-item { position: relative; padding: 0 0 18px 22px; border-left: 1px solid #e5e8f0; margin-left: 6px; }
.timeline-item:last-child { border-left-color: transparent; }
.timeline-item::before {
  content: ""; position: absolute; left: -5px; top: 3px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px #e8f0ff;
}
.timeline-item .tl-meta { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.timeline-item .tl-meta b { color: var(--text-2); margin-right: 8px; }
.timeline-item .tl-content { font-size: 13px; color: var(--text); white-space: pre-wrap; }

/* 静态说明块 */
.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.info-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.info-card .ic-icon { width: 42px; height: 42px; border-radius: 10px; background: #eef4ff; color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 12px; }
.info-card h4 { font-size: 14px; margin-bottom: 6px; }
.info-card p { font-size: 12px; color: var(--text-3); line-height: 1.7; }
