/* 2026-11-01 新增：CRM 与 ERP 双入口的门户外壳样式。
 * 只服务 portal.html / crm.html，不改动 styles.css 里 ERP 工作台的既有样式。 */

.portal-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 40px 20px;
  background: linear-gradient(180deg, #f4f7fb 0%, #e8eef7 100%);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #1f2a37;
}
.portal-head { text-align: center; display: block; background: none; color: #1f2a37; padding: 0; }
.portal-head h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: 1px; }
.portal-head .sub { margin: 0; color: #5b6b7f; font-size: 14px; }
.portal-head .ver-line { margin: 6px 0 0; }
.portal-head .ver { color: #8b98a8; font-size: 12px; }
.portal-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.portal-card {
  width: 320px; background: #fff; border: 1px solid #dde5ef; border-radius: 12px;
  padding: 26px 24px 22px; box-shadow: 0 6px 22px rgba(31, 42, 55, .07);
  display: flex; flex-direction: column; gap: 10px;
}
.portal-card .pc-icon {
  width: 56px; height: 56px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff; background: #2563eb; letter-spacing: .5px;
}
.portal-card[data-sys="crm"] .pc-icon { background: #0d9488; }
.portal-card[data-sys="portal"] .pc-icon { background: #7c3aed; }
.portal-card h2 { margin: 4px 0 0; font-size: 19px; }
.portal-card .pc-desc { margin: 0; color: #5b6b7f; font-size: 13px; line-height: 1.6; min-height: 62px; }
.portal-card .pc-state { margin: 0; font-size: 12px; color: #8b98a8; }
.portal-card .pc-state.on { color: #0d7a47; }
.portal-card .pc-state.off { color: #b45309; }
.portal-card button:disabled { opacity: .5; cursor: not-allowed; }
.portal-card button.primary {
  margin-top: 6px; width: 100%; padding: 11px 0; font-size: 15px; cursor: pointer;
  color: #fff; background: #2563eb; border: 0; border-radius: 8px;
}
.portal-card[data-sys="crm"] button.primary { background: #0d9488; }
.portal-card[data-sys="portal"] button.primary { background: #7c3aed; }
.portal-card button.primary:hover { filter: brightness(1.06); }
.portal-tip { margin: 0; color: #6b7a8d; font-size: 12.5px; }
.portal-foot { color: #97a3b2; font-size: 12px; }

/* ---------- CRM 外壳 ---------- */
.crm-body {
  margin: 0; font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #f4f7fb; color: #1f2a37;
}
.crm-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.crm-login .card {
  width: 360px; background: #fff; border: 1px solid #dde5ef; border-radius: 12px;
  padding: 28px 26px; box-shadow: 0 6px 22px rgba(31, 42, 55, .07);
}
.crm-login h1 { font-size: 20px; margin: 0 0 4px; }
.crm-login .sub { margin: 0 0 18px; color: #6b7a8d; font-size: 12.5px; }
.crm-login label { display: block; font-size: 13px; color: #4a5768; margin-bottom: 12px; }
.crm-login input {
  width: 100%; box-sizing: border-box; margin-top: 5px; padding: 9px 10px;
  border: 1px solid #cfdaea; border-radius: 7px; font-size: 14px;
}
.crm-login button.primary {
  width: 100%; padding: 10px 0; margin-top: 4px; font-size: 15px; cursor: pointer;
  color: #fff; background: #0d9488; border: 0; border-radius: 8px;
}
.crm-login .err { color: #c0392b; font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.crm-login .back { display: block; margin-top: 14px; font-size: 12.5px; color: #2563eb; text-decoration: none; }

.crm-shell { min-height: 100vh; display: flex; flex-direction: column; }
.crm-top {
  height: 54px; display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: #0f766e; color: #fff; flex: 0 0 auto;
  justify-content: flex-start;   /* 复位 styles.css:16 全局 header 的 space-between */
}
.crm-top .brand { font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.crm-top .badge {
  font-size: 11.5px; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.18);
}
.crm-top .spacer { flex: 1; }
.crm-top .who { font-size: 12.5px; opacity: .92; }
.crm-top a, .crm-top button {
  font-size: 12.5px; color: #fff; background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28); border-radius: 6px; padding: 5px 10px;
  cursor: pointer; text-decoration: none;
}
.crm-main { flex: 1; display: flex; min-height: 0; }
.crm-nav { width: 208px; flex: 0 0 208px; background: #fff; border-right: 1px solid #e3eaf3; padding: 10px 0; }
.crm-nav button {
  display: flex; width: 100%; align-items: center; gap: 8px; justify-content: space-between;
  padding: 10px 16px; font-size: 13.5px; color: #3c4a5b; background: none; border: 0;
  cursor: pointer; text-align: left;
}
.crm-nav button:hover { background: #f2f7fd; }
.crm-nav button[disabled] { color: #a6b1bf; cursor: not-allowed; }
.crm-nav button[disabled]:hover { background: none; }
.crm-nav .tag { font-size: 10.5px; color: #a6b1bf; }
.crm-content { flex: 1; padding: 22px 26px; overflow: auto; }
.crm-content .panel { background: #fff; border: 1px solid #e3eaf3; border-radius: 10px; padding: 22px 24px; max-width: 820px; }
.crm-content h2 { margin: 0 0 10px; font-size: 17px; }
.crm-content p { margin: 0 0 8px; font-size: 13.5px; color: #4a5768; line-height: 1.75; }
.crm-content .warn { color: #b45309; }
.crm-content ul { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: #4a5768; line-height: 1.9; }
.crm-toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #1f2a37; color: #fff; font-size: 13px; padding: 9px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.crm-toast.show { opacity: 1; }
.crm-toast.err { background: #b93a2c; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- CRM 业务页（2026-11-01 线索管理） */
.crm-page { display: flex; flex-direction: column; gap: 10px; }
.crm-page .page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-page .page-head h2 { margin: 0; font-size: 17px; color: #0f172a; }
.crm-page .muted { color: #64748b; font-size: 12.5px; }
.crm-page .spacer { flex: 1; }
.crm-page button { font: inherit; cursor: pointer; border: 1px solid #cbd5e1; background: #fff;
  color: #1f2a37; padding: 6px 12px; border-radius: 6px; }
.crm-page button:hover:not(:disabled) { border-color: #94a3b8; background: #f8fafc; }
.crm-page button:disabled { cursor: not-allowed; opacity: .55; }
.crm-page button.primary { background: #0d9488; border-color: #0d9488; color: #fff; }
.crm-page button.primary:hover { background: #0f766e; }
.crm-page button.ghost { background: #f8fafc; }
.crm-page input, .crm-page select, .crm-page textarea { font: inherit; padding: 5px 8px;
  border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #1f2a37; }
.crm-page input[type="search"] { min-width: 220px; }

.lead-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-bar .tabs { display: flex; gap: 4px; }
.lead-bar .tabs button { background: #f1f5f9; border-color: #e2e8f0; }
.lead-bar .tabs button.on { background: #0d9488; border-color: #0d9488; color: #fff; }

.table-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: auto; }
.crm-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.crm-table th, .crm-table td { padding: 8px 8px; text-align: left; border-bottom: 1px solid #eef2f7; white-space: nowrap; }
.crm-table thead th { background: #f8fafc; color: #475569; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.crm-table td.num, .crm-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.crm-table tbody tr:hover { background: #f8fbfd; }
.crm-table td.empty { text-align: center; color: #94a3b8; padding: 26px 0; }
.crm-table td.ops { text-align: right; position: sticky; right: 0; background: #fff;
  box-shadow: -6px 0 6px -6px rgba(15, 23, 42, .18); }
.crm-table tbody tr:hover td.ops { background: #f8fbfd; }
.crm-table td.ops button { padding: 3px 7px; font-size: 12px; margin-left: 3px; }
.crm-table td.name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.crm-table th.pair, .crm-table td.pair { min-width: 92px; line-height: 1.5; white-space: nowrap; }
.crm-table td.pair .muted { font-size: 11.5px; }
.crm-table td.code { font-variant-numeric: tabular-nums; }
.crm-table .tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px;
  background: #eef2f7; color: #475569; }
.crm-table .tag.pool { background: #ecfdf5; color: #047857; }
.crm-table .tag.mine { background: #eff6ff; color: #1d4ed8; }
.crm-table .tag.overdue { background: #fef2f2; color: #b91c1c; }
.crm-table .tag.invalid { background: #f1f5f9; color: #94a3b8; }
.crm-table .tag.converted { background: #f5f3ff; color: #6d28d9; }

.pager { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #475569; }
.pager .spacer { flex: 1; }

/* 弹窗 */
.crm-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex;
  align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.crm-modal.hidden { display: none; }
.modal-card { background: #fff; border-radius: 10px; padding: 18px 20px; width: 100%; max-width: 720px;
  max-height: 92vh; overflow: auto; box-shadow: 0 18px 40px rgba(15, 23, 42, .22); display: flex;
  flex-direction: column; gap: 10px; }
.modal-card h3 { margin: 0; font-size: 16px; color: #0f172a; }
.modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: #475569; }
.modal-card .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-card .modal-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.modal-card .modal-actions .err { flex: 1; color: #b91c1c; font-size: 12.5px; }
.modal-card .modal-actions button { font: inherit; cursor: pointer; border: 1px solid #cbd5e1;
  background: #fff; padding: 6px 14px; border-radius: 6px; }
.modal-card .modal-actions button.primary { background: #0d9488; border-color: #0d9488; color: #fff; }
.modal-card .hint { font-size: 12.5px; color: #64748b; }
.modal-card ul.conflicts { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: #b45309; }

/* 客户 360 视图（2026-11-01，C26） */
.modal-card.wide { max-width: 1000px; }
.detail-body { max-height: 64vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 6px; }
.dsec { border: 1px solid #eef2f7; border-radius: 8px; padding: 10px 12px; }
.dsec h4 { margin: 0 0 8px; font-size: 13px; color: #0f172a; }
.dsec .kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 14px; font-size: 12.5px; color: #1f2937; }
.dsec .kv > div { overflow: hidden; text-overflow: ellipsis; }
.dsec .kv > div span { display: block; color: #64748b; font-size: 11.5px; }
.dsec-ops { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.dsec-ops button, .dsec button { font: inherit; cursor: pointer; border: 1px solid #cbd5e1; background: #fff;
  padding: 4px 10px; border-radius: 6px; font-size: 12px; }
.dsec-ops button:hover, .dsec button:hover { border-color: #94a3b8; background: #f8fafc; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th, .mini-table td { padding: 5px 8px; text-align: left; border-bottom: 1px solid #f1f5f9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.mini-table thead th { background: #f8fafc; color: #475569; font-weight: 600; }
.mini-table button.mini { font: inherit; cursor: pointer; border: 1px solid #cbd5e1; background: #fff;
  padding: 1px 7px; border-radius: 5px; font-size: 11.5px; margin-right: 4px; }
.detail-body .muted { color: #94a3b8; font-size: 12px; margin: 2px 0; }



/* CRM 分析统计（C79–C84，2026-11-01） */
.an-summary {
  margin: 6px 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
}
.an-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.an-actions button {
  background: #0d9488;
  color: #fff;
  border: 1px solid #0d9488;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.crm-table td.ck, .crm-table th.ck { width: 34px; text-align: center; }

/* 协作与渠道补充页（C39/C40/C42/C44/C45） */
.crm-page .page-sub { margin: 14px 0 8px; font-size: 13px; color: #334155; font-weight: 600; }
.crm-page .chk-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 2px 0 8px; }
.crm-page .chk-row label.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #1f2937; }
