.cdp-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: #ffffff;
  font-family: 'Public Sans', -apple-system, sans-serif;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
}

/* Add a subtle background glow */
.cdp-container::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(102, 37, 130, 0.08) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

/* Every rule below is prefixed with the ".cdp-container" ancestor (instead of
   the bare class alone) so it always outranks the host page's blanket
   ".dispatch-container * { margin: 0; padding: 0; }" reset, which shares the
   same specificity as a plain class selector and would otherwise win the
   cascade tie-break unpredictably depending on stylesheet load order.
   Every margin/padding value is additionally marked !important because a
   sibling inline <style> block scopes an even more aggressive
   "#customer-panel-wrap * { margin: revert; padding: revert; }" reset over
   this whole component, using an ID selector no class-based selector can
   out-rank on specificity alone. (`gap` is untouched by either reset, so it
   doesn't need `!important`.) */

.cdp-container .cdp-top-pinned {
  flex-shrink: 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 20;
  position: relative;
}

.cdp-container .cdp-header {
  padding: 16px 16px 12px 16px !important;
  position: relative;
}

.cdp-container .cdp-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 7px !important;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.cdp-container .cdp-close-btn:hover {
  background: rgba(102, 37, 130, 0.08);
  color: #662582;
  transform: rotate(90deg) scale(1.1);
}

.cdp-container .cdp-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 24px !important;
  margin-bottom: 12px !important;
}

.cdp-container .cdp-header-main {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.cdp-container .cdp-avatar-large {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b4fa8, #662582);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 10px 25px -5px rgba(102, 37, 130, 0.4);
  position: relative;
}
.cdp-container .cdp-avatar-large::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.cdp-container .cdp-header-info {
  flex: 1;
  min-width: 0;
}

.cdp-container .cdp-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px !important;
}

.cdp-container .cdp-customer-name {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cdp-container .cdp-id-pill {
  flex-shrink: 0;
  padding: 2px 6px !important;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.cdp-container .cdp-contact-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.cdp-container .cdp-contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 3px 10px 3px 3px !important;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.7);
  border: 1px solid rgba(226, 232, 240, 0.5);
}
.cdp-container .cdp-contact-chip:hover {
  color: #662582;
  background: rgba(102, 37, 130, 0.05);
  border-color: rgba(102, 37, 130, 0.15);
  transform: translateY(-1px);
}

.cdp-container .cdp-contact-icon-bg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  color: #662582;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  flex-shrink: 0;
}

/* Lifetime value hero card — sits beside the identity block in the header row */
.cdp-container .cdp-ltv-card {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px !important;
  border-radius: 10px;
  background: linear-gradient(135deg, #f3e9f7, #f8fafc);
  border: 1px solid rgba(102, 37, 130, 0.12);
}
.cdp-container .cdp-ltv-card.zero {
  background: #f8fafc;
  border-color: rgba(226, 232, 240, 0.8);
}

.cdp-container .cdp-ltv-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #8b4fa8, #662582);
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px -2px rgba(102, 37, 130, 0.4);
}
.cdp-container .cdp-ltv-card.zero .cdp-ltv-icon {
  background: #cbd5e1;
  box-shadow: none;
}

.cdp-container .cdp-ltv-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cdp-container .cdp-ltv-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-weight: 700;
  white-space: nowrap;
}

.cdp-container .cdp-ltv-val {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
  color: #662582;
  white-space: nowrap;
}
.cdp-container .cdp-ltv-card.zero .cdp-ltv-val {
  color: #94a3b8;
}

.cdp-container .cdp-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 16px 16px 16px !important;
}

.cdp-container .cdp-metric-tile {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 12px;
  padding: 10px 12px !important;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.cdp-container .cdp-metric-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #8b4fa8, #662582);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cdp-container .cdp-metric-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(102, 37, 130, 0.08);
  border-color: rgba(102, 37, 130, 0.15);
}
.cdp-container .cdp-metric-tile:hover::before {
  opacity: 1;
}

.cdp-container .cdp-metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(102, 37, 130, 0.07);
  color: #662582;
  flex-shrink: 0;
}

.cdp-container .cdp-metric-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cdp-container .cdp-metric-value {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cdp-container .cdp-metric-value.zero {
  color: #cbd5e1;
}

.cdp-container .cdp-metric-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-top: 2px !important;
}

.cdp-container .cdp-scrollable-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px !important;
  background: #f8fafc; /* slight contrast for history area */
  position: relative;
  z-index: 10;
}
.cdp-container .cdp-scrollable-body::-webkit-scrollbar {
  width: 6px;
}
.cdp-container .cdp-scrollable-body::-webkit-scrollbar-track {
  background: transparent;
}
.cdp-container .cdp-scrollable-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.cdp-container .cdp-history-container {
  display: flex;
  flex-direction: column;
}

.cdp-container .cdp-month-group {
  margin-bottom: 24px !important;
}
.cdp-container .cdp-month-group:last-child {
  margin-bottom: 0 !important;
}

.cdp-container .cdp-month-label {
  position: sticky;
  top: -16px;
  background: rgba(248, 250, 252, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 0 !important;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #662582;
  z-index: 10;
  margin-bottom: 8px !important;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cdp-container .cdp-month-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(102, 37, 130, 0.15) 0%, transparent 100%);
}

.cdp-container .cdp-order-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 8px;
  margin-bottom: 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.01);
  transition: all 0.2s ease;
  cursor: pointer;
  overflow: hidden;
}
.cdp-container .cdp-order-card:last-child {
  margin-bottom: 0 !important;
}
.cdp-container .cdp-order-card:hover {
  transform: translateX(4px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.04);
  border-color: rgba(102, 37, 130, 0.2);
}
.cdp-container .cdp-order-card.expanded {
  border-color: #8b4fa8;
  box-shadow: 0 8px 20px rgba(102, 37, 130, 0.08);
  transform: translateX(4px);
}

.cdp-container .cdp-order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px !important;
}

.cdp-container .cdp-order-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cdp-container .cdp-order-id {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.cdp-container .cdp-order-date {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cdp-container .cdp-order-date svg {
  color: #94a3b8;
}

.cdp-container .cdp-order-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.cdp-container .cdp-order-price {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.cdp-container .cdp-status-badge {
  padding: 2px 6px !important;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cdp-container .cdp-status-badge::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

.cdp-container .cdp-status-blue {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}
.cdp-container .cdp-status-blue::before { background: #3b82f6; }

.cdp-container .cdp-status-amber {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}
.cdp-container .cdp-status-amber::before { background: #f59e0b; }

.cdp-container .cdp-status-green {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}
.cdp-container .cdp-status-green::before { background: #22c55e; }

.cdp-container .cdp-status-red {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.cdp-container .cdp-status-red::before { background: #ef4444; }

.cdp-container .cdp-order-details-wrapper {
  border-top: 1px dashed rgba(226, 232, 240, 0.8);
  background: #fafaf9;
  padding: 10px 14px;
}

.cdp-container .cdp-order-details-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
  padding: 8px 0;
}

.cdp-container .cdp-order-details-empty {
  font-size: 11px;
  color: #94a3b8;
  padding: 8px 0;
}

.cdp-container .cdp-order-details-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cdp-container .cdp-order-item-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
}

.cdp-container .cdp-item-qty {
  font-weight: 700;
  color: #662582;
  width: 24px;
  flex-shrink: 0;
}

.cdp-container .cdp-item-name {
  flex: 1;
  color: #334155;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.cdp-container .cdp-item-total {
  font-weight: 800;
  color: #0f172a;
}
