/* Customer CRM detail modal — unlayered, load last */
#modal .modal-card.modal-customer-crm {
  max-width: min(720px, calc(100vw - 24px));
}

#modal .modal-card.modal-customer-crm #modalForm {
  padding: 24px;
}

@media (max-width: 720px) {
  #modal .modal-card.modal-customer-crm #modalForm {
    padding: 14px;
  }
}

#modal .customer-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#modal .customer-hero {
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid #c7d2fe;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 48%, #ffffff 100%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}

#modal .customer-hero-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}

#modal .customer-hero-source {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

#modal .customer-hero-inquiry {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e2e8f0;
}

#modal .customer-hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

#modal .customer-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

#modal .customer-tag--empty {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
  font-weight: 600;
}

#modal .customer-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

#modal .customer-kpi-card {
  padding: 14px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  min-width: 0;
}

#modal .customer-kpi-card--spend {
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
  border-color: #bfdbfe;
}

#modal .customer-kpi-card--profit {
  background: linear-gradient(180deg, #ecfdf5 0%, #f8fafc 100%);
  border-color: #a7f3d0;
}

#modal .customer-kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

#modal .customer-kpi-value {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  word-break: break-word;
}

#modal .customer-kpi-card--spend .customer-kpi-value {
  color: #1d4ed8;
}

#modal .customer-kpi-card--profit .customer-kpi-value {
  color: #047857;
}

#modal .customer-section {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

#modal .customer-section-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

#modal .customer-rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#modal .customer-rank-card {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
}

#modal .customer-rank-card:first-child {
  background: linear-gradient(90deg, #fffbeb 0%, #fafafa 100%);
  border-color: #fde68a;
}

#modal .customer-rank-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #e2e8f0;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#modal .customer-rank-card:first-child .customer-rank-num {
  background: #fbbf24;
  color: #78350f;
}

#modal .customer-rank-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

#modal .customer-rank-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

#modal .customer-rank-meta strong {
  color: #0f172a;
  font-weight: 800;
}

#modal .customer-rank-share {
  font-size: 12px;
  font-weight: 800;
  color: #2563eb;
  white-space: nowrap;
}

#modal .customer-product-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

#modal .customer-product-table th,
#modal .customer-product-table td {
  padding: 10px 20px;
  padding-inline: 20px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

#modal .customer-product-table th {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  background: #f8fafc;
}

#modal .customer-product-table th:nth-child(1),
#modal .customer-product-table td:nth-child(1) {
  text-align: left;
  width: 40%;
}

#modal .customer-product-table th:nth-child(2),
#modal .customer-product-table td:nth-child(2) {
  text-align: center;
  width: 14%;
}

#modal .customer-product-table th:nth-child(3),
#modal .customer-product-table td:nth-child(3),
#modal .customer-product-table th:nth-child(4),
#modal .customer-product-table td:nth-child(4) {
  text-align: right;
}

#modal .customer-product-table th:nth-child(3),
#modal .customer-product-table td:nth-child(3) {
  width: 26%;
}

#modal .customer-product-table th:nth-child(4),
#modal .customer-product-table td:nth-child(4) {
  width: 20%;
}

#modal .customer-product-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#modal .customer-product-rank {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#modal .customer-product-table tbody tr:first-child .customer-product-rank {
  background: #fbbf24;
  color: #78350f;
}

#modal .customer-product-name-text {
  font-weight: 700;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

#modal .customer-product-qty {
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

#modal .customer-product-rev,
#modal .customer-product-share {
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#modal .customer-product-share {
  color: #2563eb;
  font-weight: 800;
}

#modal .customer-product-table tbody tr:last-child td {
  border-bottom: none;
}

#modal .customer-order-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

#modal .customer-order-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
}

#modal .customer-order-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#modal .customer-order-head strong {
  font-size: 14px;
  color: #0f172a;
}

#modal .customer-order-date {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

#modal .customer-order-head .status-badge {
  margin-left: auto;
}

#modal .customer-order-lines {
  font-size: 13px;
  color: #334155;
  line-height: 1.35;
}

#modal .customer-order-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#modal .customer-order-money {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

#modal .customer-order-profit {
  font-size: 12px;
  font-weight: 700;
  color: #059669;
}

#modal .customer-behavior-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

#modal .customer-behavior-cell {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#modal .customer-behavior-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

#modal .customer-behavior-value {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.3;
  word-break: break-word;
}

#modal .customer-crm-footer {
  background: #f8fafc;
  border-color: #e2e8f0;
}

#modal .customer-crm-rows {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

#modal .customer-crm-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}

#modal .customer-crm-row span {
  color: #94a3b8;
  font-weight: 600;
}

#modal .customer-crm-row strong {
  color: #334155;
  font-weight: 700;
  word-break: break-word;
}

#modal .customer-crm-row--full {
  grid-column: 1 / -1;
}

#modal .customer-empty {
  font-size: 13px;
  color: #94a3b8;
  padding: 8px 2px;
}

#modal .customer-inq-more {
  margin-top: 8px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
}

#modal .customer-inq-more summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  list-style: none;
}

#modal .customer-inq-more summary::-webkit-details-marker {
  display: none;
}

@media (max-width: 720px) {
  #modal .customer-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  #modal .customer-kpi-card {
    padding: 12px;
  }

  #modal .customer-kpi-value {
    font-size: 15px;
  }

  #modal .customer-product-table-wrap {
    display: none !important;
  }

  #modal .customer-rank-list--mo {
    display: flex !important;
  }

  #modal .customer-behavior-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #modal .customer-crm-rows {
    grid-template-columns: 1fr;
  }

  #modal .customer-order-head .status-badge {
    margin-left: 0;
  }
}

#modal .customer-rank-list--mo {
  display: none;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 721px) {
  #modal .customer-product-table-wrap {
    display: block;
  }
}
