:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-soft: #eff4ff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3a8a,#2563eb); padding: 24px; }
.login-card { width: 380px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-brand { text-align: center; margin-bottom: 22px; }
.logo { width: 56px; height: 56px; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; letter-spacing: 1px; }
.logo-slot { position: relative; overflow: hidden; }
.logo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; position: relative; z-index: 2; }
.logo-slot .logo-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1; }
.logo-slot:not(.no-img) .logo-fallback { display: none; }
.logo-slot.no-img img { display: none; }
.logo-slot.sm { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; background: var(--brand); color: #fff; font-weight: 800; font-size: 13px; vertical-align: -6px; margin-right: 8px; flex: none; }
.logo-slot.sm.no-img { background: var(--brand); }
.login-brand h1 { font-size: 20px; margin: 0 0 4px; }
.login-brand p { color: var(--muted); margin: 0; font-size: 13px; }
#loginForm label { display: block; margin: 14px 0; font-size: 13px; color: var(--muted); }
#loginForm input { width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; }
.btn-primary { width: 100%; padding: 12px; border: none; border-radius: 8px; background: var(--brand); color: #fff; font-size: 15px; font-weight: 600; margin-top: 8px; }
.btn-primary:hover { background: #1d4ed8; }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }
.demo-hint { margin-top: 18px; font-size: 12px; color: var(--muted); background: var(--brand-soft); padding: 10px 12px; border-radius: 8px; line-height: 1.6; }

/* 布局 */
.app { display: flex; height: 100vh; }
.sidebar { width: 220px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; padding: 16px 12px; }
.side-brand { font-weight: 700; color: #fff; padding: 8px 10px 18px; font-size: 15px; }
#nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
#nav a { padding: 11px 12px; border-radius: 8px; color: #cbd5e1; text-decoration: none; font-size: 14px; }
#nav a:hover { background: #1e293b; }
#nav a.active { background: var(--brand); color: #fff; }
.side-user { border-top: 1px solid #1e293b; padding-top: 12px; }
#userMeta { font-size: 13px; margin-bottom: 8px; color: #e2e8f0; }
.btn-ghost { width: 100%; background: transparent; border: 1px solid #334155; color: #cbd5e1; padding: 8px; border-radius: 8px; }
.btn-ghost:hover { background: #1e293b; }
.main { flex: 1; overflow: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 26px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h2 { margin: 0; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; }
.view { padding: 22px 26px; }

/* 卡片/网格 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi .value.small { font-size: 18px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; background: #fafbfc; }
.btn-sm { padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: 7px; font-size: 13px; }
.btn-sm.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-sm.danger { color: var(--red); border-color: #fecaca; }
.btn-sm:hover { filter: brightness(.97); }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }

/* 标签 */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-A { background: #fee2e2; color: #b91c1c; }
.tag-B { background: #fef3c7; color: #b45309; }
.tag-C { background: #e0e7ff; color: #4338ca; }
.tag-潜在 { background: #e0e7ff; color: #4338ca; }
.tag-意向 { background: #fef3c7; color: #b45309; }
.tag-成交 { background: #dcfce7; color: #15803d; }
.tag-流失 { background: #f1f5f9; color: #64748b; }
.tag-已撤回 { background: #f1f5f9; color: #64748b; }
.sev-高 { background: #fee2e2; color: #b91c1c; }
.sev-中 { background: #fef3c7; color: #b45309; }
.sev-低 { background: #e0e7ff; color: #4338ca; }

/* 问题清单 */
.issue { border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.issue.high { border-left-color: var(--red); }
.issue.mid { border-left-color: var(--amber); }
.issue.low { border-left-color: var(--brand); }
.issue h4 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.issue .detail { color: #374151; font-size: 13px; line-height: 1.6; }
.issue .sug { margin-top: 8px; font-size: 13px; color: #047857; background: #ecfdf5; padding: 8px 10px; border-radius: 6px; }
.issue .items { margin-top: 8px; font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 40px; }
.followup-item { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; font-size: 13px; line-height: 1.6; }
.followup-item b { color: #334155; font-size: 12px; }
.alert-good { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; padding: 14px; border-radius: 8px; }

/* 图表 */
.chart-wrap { width: 100%; overflow-x: auto; }
svg { display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.report-box { white-space: pre-wrap; background: #f8fafc; border: 1px dashed var(--line); border-radius: 8px; padding: 14px; font-size: 13px; line-height: 1.7; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* 综合总览矩阵：列多，需横向滚动；姓名与团队列吸附在左侧，滚动时不丢失定位 */
.sum-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.sum-matrix { min-width: 900px; border-collapse: separate; border-spacing: 0; }
.sum-matrix th, .sum-matrix td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sum-matrix thead th { background: #fafbfc; color: var(--muted); font-weight: 600; }
.sum-matrix thead .sum-period { text-align: center; border-left: 1px solid var(--line); background: var(--brand-soft); color: #1e40af; }
.sum-matrix .sum-sortable { cursor: pointer; user-select: none; }
.sum-matrix .sum-sortable:hover { background: #eef4ff; }
.sum-matrix .sum-sorted { color: var(--brand); background: #eef4ff; }
.sum-matrix .sum-num { text-align: right; font-variant-numeric: tabular-nums; }
.sum-matrix .col-total { font-weight: 700; background: #f8fafc; }
.sum-matrix .sum-zero { color: #cbd5e1; }
.sum-matrix .col-name, .sum-matrix .col-team { position: sticky; background: #fff; z-index: 2; }
.sum-matrix .col-name { left: 0; width: 110px; min-width: 110px; font-weight: 600; }
.sum-matrix .col-team { left: 110px; width: 120px; min-width: 120px; color: var(--muted); }
.sum-matrix thead .col-name, .sum-matrix thead .col-team { background: #fafbfc; z-index: 4; }
.sum-matrix tbody tr:hover td { background: #f8fbff; }
.sum-matrix tbody tr:hover .col-total { background: #eef4ff; }
.sum-matrix tfoot td { background: #e6edff; font-weight: 700; color: #1e3a8a; border-top: 2px solid var(--brand); border-bottom: none; }
.sum-matrix tfoot .col-total { background: #cddcff; }
.sum-matrix tfoot .col-name, .sum-matrix tfoot .col-team { background: #e6edff; z-index: 3; }
