:root {
  --navy-900: #12233d;
  --navy-800: #1a3355;
  --navy-700: #24456f;
  --navy-100: #eef2f7;
  --gold-500: #b8860b;
  --gold-600: #9c7009;
  --gold-100: #fdf3dd;
  --ink: #1c2530;
  --muted: #6b7686;
  --border: #e2e6ec;
  --bg: #f6f7fa;
  --white: #ffffff;
  --green: #2f8f5b;
  --green-bg: #e7f5ec;
  --blue: #2564c9;
  --blue-bg: #e8f0fd;
  --red: #c0392b;
  --red-bg: #fbe9e7;
  --gray: #7a8598;
  --gray-bg: #eef0f3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(18, 35, 61, 0.06), 0 1px 8px rgba(18, 35, 61, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--navy-700); text-decoration: none; }
a:hover { color: var(--gold-600); }

/* ---------- 布局 ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--navy-900);
  color: #cfd9e8;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.sidebar .brand {
  padding: 0 20px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}
.sidebar .brand small { display:block; font-weight:400; font-size:11px; color:#8fa3c2; margin-top:4px; letter-spacing:0.5px;}

.sidebar nav a {
  display: block;
  padding: 11px 20px;
  color: #b9c6da;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar nav a.active {
  background: rgba(184,134,11,0.15);
  border-left-color: var(--gold-500);
  color: #fff;
  font-weight: 600;
}

.sidebar .user-box {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
  color: #8fa3c2;
}
.sidebar .user-box .uname { color: #fff; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.sidebar .user-box a { display:inline-block; margin-top:8px; color:#8fa3c2; font-size:12px; }
.sidebar .user-box a:hover { color: var(--gold-500); }

.main {
  flex: 1;
  padding: 28px 36px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 20px; margin: 0; font-weight: 700; color: var(--navy-900); }
.page-header .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-900); color: #fff; }
.btn-gold { background: var(--gold-500); color: #fff; }
.btn-gold:hover { background: var(--gold-600); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--navy-700); color: var(--navy-800); }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 卡片 / 表格 ---------- */

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--navy-900); }
.stat-card.accent-gold .value { color: var(--gold-500); }
.stat-card.accent-green .value { color: var(--green); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.3px; }
tr:hover td { background: var(--navy-100); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-open { background: var(--gray-bg); color: var(--gray); }
.badge-following { background: var(--blue-bg); color: var(--blue); }
.badge-won { background: var(--green-bg); color: var(--green); }
.badge-lost { background: var(--red-bg); color: var(--red); }

.owner-tag {
  display: inline-flex; align-items:center; gap:5px;
  background: var(--gold-100); color: var(--gold-600); border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}

/* ---------- 表单 ---------- */

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; color: var(--navy-900); margin-bottom: 6px; }
.form-row .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=tel], input[type=email],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(36,69,111,0.1); }
textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- 登录页 ---------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
}
.login-box {
  background: #fff; border-radius: 12px; padding: 40px 36px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box .logo { font-size: 20px; font-weight: 700; color: var(--navy-900); margin-bottom: 4px; }
.login-box .logo-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 26px; }
.login-box .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }

/* ---------- 提示 ---------- */

.flash { padding: 11px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input[type=text] { width: auto; min-width: 140px; }

.timeline-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.timeline-item .meta strong { color: var(--navy-800); }

.protection-note {
  background: var(--gold-100); border: 1px solid #f0dfa8; color: var(--gold-600);
  border-radius: 6px; padding: 10px 14px; font-size: 12.5px; margin-bottom: 16px;
}

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  /* 数据量比较大的表格（客户列表、线索列表、仪表板明细等）在手机窄屏下改成
     卡片内部横向滑动查看，而不是把整个页面撑宽、挤压所有文字 */
  .card:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card table { min-width: 640px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-header > div:last-child, .page-header > a { align-self: flex-start; }
  .filter-bar { flex-wrap: wrap; }
}

/* ---------- 销售阶段进度条 ---------- */

.stage-track { display: flex; align-items: center; padding: 8px 0; }
.stage-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.stage-dot {
  width: 30px; height: 30px; border-radius: 50%; background: var(--gray-bg); color: var(--gray);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  border: 2px solid var(--border);
}
.stage-step.done .stage-dot { background: var(--green); color: #fff; border-color: var(--green); }
.stage-step.active .stage-dot { background: var(--gold-500); color: #fff; border-color: var(--gold-500); }
.stage-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stage-step.active .stage-label { color: var(--gold-600); font-weight: 600; }
.stage-step.done .stage-label { color: var(--green); }
.stage-connector { flex: 1; height: 2px; background: var(--border); margin: 0 8px; margin-bottom: 20px; min-width: 20px; }
.stage-connector.done { background: var(--green); }

.stage-chip {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--gold-100); color: var(--gold-600);
}

.amount-tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
  background: var(--green-bg); color: var(--green);
}

/* ---------- 联系人卡片 ---------- */

.contact-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.contact-item:last-child { border-bottom: none; }

/* ---------- 排行榜 ---------- */

.leaderboard-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-rank {
  width: 24px; height: 24px; border-radius: 50%; background: var(--navy-100); color: var(--navy-800);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.leaderboard-row:nth-child(1) .leaderboard-rank { background: var(--gold-500); color: #fff; }
.leaderboard-row:nth-child(2) .leaderboard-rank { background: #a8adb5; color: #fff; }
.leaderboard-row:nth-child(3) .leaderboard-rank { background: #b08d57; color: #fff; }
.leaderboard-name { width: 90px; flex-shrink: 0; font-size: 13.5px; font-weight: 600; }
.leaderboard-bar-wrap { flex: 1; background: var(--navy-100); border-radius: 4px; height: 10px; overflow: hidden; }
.leaderboard-bar { height: 100%; background: linear-gradient(90deg, var(--gold-500), var(--gold-600)); border-radius: 4px; min-width: 2px; }
.leaderboard-amount { width: 160px; flex-shrink: 0; text-align: right; font-size: 13px; font-weight: 700; color: var(--navy-900); }

/* ---------- 侧边栏折叠分类 ---------- */

.nav-group { margin-top: 4px; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 20px; color: #b9c6da; font-size: 14px; cursor: pointer; user-select: none;
}
.nav-group-title:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-caret { transition: transform 0.15s ease; font-size: 12px; }
.nav-group-title.expanded .nav-caret { transform: rotate(90deg); }
.nav-submenu { max-height: 0; overflow: hidden; transition: max-height 0.2s ease; }
.nav-submenu.open { max-height: 300px; }
.nav-submenu a {
  display: block; padding: 9px 20px 9px 40px; color: #96a6bf; font-size: 13px; border-left: 3px solid transparent;
}
.nav-submenu a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-submenu a.active { background: rgba(184,134,11,0.15); border-left-color: var(--gold-500); color: #fff; font-weight: 600; }

/* ---------- 简易柱状图（仪表板分析页用，纯CSS不依赖外部图表库） ---------- */

.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 10px 4px; }
.bar-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar-chart-bar {
  width: 60%; background: linear-gradient(180deg, var(--gold-500), var(--navy-700)); border-radius: 4px 4px 0 0;
  min-height: 2px; transition: height 0.3s ease;
}
.bar-chart-value { font-size: 11px; color: var(--navy-800); font-weight: 700; }
.bar-chart-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

.hbar-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.hbar-label { width: 90px; flex-shrink: 0; font-size: 13px; font-weight: 600; }
.hbar-track { flex: 1; background: var(--navy-100); border-radius: 4px; height: 16px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--navy-700), var(--gold-500)); border-radius: 4px; }
.hbar-value { width: 140px; flex-shrink: 0; text-align: right; font-size: 12.5px; color: var(--navy-900); font-weight: 600; }

/* ---------- 线索/产品列表小元素 ---------- */

.lead-status-new { background: var(--gray-bg); color: var(--gray); }
.lead-status-contacted { background: var(--blue-bg); color: var(--blue); }
.lead-status-converted { background: var(--green-bg); color: var(--green); }
.lead-status-invalid { background: var(--red-bg); color: var(--red); }

.product-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px;
  background: var(--navy-100); color: var(--navy-800); font-size: 12px; font-weight: 600; margin: 3px 4px 3px 0;
}
.product-tag button { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; line-height: 1; }
.product-tag button:hover { color: var(--red); }

/* ---------- 消息通知 ---------- */

.notif-bell {
  display: flex; align-items: center; gap: 6px; color: #cfd9e8 !important; font-size: 13px; font-weight: 600;
  position: relative;
}
.notif-bell:hover { color: #fff !important; }
.notif-badge {
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 1px 7px; margin-left: 2px;
}
.notif-item {
  display: flex; gap: 12px; align-items: start; padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.notif-item:hover { background: var(--navy-100); }
.notif-item.unread { background: var(--gold-100); }
.notif-item.unread:hover { background: #fbecc4; }
.notif-icon { font-size: 18px; flex-shrink: 0; }

/* ---------- 帮助页 ---------- */

.help-toc { display: flex; flex-wrap: wrap; gap: 8px; }
.help-toc a {
  padding: 6px 14px; background: var(--navy-100); border-radius: 20px; font-size: 13px;
  color: var(--navy-800); font-weight: 600;
}
.help-toc a:hover { background: var(--gold-100); color: var(--gold-600); }
.card h4 { font-size: 14px; color: var(--navy-800); margin: 18px 0 6px; }
.card h4:first-of-type { margin-top: 4px; }
.card ul { margin: 6px 0; padding-left: 20px; }
.card ul li { margin-bottom: 4px; font-size: 13.5px; }
.card p { font-size: 13.5px; line-height: 1.7; }

/* ---------- 查重提醒 ---------- */

.duplicate-warning {
  border-color: #f0dfa8;
  background: linear-gradient(180deg, var(--gold-100), #fff 40%);
}

/* ---------- Logo ---------- */

.brand-logo { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; }
.login-logo-img { width: 56px; height: 56px; border-radius: 50%; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }

/* ---------- 销售漏斗 ---------- */

.funnel-row { margin-bottom: 10px; }
.funnel-bar {
  background: linear-gradient(90deg, var(--navy-700), var(--gold-500));
  color: #fff; padding: 10px 16px; border-radius: 6px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; min-width: 120px; transition: width 0.3s ease;
}
.funnel-conv { text-align: center; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* 打印/导出PDF专用样式：用于"仪表板"页面点"打印/导出PDF"时，
   隐藏侧边栏、筛选表单等操作类元素，只保留统计数据本身，方便开会用 */
@media print {
  .sidebar, .no-print, .flash { display: none !important; }
  .app-shell { display: block !important; }
  .main { margin: 0 !important; padding: 12px !important; width: 100% !important; }
  .print-header { display: block !important; margin-bottom: 16px; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; page-break-inside: avoid; }
  body { background: #fff !important; }
}
