/* ── Analytics ─────────────────────────────────────────────────────────── */
.analytics-hint {
  max-width: 760px;
  margin: -12px 0 16px;
  color: var(--muted);
}

.analytics-status {
  margin: 0 0 12px;
}

.analytics-status[hidden] {
  display: none;
}

#analytics-error {
  margin: 0 0 12px;
}

#analytics-error:empty {
  min-height: 0;
  margin: 0;
}

.analytics-tools {
  align-items: center;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
}

.segmented-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.segmented-btn:hover {
  color: var(--ink);
}

.segmented-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

.segmented-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.analytics-generated {
  margin: 0 0 18px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.analytics-panel {
  min-width: 0;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
}

.analytics-panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.analytics-panel-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  letter-spacing: -0.02em;
}

.analytics-panel-head .eyebrow {
  margin-bottom: 2px;
}

.analytics-chart {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 220px;
  padding-top: 8px;
  border-bottom: 1px solid var(--line);
}

.analytics-chart[hidden] {
  display: none;
}

.analytics-bar-col {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
  height: 100%;
  border-radius: 6px;
}

.analytics-bar-track {
  display: flex;
  flex: 1 1 auto;
  align-items: flex-end;
  min-height: 0;
}

.analytics-bar {
  width: 100%;
  max-width: 26px;
  height: var(--analytics-bar-height, 0%);
  min-height: 2px;
  margin: 0 auto;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  opacity: 0.82;
  transition:
    opacity 120ms ease,
    height 180ms ease;
}

.analytics-bar.is-zero {
  background: var(--line);
  opacity: 1;
}

.analytics-bar-col:hover .analytics-bar {
  opacity: 1;
}

.analytics-bar-label {
  color: var(--muted-2);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.analytics-empty {
  margin: 18px 0 0;
}

.analytics-empty[hidden] {
  display: none;
}

.analytics-funnel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.analytics-funnel[hidden] {
  display: none;
}

.analytics-funnel-step {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.analytics-funnel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.analytics-funnel-label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
}

.analytics-funnel-count {
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.analytics-funnel-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.analytics-funnel-fill {
  display: block;
  width: var(--analytics-funnel-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  opacity: 0.85;
}

.analytics-funnel-step:first-child .analytics-funnel-fill {
  opacity: 1;
}

.analytics-funnel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 10px;
  color: var(--muted-2);
  font-size: 11.5px;
}

.analytics-funnel-split {
  color: var(--muted);
}

.analytics-event-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.analytics-event-label {
  color: var(--ink);
  font-weight: 650;
}

.analytics-event-code {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11.5px;
}

.analytics-event-count,
.analytics-event-users {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .analytics-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .analytics-tools .segmented {
    justify-self: start;
  }

  .analytics-chart {
    height: 180px;
    gap: 3px;
  }
}

@media (max-width: 620px) {
  .analytics-tools {
    justify-content: space-between;
    width: 100%;
  }

  .analytics-panel {
    padding: 14px;
  }

  .analytics-chart {
    height: 160px;
  }

  .analytics-bar {
    max-width: 16px;
  }

  .analytics-bar-label {
    font-size: 9.5px;
  }

  .analytics-funnel-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Engagement (chat features) ─────────────────────────────────────────── */
.engagement-panel {
  margin-top: 14px;
}

.engagement-head {
  flex-wrap: wrap;
  align-items: center;
}

.engagement-kpis {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  margin-bottom: 12px;
}

.engagement-charts {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.engagement-chart-block {
  min-width: 0;
}

.engagement-chart-block .analytics-panel-head {
  align-items: center;
  margin-bottom: 10px;
}

.engagement-chart-block h4 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.engagement-series-select {
  min-height: 34px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.engagement-series-select:focus-visible,
.engagement-table summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 90 daily bars must fit the half-width block without overflowing. */
.engagement-panel .analytics-chart {
  gap: 1px;
}

.engagement-line {
  height: 220px;
  border-bottom: 1px solid var(--line);
}

.engagement-line[hidden] {
  display: none;
}

.engagement-line-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.engagement-line-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}

.engagement-line-dot {
  fill: var(--accent);
}

.engagement-line-axis,
.engagement-line-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.engagement-line-grid {
  stroke-dasharray: 3 4;
}

.engagement-line-tick {
  fill: var(--muted-2);
  font-size: 10.5px;
}

.engagement-table {
  margin-top: 16px;
}

.engagement-table summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.engagement-table .table-wrap {
  margin-top: 10px;
}

@media (max-width: 900px) {
  .engagement-charts {
    grid-template-columns: minmax(0, 1fr);
  }

  .engagement-line {
    height: 180px;
  }
}
