/* ============================================================
   cards.css — 卡片组件
   统计卡片、图表卡片、数据卡片、漏斗卡片
   ============================================================ */

/* ============================================================
   统计卡片 (Stats Cards)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  transition: var(--tr);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  opacity: 0.08;
  transform: translate(20px, -20px);
}

.stat-card.blue::before   { background: var(--primary); }
.stat-card.green::before  { background: var(--success); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.gold::before   { background: var(--gold); }

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-base);
}

.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.orange { background: var(--orange-light); }
.stat-icon.gold   { background: var(--gold-light); }

.stat-change {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: var(--fw-semibold);
}

.stat-change.up   { background: var(--success-light); color: var(--success); }
.stat-change.down { background: var(--danger-light);  color: var(--danger); }

.stat-val {
  font-size: 22px;
  font-weight: var(--fw-bold);
  line-height: 1;
  margin-bottom: 2px;
}

.stat-card.blue .stat-val   { color: var(--primary); }
.stat-card.green .stat-val  { color: var(--success); }
.stat-card.orange .stat-val { color: var(--orange); }
.stat-card.gold .stat-val   { color: var(--gold); }

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ============================================================
   图表行
   ============================================================ */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-head-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
}

.card-head-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
}

.card-action {
  font-size: var(--fs-sm);
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.card-body {
  padding: var(--space-3);
}

/* 图表区域 */
.chart-area {
  position: relative;
  height: 200px;
}

.chart-svg {
  width: 100%;
  height: 100%;
}

/* 环形图 */
.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
}

.donut-svg {
  width: 160px;
  height: 160px;
}

.donut-legend {
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border);
}

.legend-item:last-child {
  border: none;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.legend-name {
  color: var(--text-2);
}

.legend-val {
  font-weight: var(--fw-semibold);
}

/* ============================================================
   快捷操作卡片
   ============================================================ */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: 24px;
}

.quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  cursor: pointer;
  transition: var(--tr);
  text-align: center;
  text-decoration: none;
  display: block;
}

.quick-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light, var(--border));
  box-shadow: var(--shadow);
}

.quick-icon {
  font-size: 28px;
  margin-bottom: var(--space-2);
  display: block;
}

.quick-name {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.quick-desc {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
}

/* ============================================================
   表格行容器
   ============================================================ */
.tables-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

/* ============================================================
   客户详情覆盖层
   ============================================================ */
#custDetailOverlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  pointer-events: none;
}

#custDetailOverlay.open {
  transform: translateX(0);
  pointer-events: auto;
}

.cdo-topbar {
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.cdo-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: var(--tr);
  flex-shrink: 0;
}

.cdo-back-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cdo-title-area {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.cdo-customer-name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cdo-badge {
  padding: 2px 10px;
  border-radius: 10px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  flex-shrink: 0;
}

.cdo-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.cdo-action-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: var(--tr);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-2);
}

.cdo-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cdo-action-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
  font-weight: var(--fw-semibold);
}

.cdo-action-btn.primary:hover {
  opacity: 0.88;
}

/* 三栏布局 */
.cdo-body {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  overflow: hidden;
}

.cdo-left {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--bg-card);
}

.cdo-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.cdo-right {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.cdo-section-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.cdo-info-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: var(--space-2);
}

.cdo-info-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.cdo-info-value {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
}

/* 右侧栏 */
.cdo-right-section {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.cdo-right-section:last-child {
  border-bottom: none;
}

/* 时间线 */
.cdo-timeline-item {
  display: flex;
  gap: var(--space-3);
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

.cdo-timeline-item:last-child {
  border-bottom: none;
}

.cdo-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--primary);
  margin-top: 5px;
  flex-shrink: 0;
}

.cdo-timeline-body {
  flex: 1;
  min-width: 0;
}

/* 雷达图 */
.cdo-radar-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-4) 0;
}

/* Tab 区域 */
.cdo-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  overflow-x: auto;
}

.cdo-tab {
  padding: 14px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: var(--tr);
  white-space: nowrap;
}

.cdo-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.cdo-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: var(--fw-semibold);
}

.cdo-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* 商机卡片 */
.cdo-opp-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  overflow: hidden;
  transition: border-color 0.2s;
}

.cdo-opp-card:hover {
  border-color: var(--primary-border-hov);
}

.cdo-opp-card-header {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cdo-opp-card-body {
  padding: 0 16px 14px;
  display: none;
  border-top: 1px solid var(--border);
}

.cdo-opp-card.expanded .cdo-opp-card-body {
  display: block;
}

.cdo-opp-card.expanded .cdo-opp-card-header {
  background: var(--primary-light-2);
}

/* 快速跟进表单 */
.cdo-follow-form {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

/* 商机表单区域 */
.opp-form-section {
  background: var(--bg-input);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
}

.opp-form-section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--primary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 详情字段 */
.detail-field {
  background: var(--bg-input);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.detail-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-bottom: var(--space-1);
}

.detail-value {
  font-size: var(--fs-base);
  color: var(--text);
}

.detail-tab {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: var(--tr);
}

.detail-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: var(--fw-semibold);
}