/* ============ zaimou CRM · 基础 ============ */
:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --sidebar-w: 224px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { flex: 1; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }

/* ============ 登录页 ============ */
.login-body { background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 380px; max-width: 100%; background: #fff; border-radius: 16px;
  padding: 36px 32px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #2563eb, #38bdf8);
  color: #fff; font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center;
  letter-spacing: .5px;
}
.brand-name { font-size: 18px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 13px; margin: 4px 0 20px; }

/* ============ 布局 ============ */
.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: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand .brand-logo { width: 38px; height: 38px; font-size: 14px; }
.brand .brand-name { color: #fff; font-size: 15px; font-weight: 600; line-height: 1.3; }
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: #cbd5e1; margin-bottom: 4px; font-size: 14px; transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; }
.sidebar-foot { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 62px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-badge { font-size: 13px; color: var(--muted); background: var(--bg); padding: 5px 12px; border-radius: 20px; }
.content { padding: 20px 24px 40px; }

/* ============ 通用组件 ============ */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-body { padding: 16px 18px; }
.panel-narrow { max-width: 720px; }
.link { font-size: 13px; }
.loading { padding: 30px; text-align: center; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--panel); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 18px; display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); }
.c-blue .stat-icon { background: #eff6ff; } .c-blue .stat-value { color: #2563eb; }
.c-green .stat-icon { background: #f0fdf4; } .c-green .stat-value { color: #16a34a; }
.c-orange .stat-icon { background: #fff7ed; } .c-orange .stat-value { color: #ea580c; }
.c-purple .stat-icon { background: #faf5ff; } .c-purple .stat-value { color: #9333ea; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; white-space: nowrap; }
.table th { background: #f8fafc; font-weight: 600; color: var(--muted); }
.table tbody tr:hover { background: #f8fafc; }
.table .actions { display: flex; gap: 6px; }
.tag { display: inline-block; background: var(--primary-light); color: var(--primary); border-radius: 6px; padding: 1px 8px; font-size: 12px; margin: 1px 2px 1px 0; }
.tag-primary { background: #dcfce7; color: #16a34a; }
.level-badge { display: inline-block; width: 22px; height: 22px; border-radius: 50%; text-align: center; line-height: 22px; font-weight: 700; font-size: 12px; color: #fff; }
.lv-A { background: #dc2626; } .lv-B { background: #f59e0b; } .lv-C { background: #94a3b8; }
.stage-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; padding: 14px 18px; justify-content: flex-end; }
.pager button { min-width: 34px; }
.pager .info { color: var(--muted); font-size: 13px; margin-right: 8px; }

/* 表单 */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field span i { color: var(--danger); font-style: normal; }
.input, select.input, .form input, .form select, .form textarea, .field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text); outline: none; transition: border .15s, box-shadow .15s; width: 100%;
}
.input:focus, .form input:focus, .form select:focus, .form textarea:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form textarea, .field textarea { resize: vertical; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 8px;
  padding: 8px 16px; font-size: 14px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-light); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* 提示 */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-warn { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 200; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* Modal */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 480px; max-width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* 看板 */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-col { background: #eef2f7; border-radius: 10px; min-width: 230px; flex: 1; max-width: 280px; }
.kanban-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 600; font-size: 13.5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.kanban-count { background: #fff; border-radius: 20px; padding: 0 8px; font-size: 12px; color: var(--muted); font-weight: 500; }
.kanban-body { padding: 4px 10px 12px; min-height: 120px; }
.deal-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
  cursor: grab; box-shadow: 0 1px 2px rgba(15,23,42,.06); transition: box-shadow .15s, transform .1s;
}
.deal-card:hover { box-shadow: 0 4px 12px rgba(15,23,42,.12); }
.deal-card.dragging { opacity: .5; }
.deal-card .deal-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.deal-card .deal-cust { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.deal-card .deal-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.deal-amount { font-weight: 700; color: var(--primary-dark); }
.prio { font-size: 12px; padding: 0 6px; border-radius: 4px; }
.prio-高 { background: #fee2e2; color: #dc2626; }
.prio-中 { background: #fef3c7; color: #d97706; }
.prio-低 { background: #dbeafe; color: #2563eb; }
.kanban-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }

/* 时间线 */
.timeline { display: flex; flex-direction: column; }
.timeline-item { border-left: 2px solid var(--border); padding: 0 0 16px 18px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; }
.timeline-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.badge { background: var(--primary-light); color: var(--primary); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.timeline-body { margin-bottom: 4px; }
.timeline-next { font-size: 13px; color: var(--warning); }

/* 客户详情 */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.info-grid .span-2 { grid-column: span 2; }
.info-grid .muted { font-size: 12px; }
.info-grid div div { margin-top: 2px; }

/* 漏斗 */
.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.funnel-label { width: 76px; font-size: 13px; color: var(--muted); }
.funnel-bar { height: 26px; border-radius: 6px; display: flex; align-items: center; padding: 0 10px; color: #fff; font-size: 12.5px; font-weight: 600; min-width: 40px; transition: width .3s; }

/* 空态 / 列表 */
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.list-row .sub { font-size: 12.5px; color: var(--muted); }

/* 响应式 */
@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .sidebar .brand-name, .sidebar .nav-item span:not(.nav-icon), .sidebar-foot .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; }
  .main { margin-left: 64px; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ============ 快速操作栏 ============ */
.quickbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ============ 图表 ============ */
.chart { min-height: 220px; }
.chart-donut { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-wrap { position: relative; width: 190px; height: 190px; flex-shrink: 0; }
.donut { width: 100%; height: 100%; display: block; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-value { font-size: 20px; font-weight: 800; color: var(--text); }
.donut-sub { font-size: 12px; color: var(--muted); }
.donut-legend { flex: 1; min-width: 200px; }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.legend-row i { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.legend-row span { flex: 1; color: var(--text); }
.legend-row b { font-weight: 600; }

/* 柱状图（月度趋势） */
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 200px; padding-top: 18px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar-value { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }
.bar-track { width: 100%; max-width: 52px; height: 140px; background: #f1f5f9; border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.bar-fill { width: 100%; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 6px 6px 0 0; transition: height .3s; min-height: 3px; }
.bar-label { font-size: 12px; color: var(--muted); }

/* 横向条形（账号粉丝榜） */
.hbar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hbar-label { width: 190px; flex-shrink: 0; }
.hbar-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { flex: 1; height: 30px; background: #f1f5f9; border-radius: 8px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 8px; display: flex; align-items: center; justify-content: flex-end; padding: 0 10px; color: #fff; font-size: 12.5px; font-weight: 700; min-width: 44px; transition: width .3s; }

/* ============ 合同上传 ============ */
.upload-box {
  border: 2px dashed #cbd5e1; border-radius: 10px; padding: 26px 16px; text-align: center;
  color: var(--muted); cursor: pointer; transition: all .15s; background: #f8fafc; margin-bottom: 12px;
}
.upload-box:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.upload-box.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-hint { font-size: 14px; }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.file-icon { font-size: 22px; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ 角色徽标 ============ */
.role-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.role-admin { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.role-op { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
