:root {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --border: #e3e9f2;
  --border-strong: #d6deeb;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-weak: #eff6ff;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #7c3aed;
  --shadow: 0 18px 50px rgba(15, 23, 42, .13);
}

/* =========================================================
   基础
   ========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter,
    "PingFang SC",
    "Microsoft YaHei",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--primary);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 12px;
}

.text-danger {
  color: var(--danger);
}

/* =========================================================
   整体框架
   ========================================================= */

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 232px;
  background: #fff;
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  color: #fff;
  font-weight: 800;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
}

.brand-name {
  color: var(--primary);
  font-size: 18px;
  font-weight: 800;
}

.brand-sub {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
}

.beta {
  margin-left: 4px;
  padding: 2px 6px;
  color: var(--primary);
  font-size: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
}

.nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-label {
  margin: 18px 10px 6px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 2px 0;
  padding: 10px 12px;
  color: #334155;
  text-align: left;
  white-space: nowrap;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-weak);
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}

.user-mini,
.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f172a, #475569);
}

.user-mini-name,
.profile-name {
  font-size: 13px;
  font-weight: 700;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: 232px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(12px);
}

.search-wrap {
  display: flex;
  align-items: center;
  width: min(540px, 55vw);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.search-wrap select {
  padding: 9px;
  color: #334155;
  border: 0;
  border-right: 1px solid var(--border);
  background: #fff;
}

.search-wrap input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 0;
  outline: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.icon-btn:hover {
  background: #f1f5f9;
}

.notif-dot {
  position: absolute;
  top: -2px;
  right: 0;
  padding: 2px 5px;
  color: #fff;
  font-size: 9px;
  border-radius: 999px;
  background: var(--danger);
}

.profile-chip {
  padding-left: 8px;
}

.content {
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;
  padding: 24px;
}

/* =========================================================
   页面标题与按钮
   ========================================================= */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.page-subtitle {
  margin-top: 7px;
  color: var(--muted);
}

.btn {
  padding: 9px 14px;
  color: #334155;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  transition:
    border-color .15s ease,
    box-shadow .15s ease,
    transform .15s ease;
}

.btn:hover {
  border-color: #cbd5e1;
  box-shadow: 0 5px 18px rgba(15, 23, 42, .08);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .6;
}

.btn-primary {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.btn-primary:hover {
  color: #fff;
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.btn-danger {
  color: #be123c;
  border-color: #fecdd3;
  background: #fff1f2;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* =========================================================
   通用卡片与数据
   ========================================================= */

.grid {
  display: grid;
  gap: 14px;
}

.grid.kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .025);
}

.card-pad {
  padding: 16px;
}

.kpi-title {
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

.kpi-value {
  margin: 10px 0 8px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.delta {
  color: var(--success);
  font-size: 12px;
}

.dashboard-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
}

.dashboard-center {
  display: grid;
  gap: 14px;
}

.split-2 {
  display: grid;
  grid-template-columns: 1.25fr .85fr;
  gap: 14px;
}

.card-title {
  padding: 15px 16px 0;
  font-size: 14px;
  font-weight: 800;
}

/* =========================================================
   图表
   ========================================================= */

.pipeline {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  height: 230px;
  padding: 22px 18px 18px;
}

.stage {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.bar {
  width: 100%;
  min-height: 26px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
}

.stage:nth-child(2) .bar {
  background: linear-gradient(180deg, #22d3ee, #0891b2);
}

.stage:nth-child(3) .bar {
  background: linear-gradient(180deg, #8b5cf6, #7c3aed);
}

.stage:nth-child(4) .bar {
  background: linear-gradient(180deg, #fb923c, #ea580c);
}

.stage:nth-child(5) .bar {
  background: linear-gradient(180deg, #facc15, #eab308);
}

.stage:nth-child(6) .bar {
  background: linear-gradient(180deg, #4ade80, #16a34a);
}

.stage-value {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
}

.stage-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: 18px;
  padding: 18px;
}

.donut {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background:
    conic-gradient(
      #2563eb 0 32%,
      #7c3aed 32% 56%,
      #14b8a6 56% 72%,
      #f59e0b 72% 84%,
      #ef4444 84% 92%,
      #94a3b8 92% 100%
    );
}

.donut::after {
  content: "";
  position: absolute;
  inset: 32px;
  border-radius: 50%;
  background: #fff;
}

.legend {
  display: grid;
  gap: 8px;
  font-size: 12px;
}

.legend-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* =========================================================
   表格
   ========================================================= */

.table-card {
  overflow: hidden;
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.table-title {
  font-size: 15px;
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  min-width: 1250px;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 12px 14px;
  color: #334155;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: normal;
  border-bottom: 1px solid #eef2f7;
}

th {
  color: #64748b;
  font-weight: 700;
  white-space: nowrap;
  background: #fbfdff;
}

tbody tr:hover {
  background: #fbfdff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* 客户主表关键列宽，避免中文竖排 */
.table-card th:nth-child(1),
.table-card td:nth-child(1) {
  min-width: 76px;
}

.table-card th:nth-child(2),
.table-card td:nth-child(2) {
  min-width: 225px;
}

.table-card th:nth-child(3),
.table-card td:nth-child(3) {
  min-width: 175px;
}

.table-card th:nth-child(4),
.table-card td:nth-child(4) {
  min-width: 115px;
}

.table-card th:nth-child(5),
.table-card td:nth-child(5) {
  min-width: 170px;
}

.table-card th:nth-child(6),
.table-card td:nth-child(6) {
  min-width: 115px;
}

.table-card th:nth-child(7),
.table-card td:nth-child(7),
.table-card th:nth-child(8),
.table-card td:nth-child(8) {
  min-width: 120px;
}

.table-card th:nth-child(9),
.table-card td:nth-child(9) {
  min-width: 205px;
  white-space: normal;
}

.table-card th:nth-child(10),
.table-card td:nth-child(10) {
  min-width: 225px;
  white-space: normal;
}

.table-card th:last-child,
.table-card td:last-child {
  min-width: 115px;
}

.row-overdue {
  background: #fffafa;
}

.company-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.company-logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  color: var(--primary);
  font-weight: 800;
  border-radius: 50%;
  background: #eff6ff;
}

.score {
  display: inline-flex;
  justify-content: center;
  min-width: 40px;
  padding: 4px 8px;
  color: #15803d;
  font-weight: 800;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #ecfdf5;
}

/* =========================================================
   标签
   ========================================================= */

.badge {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid;
  border-radius: 999px;
}

.badge-blue {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.badge-purple {
  color: #6d28d9;
  border-color: #ddd6fe;
  background: #f5f3ff;
}

.badge-green {
  color: #15803d;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.badge-orange {
  color: #c2410c;
  border-color: #fed7aa;
  background: #fff7ed;
}

.badge-red {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.badge-gray {
  color: #475569;
  border-color: #cbd5e1;
  background: #f8fafc;
}

/* =========================================================
   操作列表
   ========================================================= */

.side-card {
  padding: 16px;
}

.action-list,
.activity-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.action-item,
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid #edf1f7;
  border-radius: 10px;
  background: #fff;
}

.action-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  color: var(--primary);
  border-radius: 8px;
  background: #eff6ff;
}

.action-main {
  flex: 1;
}

.action-title {
  font-size: 12px;
  font-weight: 700;
}

.action-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

/* =========================================================
   工具栏、表单基础
   ========================================================= */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.input,
.select,
.textarea {
  max-width: 100%;
  padding: 9px 11px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: 0;
  background: #fff;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px #dbeafe;
}

.toolbar .input {
  min-width: 260px;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-pill {
  padding: 7px 11px;
  color: #475569;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}

.form-card {
  max-width: 920px;
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.field.full {
  grid-column: 1/-1;
}

.textarea {
  min-height: 110px;
  resize: vertical;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress > div {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.empty {
  padding: 48px;
  color: var(--muted);
  text-align: center;
}

.empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.setting-card {
  padding: 18px;
}

.setting-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.code-box {
  padding: 12px;
  overflow: auto;
  color: #e2e8f0;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  font-size: 12px;
  border-radius: 10px;
  background: #0f172a;
}

/* =========================================================
   弹窗通用
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(2px);
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
   新增/编辑/跟进表单弹窗
   ========================================================= */

.modal-form {
  display: block;
  width: min(920px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* 表单顶部标题 */
.modal-form > h2,
.modal-form > h3 {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0;
  padding: 22px 26px 18px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -.02em;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(12px);
}

/* 标题后的客户信息 */
.modal-form > h2 + p,
.modal-form > h3 + p {
  margin: 18px 26px 0;
}

/* 隐藏字段不占空间 */
.modal-form > input[type="hidden"] {
  display: none;
}

/* 表单正文 */
.modal-form > .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
  padding: 22px 26px 28px;
}

.modal-form .field {
  min-width: 0;
  gap: 7px;
}

.modal-form .field label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.modal-form .input,
.modal-form .select,
.modal-form .textarea {
  width: 100%;
  min-width: 0;
  border-color: #dbe3ef;
}

.modal-form .input,
.modal-form .select {
  height: 46px;
  padding: 10px 13px;
}

.modal-form .textarea {
  min-height: 92px;
  padding: 11px 13px;
  line-height: 1.55;
}

.modal-form > .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 6;
  margin: 0;
  padding: 14px 26px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(12px);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .06);
}

.modal-form > .modal-actions .btn {
  min-width: 96px;
}

/* =========================================================
   客户详情弹窗
   ========================================================= */

.modal-detail {
  width: min(1180px, 100%);
  height: min(860px, calc(100vh - 48px));
}

.modal-header {
  position: relative;
  z-index: 4;
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(12px);
}

.modal-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.modal-title {
  margin: 0;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.2;
  letter-spacing: -.03em;
}

.modal-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0;
  color: #475569;
  font-size: 21px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  border-color: #cbd5e1;
  background: #f8fafc;
}

.detail-body {
  padding: 22px 28px 30px;
}

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.detail-kpi {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(145deg, #fff, #fbfdff);
}

.detail-kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-kpi-value {
  margin-top: 10px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.25;
  font-weight: 800;
  word-break: break-word;
}

/* =========================================================
   AI摘要
   ========================================================= */

.ai-summary {
  position: relative;
  margin-bottom: 18px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  background:
    radial-gradient(
      circle at 100% 0,
      rgba(96, 165, 250, .16),
      transparent 34%
    ),
    linear-gradient(135deg, #f8fbff, #fff);
}

.ai-summary::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(#2563eb, #7c3aed);
}

.ai-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.ai-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
}

.ai-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  font-size: 12px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.ai-summary-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.ai-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-summary-item {
  padding: 12px 14px;
  border: 1px solid rgba(219, 234, 254, .9);
  border-radius: 12px;
  background: rgba(255, 255, 255, .82);
}

.ai-summary-item.full {
  grid-column: 1/-1;
}

.ai-summary-label {
  margin-bottom: 5px;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

.ai-summary-text {
  color: #172033;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.ai-loading {
  pointer-events: none;
  opacity: .65;
}

/* =========================================================
   详情标签页
   ========================================================= */

.detail-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 5px;
  margin: 0 -28px 18px;
  padding: 10px 28px;
  overflow-x: auto;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(12px);
  scrollbar-width: none;
}

.detail-tabs::-webkit-scrollbar {
  display: none;
}

.detail-tab {
  flex: 0 0 auto;
  padding: 8px 13px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.detail-tab:hover {
  color: var(--primary);
  background: #f8fafc;
}

.detail-tab.active {
  color: var(--primary);
  background: var(--primary-weak);
}

.detail-panel {
  display: none;
}

.detail-panel.active {
  display: block;
}

.detail-section-title {
  margin: 0 0 14px;
  font-size: 17px;
}

/* =========================================================
   详情信息卡
   ========================================================= */

.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.detail-info {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid #edf1f7;
  border-radius: 12px;
  background: #fff;
}

.detail-info.wide {
  grid-column: span 2;
}

.detail-info.full {
  grid-column: 1/-1;
}

.detail-info-label {
  margin-bottom: 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.detail-info-value {
  min-height: 20px;
  color: #172033;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.detail-info-value a {
  color: var(--primary);
  text-decoration: none;
}

.detail-info-value a:hover {
  text-decoration: underline;
}

/* =========================================================
   跟进时间线
   ========================================================= */

.followup-timeline {
  position: relative;
  display: grid;
}

.followup-timeline::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 15px;
  width: 2px;
  background: #e2e8f0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  padding-bottom: 18px;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px #bfdbfe;
}

.timeline-card {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 8px;
}

.timeline-title {
  font-size: 13px;
  font-weight: 800;
}

.timeline-meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.timeline-summary {
  margin-top: 9px;
  font-size: 13px;
  line-height: 1.65;
}

.timeline-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 11px;
}

.timeline-result-box {
  padding: 10px 11px;
  border-radius: 10px;
  background: #f8fafc;
}

.timeline-result-label {
  margin-bottom: 4px;
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.timeline-result-text {
  font-size: 12px;
  line-height: 1.55;
}

.empty-detail {
  padding: 38px 20px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
}

/* =========================================================
   详情底部操作栏
   ========================================================= */

.detail-footer {
  position: relative;
  z-index: 4;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.detail-footer-actions {
  display: flex;
  gap: 8px;
}

/* =========================================================
   提示
   ========================================================= */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  color: #fff;
  border-radius: 10px;
  background: #0f172a;
  box-shadow: var(--shadow);
}

/* =========================================================
   小型桌面及平板
   ========================================================= */

@media (max-width: 1180px) {
  .grid.kpis {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-main {
    grid-template-columns: 1fr;
  }

  .split-2 {
    grid-template-columns: 1fr;
  }

  .right-rail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

@media (max-width: 980px) {
  .modal-backdrop {
    padding: 14px;
  }

  .modal-detail {
    height: calc(100vh - 28px);
  }

  .modal-form {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 28px);
  }

  .detail-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ai-summary-grid {
    grid-template-columns: 1fr;
  }

  .ai-summary-item.full,
  .detail-info.wide {
    grid-column: auto;
  }

  .detail-info.full {
    grid-column: 1/-1;
  }
}

@media (max-width: 820px) {
  .sidebar {
    width: 78px;
  }

  .brand > div:not(.brand-mark),
  .nav-item {
    font-size: 0;
  }

  .nav-item span {
    font-size: 18px;
  }

  .nav-label,
  .sidebar-footer {
    display: none;
  }

  .main {
    margin-left: 78px;
  }

  .grid.kpis {
    grid-template-columns: 1fr 1fr;
  }

  .top-actions .profile-chip {
    display: none;
  }

  .content {
    padding: 16px;
  }

  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .field.full {
    grid-column: auto;
  }

  .right-rail {
    grid-template-columns: 1fr;
  }

  .modal-form > .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-form .field.full {
    grid-column: auto;
  }
}

/* =========================================================
   手机及钉钉内置浏览器
   ========================================================= */

@media (max-width: 640px) {
  .sidebar {
    width: 62px;
  }

  .main {
    margin-left: 62px;
  }

  .brand {
    justify-content: center;
    padding: 15px 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .nav {
    padding: 10px 7px;
  }

  .nav-item {
    justify-content: center;
    padding: 11px 8px;
  }

  .topbar {
    height: auto;
    min-height: 58px;
    padding: 9px 12px;
  }

  .search-wrap {
    width: 100%;
  }

  .search-wrap select {
    max-width: 85px;
  }

  .top-actions {
    display: none;
  }

  .content {
    padding: 14px 12px;
  }

  .page-head {
    display: grid;
    gap: 12px;
  }

  .page-head > div:last-child {
    display: flex;
    gap: 8px;
  }

  .page-title {
    font-size: 23px;
  }

  .page-subtitle {
    font-size: 13px;
    line-height: 1.5;
  }

  .grid.kpis {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-value {
    font-size: 21px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar .input,
  .toolbar .select,
  .toolbar .btn {
    width: 100%;
    min-width: 0;
  }

  .modal-backdrop {
    padding: 0;
    place-items: stretch;
  }

  .modal,
  .modal-form,
  .modal-detail {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .modal-form > h2,
  .modal-form > h3 {
    padding: 17px 16px 14px;
    font-size: 20px;
  }

  .modal-form > h2 + p,
  .modal-form > h3 + p {
    margin: 14px 16px 0;
  }

  .modal-form > .form-grid {
    padding: 18px 16px 24px;
    gap: 15px;
  }

  .modal-form > .modal-actions {
    padding: 10px 16px;
  }

  .modal-form > .modal-actions .btn {
    flex: 1;
    min-width: 0;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-title {
    font-size: 20px;
  }

  .modal-subtitle {
    font-size: 12px;
    line-height: 1.5;
  }

  .detail-body {
    padding: 14px 16px 24px;
  }

  .detail-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .detail-kpi {
    padding: 12px;
  }

  .detail-kpi-value {
    font-size: 16px;
  }

  .ai-summary {
    padding: 16px 14px;
  }

  .ai-summary-head {
    align-items: flex-start;
  }

  .ai-summary-head .btn {
    padding: 6px 8px;
    font-size: 11px;
  }

  .detail-tabs {
    margin: 0 -16px 14px;
    padding: 9px 16px;
  }

  .detail-info-grid {
    grid-template-columns: 1fr;
  }

  .detail-info.wide,
  .detail-info.full {
    grid-column: auto;
  }

  .timeline-head {
    display: block;
  }

  .timeline-meta {
    margin-top: 4px;
  }

  .timeline-result {
    grid-template-columns: 1fr;
  }

  .detail-footer {
    padding: 10px 12px;
  }

  .detail-footer > .muted {
    display: none;
  }

  .detail-footer-actions {
    width: 100%;
  }

  .detail-footer-actions .btn {
    flex: 1;
    padding-right: 7px;
    padding-left: 7px;
    font-size: 12px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
    left: 16px;
    text-align: center;
  }
}