/* 咨询集团管理平台 — 企业级数据密集型风格 */
:root {
  --primary: #1E40AF;
  --primary-light: #3B82F6;
  --primary-bg: #EFF6FF;
  --accent: #F59E0B;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-muted: #475569;
  --border: #E2E8F0;
  --green: #059669;
  --red: #DC2626;
  --radius: 8px;
  --sidebar-w: 216px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #0F1E4D; color: #CBD5E1;
  position: fixed; top: 0; bottom: 0; left: 0; padding: 20px 12px; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar .brand {
  color: #fff; font-size: 17px; font-weight: 700; padding: 4px 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 14px; letter-spacing: 1px;
}
.sidebar .brand small { display: block; font-size: 11px; font-weight: 400; color: #94A3B8; letter-spacing: 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 2px;
  color: #CBD5E1; border-radius: 6px; font-size: 14px; transition: background .2s, color .2s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar .nav-group { font-size: 11px; color: #64748B; padding: 14px 12px 4px; letter-spacing: 1px; }
.main { flex: 1; margin-left: var(--sidebar-w); padding: 22px 26px 60px; min-width: 0; }

/* ---------- 页头 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 20px; font-weight: 700; }
.page-head .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- KPI 卡片 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
a.kpi { display: block; color: inherit; text-decoration: none !important; cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s; }
a.kpi:hover { border-color: var(--primary-light); box-shadow: 0 3px 12px rgba(30,64,175,.12); }
.kpi .label { font-size: 12px; color: var(--text-muted); }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.kpi.accent .value { color: var(--accent); }
.kpi.green .value { color: var(--green); }
.kpi.red .value { color: var(--red); }
.kpi.blue .value { color: var(--primary); }

/* ---------- 卡片与图表 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.chart-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.chart-grid .card { margin-bottom: 0; }
.chart-box { position: relative; height: 240px; }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 8px 10px; background: #F1F5F9; color: var(--text-muted);
  font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
table.data td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:hover td { background: var(--primary-bg); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 700; background: #F8FAFC; border-top: 2px solid var(--border); }
.pos { color: var(--green); } .neg { color: var(--red); }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; white-space: nowrap; }
.tag.st-进行中 { background: #DBEAFE; color: #1D4ED8; }
.tag.st-已完成 { background: #D1FAE5; color: #047857; }
.tag.st-暂时停滞 { background: #FEF3C7; color: #B45309; }
.tag.st-意向中 { background: #F3E8FF; color: #7E22CE; }
.tag.st-投标 { background: #FFE4E6; color: #BE123C; }
.tag.st-已终止 { background: #F1F5F9; color: #64748B; }
.tag.st-已失败 { background: #FEE2E2; color: #B91C1C; }
.tag.st-已签约 { background: #D1FAE5; color: #047857; }
.tag.st-投标中 { background: #FEF3C7; color: #B45309; }
.tag.st-跟进中 { background: #DBEAFE; color: #1D4ED8; }
.tag.st-意向 { background: #F3E8FF; color: #7E22CE; }
.tag.st-待回款 { background: #FEF3C7; color: #B45309; }
.tag.st-已回款 { background: #D1FAE5; color: #047857; }
.tag.st-已取消 { background: #F1F5F9; color: #64748B; }
.tag.line { background: #E0E7FF; color: #3730A3; }

/* ---------- 按钮与表单 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px;
  border: 1px solid transparent; background: var(--primary); color: #fff; font-size: 13px;
  cursor: pointer; transition: background .2s; text-decoration: none !important; font-family: inherit;
}
.btn:hover { background: #18348C; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #F1F5F9; }
.btn.danger { background: var(--surface); color: var(--red); border-color: var(--border); }
.btn.danger:hover { background: #FEF2F2; border-color: #FECACA; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #D97706; }

input, select, textarea {
  font-family: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); outline-offset: 0; border-color: var(--primary-light); }
label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { min-width: 120px; flex: 1; }
.inline-form .btn { flex: 0; }

/* ---------- 筛选栏 ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 130px; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  padding: 9px 18px; border: none; background: none; font-size: 14px; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs button:hover { color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---------- 弹窗 ---------- */
dialog {
  border: none; border-radius: 10px; padding: 22px; width: min(560px, 92vw);
  box-shadow: 0 20px 50px rgba(15,23,42,.25);
}
dialog::backdrop { background: rgba(15,23,42,.45); }
dialog h3 { font-size: 16px; margin-bottom: 14px; }

/* ---------- 盈亏平衡大数字卡 ---------- */
.bep-nums { display: flex; gap: 26px; align-items: flex-end; margin: 10px 0 12px; flex-wrap: wrap; }
.bep-num .v { font-size: 36px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.bep-num .u { font-size: 15px; font-weight: 600; margin-left: 2px; color: var(--text-muted); }
.bep-num .l { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.bep-num.target .v { color: var(--text-muted); }
.bep-num.done-red .v { color: var(--red); }
.bep-num.done-green .v { color: var(--green); }
.bep-num.pct .v { color: var(--primary); }
.card.bep-win {
  background: linear-gradient(135deg, #ECFDF5 0%, #FFFBEB 100%);
  border: 1.5px solid #F59E0B;
  box-shadow: 0 4px 20px rgba(245, 158, 11, .18);
  position: relative; overflow: hidden;
}
.card.bep-win::after {
  content: ''; position: absolute; top: 0; left: -80%; width: 60%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.7), transparent);
  animation: bepShine 3.2s ease-in-out infinite; pointer-events: none;
}
@keyframes bepShine { 0% { left: -80%; } 55%, 100% { left: 120%; } }
@media (prefers-reduced-motion: reduce) { .card.bep-win::after { animation: none; } }
.bep-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: linear-gradient(135deg, #F59E0B, #D97706); color: #fff;
  font-size: 12px; font-weight: 800; padding: 3px 12px; border-radius: 99px; letter-spacing: 1px;
}
.bep-badge svg { width: 14px; height: 14px; }

/* ---------- NEW 徽标 ---------- */
.badge-new {
  display: inline-block; background: linear-gradient(135deg, #F59E0B, #DC2626); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .5px; padding: 1px 6px;
  border-radius: 4px; margin-right: 6px; vertical-align: 1px;
}

/* ---------- 业绩进度条 ---------- */
.pbar-wrap { margin: 8px 0 4px; }
.pbar {
  height: 26px; background: #E2E8F0; border-radius: 99px; position: relative;
}
.pbar .fill { overflow: hidden; }
.pbar::after {
  content: ''; position: absolute; left: calc(50% - 1px); top: 5px; bottom: 5px; width: 2px;
  background: rgba(255,255,255,.95); border-radius: 1px; z-index: 2;
}
.pbar-scale {
  display: flex; justify-content: space-between; align-items: flex-start;
  font-size: 11px; color: var(--text-muted); margin-top: 3px;
}
.pbar-scale .mid { color: #334155; font-weight: 700; text-align: center; }
.pbar .fill.danger { background: linear-gradient(90deg, #F87171, #DC2626); }
.pbar .fill.alive { background: linear-gradient(90deg, #FBBF24, #84CC16); }
.pbar .fill {
  height: 100%; border-radius: 99px; transition: width .6s ease;
  background: linear-gradient(90deg, #F59E0B, #DC2626);
  display: flex; align-items: center; justify-content: flex-end; padding-right: 10px;
  color: #fff; font-size: 12px; font-weight: 700; min-width: 46px;
}
.pbar .fill.done { background: linear-gradient(90deg, #10B981, #059669); }
.pbar-msg { font-size: 15px; font-weight: 700; margin-top: 6px; }
.pbar-msg.gap { color: var(--red); }
.pbar-msg.win { color: var(--green); }
.pbar-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- 其他 ---------- */
.flash {
  background: #ECFDF5; border: 1px solid #A7F3D0; color: #047857;
  padding: 9px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13px;
}
.muted { color: var(--text-muted); font-size: 12px; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clickable { cursor: pointer; }
.progress-cell { max-width: 380px; font-size: 12px; color: var(--text-muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* ---------- 移动端导航 ---------- */
.mobile-topbar { display: none; }
.nav-mask { display: none; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0;
    height: 50px; background: #0F1E4D; color: #fff; z-index: 60; padding: 0 14px;
  }
  .mobile-topbar .hamburger { background: none; border: none; color: #fff; cursor: pointer; padding: 4px; }
  .mobile-topbar .mt-title { font-weight: 700; font-size: 15px; }
  .mobile-topbar .mt-badge { margin-left: auto; color: #fff; position: relative; display: flex; }
  .mobile-topbar .mt-badge span {
    position: absolute; top: -6px; right: -8px; background: #DC2626; border-radius: 99px;
    font-size: 10px; font-weight: 700; padding: 0 5px; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 70; width: 240px; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-mask {
    display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 65; }
  .main { margin-left: 0; padding: 64px 12px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .bep-num .v { font-size: 26px; }
  .page-head h1 { font-size: 17px; }
  .form-grid { grid-template-columns: 1fr; }
  dialog { width: 94vw; padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
