:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; width: 100%; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); padding: 36px 32px; border-radius: 12px; box-shadow: var(--shadow); width: 340px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.btn { background: var(--primary); color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-size: 14px; }
.btn:hover { background: var(--primary-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f3f4f6; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: #111827; color: #e5e7eb; padding: 18px 0; flex-shrink: 0; position: relative; }
.sidebar .brand { padding: 0 20px 18px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid #1f2937; margin-bottom: 10px; }
.sidebar a { display: block; padding: 11px 20px; color: #cbd5e1; text-decoration: none; font-size: 14px; border-left: 3px solid transparent; }
.sidebar a:hover { background: #1f2937; color: #fff; }
.sidebar a.active { background: #1f2937; color: #fff; border-left-color: var(--primary); }
.sidebar .ver { position: absolute; bottom: 10px; left: 0; right: 0; padding: 8px 20px; font-size: 11px; color: #6b7280; border-top: 1px solid #1f2937; }
.main { flex: 1; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.topbar .title { font-weight: 600; font-size: 16px; }
.topbar .user { color: var(--muted); font-size: 13px; display: flex; gap: 14px; align-items: center; }
.content { padding: 24px; overflow: auto; flex: 1; }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }

/* 批量操作栏（管理员） */
.bulk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.bulk-bar strong { color: var(--accent); }
.bulk-bar select { width: auto; min-width: 160px; }
.bulk-bar .muted { font-size: 12px; }

/* 卡片/统计 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.warn .num { color: var(--warn); }
.stat.success .num { color: var(--success); }
/* 可点击卡片（仪表盘跳转） */
.stat.link { cursor: pointer; transition: transform .08s ease, box-shadow .08s ease, border-color .08s ease; }
.stat.link:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: 0 4px 12px rgba(37,99,235,.15); }
.stat.link::after { content: "›"; float: right; color: var(--muted); font-size: 20px; line-height: 1; opacity: .55; }
.stat.link:hover::after { color: var(--primary); }

/* 导航排序 */
.nav-order { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.nav-row { display: flex; align-items: center; gap: 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.nav-row .nav-ctrl { display: flex; gap: 4px; }
.nav-row .chk { margin: 0; }
.nav-row .chk.locked { color: var(--muted); }


.panel { background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--muted); font-weight: 600; background: #fafafa; }
tr:hover td { background: #f9fafb; }
.tag { display: inline-block; background: #eef2ff; color: var(--primary-dark); border-radius: 4px; padding: 1px 8px; font-size: 12px; margin: 1px 3px 1px 0; }

/* 看板 */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: #eef1f6; border-radius: 10px; width: 250px; flex-shrink: 0; padding: 10px; }
.kcol.dragover { outline: 2px dashed var(--primary); }
.kcol-head { font-weight: 600; font-size: 13px; margin-bottom: 10px; display: flex; justify-content: space-between; }
.kcol-head .cnt { color: var(--muted); font-weight: 400; }
.kcard { background: #fff; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard .pname { font-weight: 600; margin-bottom: 6px; }
.kcard .meta { color: var(--muted); font-size: 12px; line-height: 1.6; }
.kcard select { margin-top: 8px; font-size: 12px; padding: 4px 6px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 92vw; max-height: 90vh; overflow: auto; padding: 22px 24px; }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal .field { margin-bottom: 12px; }
.modal .field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.modal .row { display: flex; gap: 12px; }
.modal .row > div { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.empty { color: var(--muted); text-align: center; padding: 30px; }
.overdue { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); }
.flex { display: flex; gap: 8px; align-items: center; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.primary { background: #eff6ff; color: #1d4ed8; }

/* 来源管理表格内按钮间距 */
.src-acts .btn { margin: 0 2px; }

/* 复选框组（标签 / 产品多选） */
.chk-group { display: flex; flex-wrap: wrap; gap: 10px 16px; padding: 6px 0; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); cursor: pointer; }
.chk input { width: auto; }

/* 跟进时间线 */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.tl-item { border-left: 3px solid var(--primary); padding: 6px 0 6px 14px; }
.tl-head { font-size: 13px; }
.tl-body { margin-top: 4px; font-size: 14px; }

/* 提醒中心 */
.rem-item { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 4px; background: #fff; }
.rem-item.read { opacity: .58; }
.rem-item:not(.read) { border-left: 3px solid var(--warn); }
.rem-title { font-weight: 600; font-size: 14px; }
.rem-msg { font-size: 14px; line-height: 1.5; }
.rem-actions { display: flex; gap: 6px; margin-top: 4px; }

/* 左侧导航未读角标 */
.sidebar a { position: relative; }
.nav-badge {
  display: inline-block; min-width: 18px; height: 18px; line-height: 18px;
  padding: 0 5px; margin-left: 6px; border-radius: 9px;
  background: #ef4444; color: #fff; font-size: 11px; text-align: center; vertical-align: middle;
}

/* 右下角提醒弹窗 */
#toast-box { position: fixed; right: 20px; bottom: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 8px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
  cursor: pointer; animation: toast-in .22s ease-out; transition: opacity .35s, transform .35s;
}
.toast:hover { box-shadow: 0 10px 28px rgba(15, 23, 42, .26); }
.toast.fade { opacity: 0; transform: translateY(6px); }
.toast-t { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.toast-m { font-size: 13px; color: #475569; line-height: 1.5; }
.toast-h { font-size: 12px; color: var(--primary); margin-top: 6px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* 报价明细 */
.quo-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.quo-item { display: flex; gap: 6px; align-items: center; }
.quo-item input { padding: 6px 8px; }

/* 报表合计行 */
.total-row td { background: #f0f4ff; font-weight: 700; }

/* 待办附件 */
.attach-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.attach-item { display: flex; align-items: center; gap: 8px; background: #f3f4f6; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.attach-item a { color: var(--primary); text-decoration: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item a:hover { text-decoration: underline; }
.att-link { color: var(--primary); text-decoration: none; }
.att-link:hover { text-decoration: underline; }

/* ===================== 数据分析 ===================== */
.an-toolbar { flex-wrap: wrap; gap: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg .btn { border: none; border-radius: 0; background: #fff; color: var(--text); }
.seg .btn + .btn { border-left: 1px solid var(--border); }
.seg .btn.active { background: var(--primary); color: #fff; }
.seg .btn.active:hover { background: var(--primary-dark); }
.an-sel { width: auto; min-width: 150px; }
.an-days { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.an-days input { width: 74px; }

.an-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.an-kpis.small { grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.an-kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.an-kpis.small .an-kpi { padding: 10px 12px; box-shadow: none; }
.an-kl { font-size: 12px; color: var(--muted); }
.an-kv { font-size: 22px; font-weight: 600; margin: 4px 0 2px; letter-spacing: -.4px; }
.an-kpis.small .an-kv { font-size: 17px; }
.an-ke { font-size: 11px; color: var(--muted); }
.an-kpi.c-blue .an-kv { color: var(--primary); }
.an-kpi.c-teal .an-kv { color: #0f766e; }
.an-kpi.c-coral .an-kv { color: #c2410c; }
.an-kpi.c-purple .an-kv { color: #6d28d9; }

.an-card { margin-bottom: 16px; }
.an-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.an-head h3 { margin: 0; font-size: 15px; }
.an-head .muted { font-size: 12px; }

.an-grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.an-grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
.an-grid2.wide { gap: 16px; }
.an-tcell { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px 2px; }
.an-tlabel { font-size: 12px; color: var(--muted); }
.an-tcell svg { display: block; }

.an-bars { display: flex; flex-direction: column; gap: 7px; }
.an-bar { display: grid; grid-template-columns: 92px 1fr 96px; align-items: center; gap: 8px; font-size: 12px; }
.an-bl { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-bt { background: #eef2f7; border-radius: 999px; height: 8px; overflow: hidden; }
.an-bt i { display: block; height: 100%; border-radius: 999px; }
.an-bv { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.an-funnel { display: flex; flex-direction: column; gap: 6px; align-items: center; margin-bottom: 6px; }
.an-fstep { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.an-fbar { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px; background: #e8effb; color: #1e3a8a; font-size: 13px; }
.an-fbar b { font-size: 15px; }
.an-fstep:nth-child(2) .an-fbar { background: #dbe9f9; }
.an-fstep:nth-child(3) .an-fbar { background: #cfe1f7; }
.an-fstep:nth-child(4) .an-fbar { background: #c3d9f4; }
.an-fstep:nth-child(5) .an-fbar { background: #b7d1f2; }
.an-fmeta { font-size: 11px; color: var(--muted); }
.an-fmeta b { color: var(--primary); }

.an-note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.7; }
.an-note b { color: var(--text); }
.an-sub { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.an-tw { overflow-x: auto; }
.ta-r { text-align: right; white-space: nowrap; }
th.ta-r { text-align: right; }
.an-warn { color: var(--warn); font-weight: 500; }
.an-danger { color: var(--danger); font-weight: 500; }
.an-mini { display: inline-block; width: 48px; height: 6px; background: #eef2f7; border-radius: 999px;
  overflow: hidden; vertical-align: middle; margin-right: 6px; }
.an-mini i { display: block; height: 100%; background: var(--success); }

@media (max-width: 1180px) {
  .an-grid4 { grid-template-columns: repeat(2, 1fr); }
  .an-kpis { grid-template-columns: repeat(2, 1fr); }
  .an-kpis.small { grid-template-columns: repeat(3, 1fr); }
  .an-grid2 { grid-template-columns: 1fr; }
}
