:root {
  --primary: #b91c1c;
  --primary-dark: #991b1b;
  --accent: #2563eb;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #005fa3;
  border-bottom: 1px solid #004c82;
  box-shadow: var(--shadow);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-img {
  display: block;
  height: 54px;
  width: auto;
  max-width: 320px;
  object-fit: contain;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.88);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  transition: all .2s;
}
.nav-link:hover, .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.container {
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px;
}

.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
}

.rank-list { display: flex; flex-direction: column; gap: 4px; }
.rank-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px;
  background: var(--bg); transition: all .15s; cursor: pointer;
}
.rank-item:hover { background: #e7f0fa; }
.rank-no {
  width: 20px; height: 20px; line-height: 20px; text-align: center;
  border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; flex: none;
}
.rank-name { flex: 1; font-size: 13px; }
.rank-val { font-weight: 700; color: var(--accent); }

.st-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.st-badge.active { background: #e6f6ec; color: var(--success); }
.st-badge.expiring { background: #fdf0db; color: var(--warn); }
.st-badge.expired { background: #fde8e8; color: var(--danger); }
.st-badge.unknown { background: #eef0f3; color: var(--muted); }

/* Cards */
.card {
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 18px;
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--primary);
  text-align: center;
}
.stat-card.active { border-color: var(--success); }
.stat-card.expiring { border-color: var(--warn); }
.stat-card.expired { border-color: var(--danger); }
.stat-card.sales { border-color: var(--accent); grid-column: span 2; min-width: 240px; }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 6px 0;
  word-break: break-all;
  line-height: 1.2;
}
.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.alert-ok, .alert-warn {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 4px;
}
.alert-ok { background: #e8f8ef; color: #1a7f4b; border: 1px solid #b7e4c7; }
.alert-warn { background: #fff4e6; color: #b5651d; border: 1px solid #ffd8a8; }

mark { background: #fff3a0; color: #5b4b00; padding: 0 2px; border-radius: 3px; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-header h3 { margin: 0; }
.head-actions { display: flex; gap: 8px; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 13px;
}
.chart-bar span { min-width: 60px; }
.bar-wrap {
  flex: 1;
  background: #edf2f7;
  border-radius: 4px;
  height: 18px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-width: 140px;
}
.toolbar input {
  min-width: 260px;
  flex: 1;
}
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: filter .2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn:hover { filter: brightness(1.05); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-dingtalk { background: #1677ff; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.op-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-xs { padding: 2px 6px; font-size: 11px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid #ddd; }
.btn-ghost:hover { background: #f5f5f5; }

/* Table */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel);
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

/* 授权台账：加宽、长字段完整显示并自动换行 */
.records-table {
  width: 100%;
  min-width: 1280px;
  table-layout: auto;
}
.records-table th,
.records-table td {
  white-space: normal;
  word-break: break-word;
  vertical-align: middle;
  line-height: 1.5;
  text-align: center;
}
.records-table td.col-project {
  min-width: 220px;
  max-width: 360px;
}
.records-table th:nth-child(1),
.records-table td:nth-child(1) { width: 70px; }   /* 年度 */
.records-table th:nth-child(2),
.records-table td:nth-child(2) { width: 110px; }  /* 代理商 */
.records-table th:nth-child(5),
.records-table td:nth-child(5),
.records-table th:nth-child(6),
.records-table td:nth-child(6) { width: 100px; white-space: nowrap; } /* 日期 */
.records-table th:nth-child(7),
.records-table td:nth-child(7) { width: 90px; }   /* 被授权人 */
.records-table th:nth-child(8),
.records-table td:nth-child(8) { width: 110px; }  /* 业绩/状态 */
.records-table th:nth-child(9),
.records-table td:nth-child(9) { width: 90px; }   /* 授权状态 */
.records-table th:nth-child(10),
.records-table td:nth-child(10) { width: 150px; white-space: nowrap; } /* 操作 */
th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--muted);
  position: sticky;
  top: 0;
}
tr:hover td { background: #f9fafb; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-expiring { background: #fef3c7; color: #92400e; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-unknown { background: #f3f4f6; color: #4b5563; }
.badge-dingtalk { background: #e6f0ff; color: #1677ff; }
.badge-pending-ledger { background: #fef3c7; color: #92400e; }

/* 制作人结算：已汇总待审批的明细行灰显锁定 */
.settle-locked td { color: var(--muted); opacity: .6; }
.settle-locked input[type="checkbox"] { cursor: not-allowed; }

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
}
.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.page-btn.active { background: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Agent list */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.agent-card {
  background: var(--panel);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 5px solid var(--accent);
  transition: transform .15s, box-shadow .15s;
  text-decoration: none;
  color: var(--text);
}
.agent-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.agent-card.gold { border-left-color: #f59e0b; background: linear-gradient(135deg, #fffbeb, #fff); }
.agent-card.silver { border-left-color: #94a3b8; background: linear-gradient(135deg, #f8fafc, #fff); }
.agent-card.bronze { border-left-color: #b45309; background: linear-gradient(135deg, #fff7ed, #fff); }
.agent-card.dormant { border-left-color: #cbd5e1; opacity: .92; }

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.agent-name { font-size: 17px; font-weight: 700; }
.agent-meta { font-size: 13px; color: var(--muted); margin: 2px 0; }
.agent-premium { margin-top: 8px; font-size: 12px; color: #d97706; font-weight: 700; }

.tier-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
  white-space: nowrap;
}
.tier-badge.tier-gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.tier-badge.tier-silver { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #fff; }
.tier-badge.tier-bronze { background: linear-gradient(135deg, #fdba74, #ea580c); color: #fff; }
.tier-badge.tier-dormant { background: #e2e8f0; color: #64748b; }

.premium-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 12px;
  font-weight: 700;
  vertical-align: middle;
}
.agent-card.premium {
  border-left-color: #d97706;
  box-shadow: 0 4px 14px rgba(217, 119, 6, .18);
}
.agent-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.agent-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.agent-count-label {
  font-size: 14px;
  color: var(--muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 12px;
}
.agent-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0 18px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}
.filter-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.filter-check input { cursor: pointer; }

/* 标签页切换（标书台账 代理商/业务员/汇总 等） */
.tab-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-bar .tab {
  padding: 7px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.tab-bar .tab:hover { border-color: #dc2626; color: #dc2626; }
.tab-bar .tab.active {
  background: #fef2f2;
  border-color: #dc2626;
  color: #dc2626;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.18);
}

/* Project query */
.project-search {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.project-search input { flex: 1; }

.letter-page {
  position: relative;
  z-index: 0;
  width: 210mm;
  max-width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  padding: 10mm 18mm 18mm 18mm;  /* 上10 / 右18 / 下18 / 左18：顶部收窄，其余与原模板一致 */
  box-sizing: border-box; /* padding 计入 210mm 总宽，内容区宽 174mm */
  box-shadow: 0 0 12px rgba(0,0,0,.08);
  overflow: hidden;
  display: flex;          /* 纵向 flex：配合 footer 的 margin-top:auto 把落款钉在页面底部 */
  flex-direction: column;
}
@media screen {
  .letter-page { margin-top: 16px; margin-bottom: 16px; }
}
/* 全页水印：淡色公司 logo 平铺，置顶浮于文字/图片上方（标题、页眉单独抬到更高层避开） */
.letter-watermark {
  position: absolute;
  inset: 0;
  background-image: url('watermark-tile.png?v=2');
  background-repeat: repeat;
  background-size: 480px 440px;
  background-position: -55px 85px;
  opacity: 0.14;
  pointer-events: none;
  z-index: 3;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
/* 左上角水印净区：遮挡平铺水印在页面最左上方的 tile，避免压到公司 logo，页眉(z-index:4)仍在其上保持可见 */
.letter-watermark-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 220px;
  height: 220px;
  background: #fff;
  z-index: 3;
  pointer-events: none;
}
/* 水印上方的正文内容 */
.letter-head, .letter-title, .letter-body, .letter-idcards, .letter-footer {
  position: relative;
  z-index: 1;
}
/* 页眉：左 logo + 右公司信息，整体水平居中，下方蓝色横线 */
.letter-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #1f3a93;
  margin-bottom: 18px;
  position: relative;
  z-index: 4;
}
.letter-head-logo img { height: 18mm; width: auto; display: block; }
.letter-head-info { text-align: center; line-height: 1.6; }
.letter-head-company { font-size: 30px; font-weight: 700; }
.letter-head-meta { font-size: 13px; color: #333; }
.letter-title {
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  margin: 16px 0 20px;
  letter-spacing: 8px;
  position: relative;
  z-index: 4;
}
.letter-body {
  font-size: 16px;
  line-height: 1.9;
  text-align: justify;
  text-indent: 2em;
}
.letter-body .letter-to { text-indent: 0; }
.letter-body p { margin: 12px 0; }
.letter-field {
  display: inline;
  text-decoration: underline;
  text-decoration-color: #333;
  text-decoration-thickness: 1px;
  margin: 0 4px;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: break-word;
}
/* 身份证展示区：左右两列，每列上下排正面/反面 */
.letter-idcards {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.letter-idcard-col {
  width: calc(50% - 8px);
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.letter-idcard-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
/* 身份证照片容器：固定身份证标准比例 85.6:54，确保四张图大小一致、左右对齐。
   注意：不能用 aspect-ratio —— html2canvas 1.4.1 不支持该属性，会导致照片框高度为 0，
   截图/下载 PDF 中身份证“消失”，与界面显示不一致。改用 padding-top 百分比（54/85.6≈63.084%），
   在浏览器与 html2canvas 中高度一致，屏幕显示效果不变。 */
.letter-idcard-photo {
  position: relative;
  width: 100%;
  padding-top: 63.084%;
  border: 1px solid #ccc;
  background: #fafafa;
  overflow: hidden;
}
.letter-idcard-photo .letter-idcard-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.letter-idcard-photo .letter-idcard-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px dashed #999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
  background: #fafafa;
}
.idcard-preview-wrap {
  position: relative;
  display: inline-block;
  margin-top: 8px;
}
.idcard-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  line-height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.idcard-delete-btn:hover { background: #b91c1c; }
.letter-footer {
  margin-top: auto;       /* 自动顶满上方剩余空间，使落款固定在页面底部，确保底部页边距恒为 18mm（不加 padding，避免撑高页面） */
  display: flex;
  justify-content: center;       /* 两组落款整体居中，不再分置左右两侧 */
  align-items: center;           /* 两组默认在同一水平线上（垂直居中对齐） */
  gap: 72px;                     /* 两组之间留白 */
  font-size: 16px;
  line-height: 2.0;
  position: relative;
  z-index: 4; /* 抬到水印(z-index:3)之上 */
  background: #fff; /* 白底净区：遮挡该处水印，使落款文字/公章不被水印压住，同时不影响各元素相对位置 */
}
.letter-footer-left { text-align: left; }
/* 仅右侧“公司名称+日期+盖章”整体下移，左侧（法人/职务/被授权人）保持原位不动 */
.letter-footer-right { text-align: center; transform: translateY(12mm); }
.letter-date { padding-top: 2mm; text-align: center; } /* 紧挨公司名称(公章)之下，无空行，用 padding 使间隙纳入 footer 白底净区、不露水印 */
.letter-company-wrap {
  position: relative;
  display: block;
  text-align: center;
  min-height: 44mm;        /* 撑高以罩住 40mm 公章，使公章四周也处于白净区，水印不再从盖章旁露出 */
  background: #fff;        /* 白底净区：遮挡该处水印，公章透明区域亦不露水印 */
}
.letter-company-text {
  position: relative;      /* 作为公章的绝对定位基准，使公章精确覆盖在本行公司名文字之上 */
  display: inline-block;
  white-space: nowrap;
  z-index: 1;
}
.letter-company-name {
  font-size: 16px;        /* 落款公司名还原为正文级，与周边文字同号（曾误改为30px，已回退） */
  font-weight: 400;
}
.letter-seal-img {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40mm;
  height: auto;
  display: block;
  opacity: 0.92;
  z-index: 5;
  pointer-events: none;
}
.letter-seal-placeholder {
  text-align: center;
  color: #b91c1c;
  font-weight: 700;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal.modal-lg { max-width: 920px; }
.modal.modal-xl { max-width: min(1200px, 94vw); }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted);
}
.modal-body { padding: 20px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
}
.form-group.full { grid-column: span 2; }
.form-group label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.form-group textarea { min-height: 60px; resize: vertical; }
.modal-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Utility */
.text-center { text-align: center; }
.mt-2 { margin-top: 12px; }
.mb-1 { margin-bottom: 8px; }
.empty-tip { color: var(--muted); text-align: center; padding: 30px; }

@media (max-width: 900px) {
  .row-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: span 1; }
}
@page {
  size: A4;
  margin: 0; /* 边距改由 .letter-page 的 padding 统一控制，确保屏幕/打印/PDF 三处一致 */
}
/* 右上角登录用户菜单 */
.user-menu { position: relative; display: inline-flex; align-items: center; margin-left: 8px; }
.user-name { cursor: pointer; color: #fff; font-size: 14px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.user-name:hover { background: rgba(255,255,255,.18); }
.user-dropdown { position: absolute; right: 0; top: 100%; margin-top: 6px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); min-width: 130px; z-index: 300; overflow: hidden; }
.user-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 10px 14px; font-size: 14px; cursor: pointer; color: var(--text); }
.user-item:hover { background: #f2f4f7; }

@media print {
  .app-header, .app-footer, .toolbar, .pagination, .modal-overlay, .no-print { display: none !important; }
  .container { padding: 0; max-width: none; }
  .letter-page { box-shadow: none; border: none; max-width: none; margin: 0; min-height: 297mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* 押金台账徽章 */
.fee-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.fee-badge.fee-bid { background: #e7f0fa; color: #005fa3; }
.fee-badge.fee-deposit { background: #f3e8fb; color: #7c3aed; }
.dir-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.dir-badge.dir-in { background: #e6f6ec; color: var(--success); }
.dir-badge.dir-out { background: #fdf0db; color: var(--warn); }

/* 审核智能建议 */
.suggest-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.suggest-approve { background: #e6f7ec; color: #1a7f37; border: 1px solid #9fd9b4; }
.suggest-reject { background: #fdeaea; color: #c0392b; border: 1px solid #f0b4ad; }
.suggest-review { background: #fff6e0; color: #9a6b00; border: 1px solid #f0d488; }
.suggest-detail td { background: #fafafa; }
.factor { font-size: 12px; line-height: 1.7; padding: 1px 0; }
.factor-good { color: #1a7f37; }
.factor-bad { color: #c0392b; }
.factor-warn { color: #9a6b00; }
.factor-info { color: #555; }
.mt-05 { margin-top: 5px; }

/* 角色徽章（代理商 / 业务员） */
.party-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.party-agent { background: #e7f0fa; color: #005fa3; border: 1px solid #b9d6f0; }
.party-sales { background: #f3e8fb; color: #7c3aed; border: 1px solid #d9bff0; }
/* 授权类型徽章（单位授权 / 独立项目授权） */
.authtype-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.at-unit { background: #eafaf0; color: #1a7f37; border: 1px solid #b6e3c6; }
.at-project { background: #fff3e0; color: #9a6b00; border: 1px solid #f0d488; }

/* 身份证上传裁剪弹窗 */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.crop-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.75);
}
.crop-modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  width: 92%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.crop-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.crop-tip { font-size: 13px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.crop-warning { color: #c05621; background: #fff7ed; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.crop-stage {
  position: relative;
  width: 100%;
  height: 340px;
  background: #222;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  touch-action: none;
  cursor: grab;
}
.crop-stage:active { cursor: grabbing; }
.crop-img-layer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-drag: none;
}
.crop-img-layer img {
  display: block;
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.crop-frame {
  position: absolute;
  border: 2px dashed rgba(255,255,255,.9);
  background: rgba(255,255,255,.08);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
  touch-action: none;
  box-sizing: border-box;
  z-index: 2;
  pointer-events: none;
}
.crop-frame-inner {
  position: absolute;
  inset: 4px;
  border: 1px dotted rgba(255,255,255,.6);
}
.crop-frame-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,.9);
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  pointer-events: none;
  white-space: nowrap;
}
.crop-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.crop-control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.crop-control-row input[type="range"] {
  flex: 1;
  min-width: 80px;
}
.crop-control-label {
  font-size: 13px;
  color: var(--text);
  min-width: 52px;
}
.crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .crop-stage { height: 260px; }
  .crop-actions { justify-content: center; }
}

/* ===== 汇总视图：资金总览 / 风险待办 / 中标率 ===== */
.fund-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.fund-warn { color: var(--danger); font-weight: 700; }

/* ===== 看板分组 / 风险聚合红卡 / 可点卡片 / 零值弱化 ===== */
/* 总览分组 2×2 两排布局 */
#dep-funds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 36px;
}
@media (max-width: 900px) {
  #dep-funds { grid-template-columns: 1fr; }
}
.fund-group { margin-bottom: 14px; }
.fund-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  padding-left: 10px;
  border-left: 3px solid var(--border);
  letter-spacing: 1px;
}
/* 组内卡片横向一行排开 */
.fund-group .stats-grid {
  margin-bottom: 0;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* 风险待办聚合大红卡 */
.risk-agg {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 18px;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.3);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.risk-agg:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(220, 38, 38, 0.4); }
.risk-agg-title { font-size: 13px; opacity: .9; margin-bottom: 4px; }
.risk-agg-num { font-size: 24px; font-weight: 800; line-height: 1.2; }
.risk-agg-num b { font-size: 28px; }
.risk-agg-sub { font-size: 12px; opacity: .85; margin-top: 4px; }
.risk-agg-cta { font-size: 14px; font-weight: 600; white-space: nowrap; opacity: .95; }
/* 红卡右侧：招标公司 / 发票等保留展示区（次级视觉） */
.risk-agg-side {
  text-align: left;
  font-size: 12px;
  line-height: 1.7;
  border-left: 1px solid rgba(255, 255, 255, .35);
  padding-left: 18px;
  max-width: 42%;
}
.risk-agg-side-title { font-weight: 700; opacity: .9; margin-bottom: 2px; }
.risk-agg-side-items { opacity: .85; }

/* 可点卡片（下钻） */
.stat-card.clickable { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.stat-card.clickable:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0, 0, 0, .12); }

/* 零值卡片弱化 */
.stat-card.zero { opacity: .5; transform: scale(.96); }
.stat-card.zero .stat-value { color: var(--muted); }

/* 筛选标签条（列表视图） */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 8px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
}
.filter-tag { color: #b91c1c; font-size: 13px; font-weight: 600; }

.todo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.todo-card {
  background: var(--panel);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--warn);
}
/* 代理商相关风险待办：红色边突出 */
.todo-card.agent-risk { border-left-color: var(--danger); }
.todo-card.agent-risk .todo-head b { color: var(--danger); }
.todo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.todo-head b { font-size: 15px; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border, #eee);
  font-size: 13px;
}
.todo-list li:last-child { border-bottom: none; }
.todo-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-list li b { color: var(--danger); white-space: nowrap; }
.todo-more { font-size: 12px; color: var(--muted); margin-top: 6px; }

.winbar {
  display: inline-block;
  vertical-align: middle;
  width: 90px;
  height: 8px;
  border-radius: 4px;
  background: var(--border, #eee);
  overflow: hidden;
  margin-right: 8px;
}
.winbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .3s;
}
.winrate-num { font-size: 13px; font-weight: 700; color: var(--text); }

/* 中标率排行：代理商 / 业务员 分两列并排 */
.winrate-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.winrate-col-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  letter-spacing: 1px;
}
@media (max-width: 720px) {
  .winrate-cols { grid-template-columns: 1fr; }
}


/* 汇总金额表总合计行 */
.settle-total-row td {
  background: #fef2f2;
  border-top: 2px solid var(--border);
  padding: 10px 12px;
}
