:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --line: #e5e7eb;
  --brand: #ff7a00;
  --brand-dark: #e56a00;
  --red: #e5484d;
  --red-bg: #fef0f0;
  --green: #16a34a;
  --green-bg: #eefaf1;
  --blue: #2f80ed;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* 顶栏 */
.topbar { background: #1f2937; color: #fff; }
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.1); color: #fff;
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; text-decoration: none;
  transition: background .15s;
}
.topbar-btn:hover { background: var(--brand); }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
}
.brand h1 { font-size: 18px; font-weight: 600; }
.period { color: #cbd5e1; font-size: 12px; margin-top: 2px; }
.topbar-note { color: #9ca3af; font-size: 12px; }

/* 概览 */
.overview {
  max-width: 1180px; margin: 20px auto 0; padding: 0 24px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--text-2); font-size: 12px; margin-top: 4px; }
.stat.red .num { color: var(--red); }
.stat.green .num { color: var(--green); }
.stat.blue .num { color: var(--blue); }
.stat.orange .num { color: var(--brand); }

/* 主容器 */
.container { max-width: 1180px; margin: 0 auto; padding: 24px; }
.container.narrow { max-width: 860px; }

.section-title { margin: 28px 0 14px; }
.section-title h2 { font-size: 16px; font-weight: 600; }
.section-title p { color: var(--text-2); font-size: 12px; margin-top: 4px; }

/* 部门网格 */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }

.dept-card .dept-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px;
}
.dept-head .dept-info h3 { font-size: 15px; font-weight: 600; }
.dept-head .dept-info .owner { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.dept-tag { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.dept-tag.weak { background: var(--red-bg); color: var(--red); }
.dept-tag.ok { background: var(--green-bg); color: var(--green); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: 8px; padding: 7px 12px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); }
.btn-ghost { background: #f3f4f6; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: #e9ecef; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #128a3c; }

/* 指标表 */
.metric-table { width: 100%; border-collapse: collapse; }
.metric-table th, .metric-table td { padding: 7px 6px; text-align: left; font-size: 13px; }
.metric-table th { color: var(--text-2); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--line); }
.metric-table td { border-bottom: 1px solid #f3f4f6; }
.metric-table tr.weak-row td { background: var(--red-bg); }
.metric-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.metric-table .rate { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.metric-table .rate.low { color: var(--red); }
.metric-table .rate.high { color: var(--green); }
.badge {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; font-weight: 600;
}
.badge.weak { background: var(--red); color: #fff; }
.badge.ok { background: #d1d5db; color: #374151; }
.badge.pending-target { background:#fef3c7; color:#92400e; font-size:10px; padding:1px 6px; margin-left:4px; border-radius:8px; font-weight:500; }
.copy-link-btn { margin-top: 12px; width: 100%; justify-content: center; }

/* 整改看板折叠已删除 */


/* 整改页 */
.intro { background: #fff7ed; border: 1px solid #ffd7a8; border-radius: 10px; padding: 12px 16px; font-size: 13px; color: #92400e; margin-bottom: 16px; }
.weak-block { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.weak-block .w-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.weak-block .w-name { font-weight: 600; font-size: 15px; }
.weak-block .w-gap { color: var(--red); font-size: 13px; font-weight: 600; }
.weak-block .w-desc { color: var(--text-2); font-size: 13px; margin-bottom: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; font-family: inherit; background: #fff;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,122,0,0.12); }
.field textarea { resize: vertical; min-height: 70px; }

.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 13px; }
.history-item .h-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.history-item .h-name { font-weight: 600; }
.history-item .h-desc { color: var(--text-2); }

.empty { text-align: center; color: var(--text-2); padding: 30px 0; font-size: 13px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 部门专属面板 */
.dept-source { color: var(--text-2); font-size: 11px; margin-bottom: 10px; }
.ov-panel { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.ov-title { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.ov-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ov-item { background: #f9fafb; border-radius: 8px; padding: 8px 10px; }
.ov-item.link { cursor: pointer; transition: all .15s; border: 1px solid transparent; }
.ov-item.link:hover { background: #fff7ed; border-color: #ffd7a8; }
.ov-item.link .ov-lbl::after { content: ' ▸'; color: var(--brand); font-weight: 600; }
.ov-item .ov-val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ov-item .ov-lbl { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.ov-item .ov-note { font-size: 10px; color: var(--red); margin-top: 3px; line-height: 1.3; }

/* 订单构成弹窗条形图 */
.bd-section { margin-top: 16px; }
.bd-section:first-child { margin-top: 0; }
.bd-title { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.bd-source { font-size: 11px; color: var(--text-2); margin-bottom: 10px; }
.bd-bars { display: flex; flex-direction: column; gap: 9px; }
.bd-row { display: flex; align-items: center; gap: 10px; }
.bd-name { min-width: 86px; font-size: 13px; flex-shrink: 0; text-align: right; color: var(--text); white-space: nowrap; }
.bd-bar { flex: 1; height: 14px; background: #f0f1f3; border-radius: 7px; overflow: hidden; }
.bd-fill { height: 100%; border-radius: 7px; transition: width .3s; }
.bd-num { font-size: 13px; font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; white-space: nowrap; font-weight: 600; }
.bd-num .pct { color: var(--text-2); font-size: 11px; font-weight: 400; margin-left: 2px; }

.cmp-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cmp-name { min-width: 100px; font-size: 12px; color: var(--text); text-align: right; flex-shrink: 0; }
.cmp-bar { flex: 1; height: 14px; background: #f0f1f3; border-radius: 7px; overflow: hidden; }
.cmp-fill { height: 100%; border-radius: 7px; transition: width .3s; }
.cmp-num { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; font-weight: 600; }
.cmp-rule { font-size: 12px; color: var(--text-2); margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line); }
.cmp-match { color: var(--green); font-weight: 600; margin-left: 8px; font-size: 11px; }
.cmp-diff { color: var(--red); font-weight: 600; margin-left: 8px; font-size: 11px; }

.stock-bars { display: flex; flex-direction: column; gap: 8px; }
.stock-row { display: flex; align-items: center; gap: 10px; }
.stock-row.stock-clickable { cursor: pointer; border-radius: 6px; padding: 3px 6px; margin: -3px -6px; transition: background .15s; }
.stock-row.stock-clickable:hover { background: #fff7ed; }
.stock-click-hint { color: var(--brand); font-size: 11px; font-weight: 500; margin-left: 4px; }
.stock-lv { width: 36px; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.stock-bar { flex: 1; height: 12px; background: #f0f1f3; border-radius: 6px; overflow: hidden; }
.stock-fill { height: 100%; border-radius: 6px; transition: width .3s; }
.stock-num { font-size: 12px; color: var(--text); white-space: nowrap; }
.stock-num .over90 { color: var(--red); font-weight: 600; margin-left: 6px; }

.sp-table td { font-size: 13px; }
.sp-table tr.zero td { color: var(--red); font-weight: 600; }
.sp-table tr.sp-total td { background: #f9fafb; font-weight: 700; border-top: 2px solid var(--line); }

.sp-group { margin-bottom: 16px; }
.sp-group:last-child { margin-bottom: 0; }
.sp-group-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.sp-group-title { font-size: 13px; font-weight: 700; color: var(--text); }
.sp-group-summary { font-size: 12px; color: var(--text-2); }

/* 保险公司出单数 */
.insurance-panel .bd-name { min-width: 72px; }
.insurance-panel .bd-fill { background: var(--blue); }

/* 库存明细弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 24px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 960px; max-height: 86vh;
  display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.22);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-close { border: none; background: none; font-size: 24px; color: var(--text-2); cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px; overflow: auto; }
.stock-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.stock-table th, .stock-table td { padding: 8px 8px; text-align: left; border-bottom: 1px solid #f0f1f3; white-space: nowrap; }
.stock-table th { color: var(--text-2); font-weight: 600; position: sticky; top: 0; background: #fff; z-index: 1; }
.stock-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.stock-table tr.over90 td.days { color: var(--red); font-weight: 700; }
.stock-table .vin { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; color: var(--text-2); }
.stock-table .lv { font-weight: 700; }
.stock-table tr.grp-label td { background: #f5f7fb; color: var(--text-2); font-size: 11px; font-weight: 600; padding: 6px 8px; border-top: 2px solid var(--line); border-bottom: 1px solid var(--line); }
.stock-table tr.grp-end td { border-bottom: 1px dashed var(--line); }

@media (max-width: 760px) {
  .overview { grid-template-columns: repeat(2, 1fr); }
  .dept-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   销售仪表盘专属样式（顶部5个KPI + 主体多列布局 + 折叠看板）
   ============================================================ */

/* 顶栏时效与刷新 */
.freshness {
  color: #cbd5e1; font-size: 12px; font-variant-numeric: tabular-nums;
  padding: 6px 10px; background: rgba(255,255,255,0.06); border-radius: 6px;
}
.topbar-btn.ghost { background: rgba(255,255,255,0.05); }

/* 顶部 5 个核心 KPI */
.kpi-row {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px;
  margin-top: 22px;
}
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.kpi .kpi-label { color: var(--text-2); font-size: 12px; }
.kpi .kpi-value { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .kpi-unit { font-size: 13px; color: var(--text-2); margin-left: 4px; font-weight: 400; }
.kpi .kpi-foot { font-size: 11px; color: var(--text-2); margin-top: 4px; }
.kpi .kpi-note { font-size: 11px; color: var(--red); margin-top: 3px; line-height: 1.4; }
.kpi.danger .kpi-value { color: var(--red); }
.kpi.success .kpi-value { color: var(--green); }
.kpi.warning .kpi-value { color: var(--brand); }
.kpi.info .kpi-value { color: var(--blue); }
.kpi .kpi-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--brand); }

/* 仪表盘主体 */
.deck { display: flex; flex-direction: column; gap: 16px; margin-top: 14px; }
.deck-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.deck-card { padding: 18px 20px; }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-sub { color: var(--text-2); font-size: 12px; }

/* 核心经营数据格（重用 .ov-grid 但允许更紧凑） */
.ov-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.source-notes {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid #f3f4f6;
  color: var(--text-2); font-size: 11px;
}

/* 让核心经营数据格子放大一点 */

.deck-card .ov-grid .ov-item .ov-val { font-size: 17px; }

/* 适配稍小屏幕（≤ 980px） */
@media (max-width: 980px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .deck-row { grid-template-columns: 1fr; }
  .ov-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-actions { flex-wrap: wrap; }
}

/* ============================================================
   周度报告 · 部门汇总（全员加总）
   ============================================================ */
.weekly-card { padding: 18px 20px; }
.weekly-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
  font-size: 13px; color: #6b7280;
}
.weekly-legend { display: flex; gap: 10px; font-size: 12px; }
/* 7 个指标瓦片 */
.wtiles {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
@media (max-width: 900px) { .wtiles { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 560px) { .wtiles { grid-template-columns: repeat(2, 1fr); } }
.wtile {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}
.wtile-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.wtile-value { font-size: 28px; font-weight: 700; color: #111827; line-height: 1.1; }
.mom { display: block; font-size: 11px; margin-top: 6px; white-space: nowrap; }
.mom.up { color: #e5484d; }      /* 涨=红（中国市场惯例） */
.mom.down { color: #16a34a; }    /* 跌=绿 */
.mom.flat { color: #9ca3af; }
.mom.none { color: #c0c4cc; }
/* 冲突说明：瓦片内黄色警示条 */
.wtile.has-note { border-color: #f59e0b; background: #fffbeb; }
.wtile-note {
  margin-top: 8px; font-size: 10px; color: #b45309; line-height: 1.5;
  border-top: 1px dashed #fcd34d; padding-top: 6px; text-align: left;
}

/* ============================================================
   上传材料（全员上传的图片/台账存档）
   ============================================================ */
.materials-card { padding: 18px 20px; }
.mat-imgs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.mat-thumb {
  position: relative; display: block; border-radius: 10px; overflow: hidden;
  border: 1px solid #e5e7eb; aspect-ratio: 4/3; background: #f3f4f6;
}
.mat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mat-badge {
  position: absolute; left: 6px; bottom: 6px;
  background: #f59e0b; color: #fff; font-size: 10px;
  padding: 2px 6px; border-radius: 999px;
}
.mat-badge.done { background: #16a34a; }
.mat-files { display: flex; flex-direction: column; gap: 6px; }
.mat-file {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: #f8fafc; border: 1px solid #e5e7eb;
  border-radius: 8px; font-size: 12px;
}
.mf-icon { flex: 0 0 auto; }
.mf-name { font-weight: 600; color: #111827; }
.mf-meta { color: #6b7280; font-size: 11px; }

/* ============================================================
   分组 PK（信息员上传 PK 文件）
   ============================================================ */
.pk-card { padding: 18px 20px 24px; }
.pk-sub-title { font-size: 14px; font-weight: 600; color: #374151; margin: 18px 0 10px; padding-left: 8px; border-left: 3px solid var(--brand); }
.pk-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.pk-group { background: #f9fafb; border: 1px solid var(--line); border-radius: 10px; padding: 14px; position: relative; }
.pk-group::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 10px 0 0 10px; }
.pk-group-红::before { background: #e5484d; }
.pk-group-蓝::before { background: #3b82f6; }
.pk-group-总::before { background: var(--brand); }
.pk-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pk-group-name { font-size: 16px; font-weight: 700; color: #111827; }
.pk-group-tag { font-size: 11px; color: #6b7280; padding: 2px 8px; background: #fff; border: 1px solid var(--line); border-radius: 20px; }
.pk-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.pk-stats > div { background: #fff; border-radius: 8px; padding: 8px 6px; text-align: center; }
.pk-stats .lbl { display: block; font-size: 11px; color: #6b7280; margin-bottom: 2px; }
.pk-stats b { font-size: 16px; color: #111827; font-variant-numeric: tabular-nums; }
.pk-stats b.hot { color: #e5484d; font-size: 18px; }
.pk-progress { height: 6px; background: #f3f4f6; border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.pk-progress .bar { height: 100%; background: linear-gradient(90deg, var(--brand), #ff9a3c); border-radius: 999px; }
.pk-progress-meta { font-size: 11px; color: #6b7280; margin-bottom: 6px; }
.pk-status { font-size: 12px; color: #374151; display: flex; align-items: center; gap: 6px; }
.pk-status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.pk-status .dot.落后 { background: #e5484d; }
.pk-status .dot.进行中 { background: #f59e0b; }
.pk-status .dot.完成 { background: #16a34a; }

.pk-indicators { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 18px; padding: 14px; background: #fff7ed; border-radius: 10px; }
.pk-ind { text-align: center; }
.pk-ind span { display: block; font-size: 11px; color: #92400e; margin-bottom: 4px; }
.pk-ind b { font-size: 18px; color: #111827; font-variant-numeric: tabular-nums; }
.pk-ind b.hot { color: #e5484d; }
.pk-ind b.warn { color: #f59e0b; }

.pk-rank-table th, .pk-rank-table td { padding: 8px 10px; font-size: 12px; }
.pk-person-红 td:first-child { border-left: 3px solid #e5484d; }
.pk-person-蓝 td:first-child { border-left: 3px solid #3b82f6; }
.pk-row-bar { width: 80px; height: 6px; background: #f3f4f6; border-radius: 999px; overflow: hidden; }
.pk-row-bar > div { height: 100%; background: var(--brand); }

.pk-detail-table th, .pk-detail-table td { padding: 6px 10px; font-size: 12px; }
.pk-detail-table td b { color: #111827; }
