/* Every rule is scoped. No body/html/shell/mail/CRM-funnel selectors. */
.customer-analytics {
  --ca-ink: #213047; --ca-muted: #536276; --ca-border: var(--line, #d7dfe8);
  --ca-surface: #fff; --ca-soft: #f6f8fb; --ca-blue: #2563a6;
  --ca-teal: #137566; --ca-amber: #885c08;
  color: var(--ca-ink); font: inherit; line-height: 1.6;
  max-width: 1160px; margin: 0 auto; padding: 16px 12px 32px; min-width: 0;
}
.customer-analytics *, .customer-analytics *::before, .customer-analytics *::after { box-sizing: border-box; }
.customer-analytics h1, .customer-analytics h2, .customer-analytics h3, .customer-analytics p, .customer-analytics figure { margin: 0; }
.customer-analytics h1 { font-size: 1.5rem; line-height: 1.4; font-weight: 700; }
.customer-analytics h2 { font-size: 1rem; font-weight: 700; }
.customer-analytics h3 { font-size: .94rem; font-weight: 650; }
.customer-analytics .ca-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.customer-analytics .ca-note { color: var(--ca-muted); font-size: .875rem; overflow-wrap: anywhere; margin-top: 8px; }
.customer-analytics .ca-status { color: var(--ca-muted); font-size: .8125rem; min-height: 1.6em; margin-bottom: 12px; overflow-wrap: anywhere; }
.customer-analytics .ca-body { display: grid; gap: 12px; }
.customer-analytics .ca-content { min-width: 0; }
.customer-analytics .ca-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.customer-analytics .ca-stat, .customer-analytics .ca-panel {
  min-width: 0; padding: 16px; border: 1px solid var(--ca-border); border-radius: 12px; background: var(--ca-surface);
}
.customer-analytics .ca-stat { padding: 14px 16px; }
.customer-analytics .ca-stat h2 { color: var(--ca-muted); font-size: .875rem; font-weight: 500; }
.customer-analytics .ca-number { font-size: clamp(1.4rem, 3vw, 2rem); font-variant-numeric: tabular-nums; font-weight: 700; overflow-wrap: anywhere; margin: 4px 0; }
.customer-analytics .ca-section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.customer-analytics .ca-badge { display: inline-block; padding: 3px 8px; border: 1px solid var(--ca-border); border-radius: 5px; font-size: .75rem; white-space: nowrap; color: var(--ca-muted); background: var(--ca-soft); }
.customer-analytics .ca-measured, .customer-analytics .ca-complete { color: #0c6253; background: #edf8f4; border-color: #b8d9ce; }
.customer-analytics .ca-partial { color: var(--ca-amber); background: #fff8e9; border-color: #e6d19e; }
.customer-analytics .ca-unmeasured, .customer-analytics .ca-unavailable { border-style: dashed; }
.customer-analytics .ca-button, .customer-analytics select {
  font: inherit; font-size: .875rem; color: var(--ca-ink); background: var(--ca-surface); border: 1px solid var(--ca-border);
  border-radius: 8px; min-height: 44px; padding: 9px 12px; max-width: 100%; cursor: pointer;
}
.customer-analytics .ca-button { flex-shrink: 0; }
.customer-analytics .ca-button:disabled { opacity: .6; cursor: default; }
.customer-analytics :is(button, select, summary, .ca-table-wrap, a):focus-visible { outline: 3px solid var(--ca-blue); outline-offset: 3px; }
.customer-analytics .ca-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.customer-analytics .ca-control { display: inline-flex; flex-direction: column; gap: 5px; font-size: .875rem; max-width: 100%; margin-bottom: 8px; }
.customer-analytics .ca-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.customer-analytics .ca-two-col > div { min-width: 0; }
.customer-analytics .ca-chart { margin-top: 10px; }
.customer-analytics .ca-chart svg { display: block; width: 100%; height: auto; max-height: 280px; overflow: visible; }
.customer-analytics .ca-gridline { stroke: #e5eaf0; stroke-width: 1; }
.customer-analytics .ca-axis { stroke: #9baaba; stroke-width: 1; }
.customer-analytics .ca-line { stroke: var(--ca-teal); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.customer-analytics .ca-point { fill: var(--ca-teal); stroke: white; stroke-width: 1; }
.customer-analytics .ca-chart-label { fill: var(--ca-muted); font: 11px system-ui, sans-serif; }
.customer-analytics .ca-bars { display: grid; gap: 10px; }
.customer-analytics .ca-bar-row { min-width: 0; }
.customer-analytics .ca-bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: .875rem; }
.customer-analytics .ca-bar-label strong { font-variant-numeric: tabular-nums; }
.customer-analytics .ca-bars svg { width: 100%; height: 8px; display: block; margin-top: 5px; }
.customer-analytics .ca-track { fill: #edf1f6; }
.customer-analytics .ca-fill { fill: var(--ca-blue); }
.customer-analytics .ca-fill-unknown { fill: #8c99aa; }
.customer-analytics .ca-table-wrap { max-width: 100%; overflow-x: auto; margin-top: 12px; border: 1px solid var(--ca-border); border-radius: 8px; }
.customer-analytics .ca-table { border-collapse: collapse; width: 100%; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.customer-analytics .ca-table caption { text-align: left; padding: 12px; color: var(--ca-muted); font-size: .8125rem; }
.customer-analytics .ca-table th, .customer-analytics .ca-table td { padding: 10px 12px; text-align: right; border-top: 1px solid var(--ca-border); white-space: nowrap; }
.customer-analytics .ca-table thead th { font-weight: 600; background: var(--ca-soft); }
.customer-analytics .ca-table tr > :first-child { text-align: left; }
.customer-analytics .ca-table tbody th { font-weight: 500; }
.customer-analytics .ca-details { border-top: 1px solid var(--ca-border); margin-top: 14px; padding-top: 4px; min-width: 0; }
.customer-analytics .ca-details summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-size: .875rem; color: var(--ca-muted); }
.customer-analytics p.ca-empty { font-size: 1.125rem; color: var(--ca-muted); margin: 12px 0 4px; }
.customer-analytics .ca-unavailable-metrics { margin: 0; padding: 0 16px; border: 1px solid var(--ca-border); border-radius: 12px; background: var(--ca-surface); }
.customer-analytics .ca-unavailable-metrics > summary { padding: 12px 0; font-weight: 600; }
.customer-analytics .ca-missing { min-width: 0; padding: 12px 0; border-top: 1px solid var(--ca-border); }
.customer-analytics .ca-missing .ca-section-head { margin-bottom: 4px; }
.customer-analytics .ca-missing .ca-note { margin-top: 4px; }
/* The actual shell already owns the title and outer content padding. */
.customer-analytics.customer-analytics-embedded { --ca-ink: var(--ink, #213047); --ca-muted: var(--ink-2, #536276); --ca-surface: var(--panel, #fff); --ca-soft: var(--sunken, #f6f8fb); --ca-blue: var(--ai, #2563a6); --ca-teal: var(--moss, #137566); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; max-width: none; margin: 0; padding: 0; }
.customer-analytics-embedded .ca-header { grid-column: 2; grid-row: 1; margin: 0; }
.customer-analytics-embedded .ca-header > div { display: none; }
.customer-analytics-embedded .ca-status { grid-column: 1; grid-row: 1; align-self: center; margin: 0; }
.customer-analytics-embedded .ca-content { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .customer-analytics { padding: 12px 8px 24px; }
  .customer-analytics .ca-two-col { grid-template-columns: minmax(0, 1fr); }
  .customer-analytics .ca-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .customer-analytics .ca-stat, .customer-analytics .ca-panel { padding: 12px; }
  .customer-analytics .ca-stats .ca-payments { grid-column: 1 / -1; grid-row: 2; }
  .customer-analytics .ca-payments { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; }
  .customer-analytics .ca-payments h2, .customer-analytics .ca-payments .ca-note { grid-column: 1 / -1; }
  .customer-analytics .ca-payments .ca-badge { align-self: center; }
  .customer-analytics .ca-note { font-size: .8125rem; margin-top: 6px; }
  .customer-analytics .ca-number { font-size: 1.5rem; }
  .customer-analytics .ca-header { flex-wrap: wrap; }
  .customer-analytics .ca-header .ca-button { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .customer-analytics *, .customer-analytics *::before, .customer-analytics *::after { scroll-behavior: auto; animation: none; transition: none; }
}
@media (forced-colors: active) {
  .customer-analytics .ca-line, .customer-analytics .ca-axis, .customer-analytics .ca-gridline { stroke: CanvasText; }
  .customer-analytics .ca-point, .customer-analytics .ca-fill, .customer-analytics .ca-fill-unknown { fill: CanvasText; }
  .customer-analytics .ca-chart-label { fill: CanvasText; }
}

.customer-analytics[data-customer-analytics-standalone] { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif; }
