/* Marketing › Emails › Statistics (public/email-stats-dashboard.js): GHL's sample-data banner,
   Engagement summary, Performance analysis, trend chart and Top performing emails. */
:root {
  --es-campaign: #4338ca; --es-workflow: #7c5cf0; --es-bulk: #38bdf8; --es-sequence: #0f9f8f; --es-all: var(--text);
  --es-track: #eef0f6; --es-grid: #e6e9f0;
}
:root[data-theme="midnight"] {
  --es-campaign: #7b83ff; --es-workflow: #a78bfa; --es-bulk: #4cc7f5; --es-sequence: #2dd4bf;
  --es-track: rgba(255, 255, 255, .06); --es-grid: rgba(255, 255, 255, .09);
}

.es { display: flex; flex-direction: column; gap: 18px; padding: 18px 20px 24px; }
.es-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 14px; }
.es-banner-ico { display: inline-flex; width: 34px; height: 34px; border-radius: 9px; align-items: center; justify-content: center; background: var(--surface); flex: none; }
.es-banner-txt { flex: 1; min-width: 0; font-weight: 500; }
.es-banner .btn { white-space: nowrap; }

.es-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.es-pill { appearance: none; -webkit-appearance: none; border: 1px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2368758a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; color: var(--text); font: inherit; font-size: 14px; border-radius: 999px; padding: 8px 34px 8px 16px; cursor: pointer; }
.es-pill:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.es-filters .es-spacer { flex: 1; }

.es-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.es-card-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.es-card-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
.es-card-head p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.es-card-head .es-grow { flex: 1; min-width: 0; }
.es-card-body { padding: 16px 20px 18px; }
.es-h2 { margin: 6px 0 0; font-size: 17px; font-weight: 650; }
.es-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }

/* Engagement summary: one stacked bar per step, the % of delivered at the right. */
.es-funnel { display: grid; grid-template-columns: 76px minmax(0, 1fr) 76px; column-gap: 12px; row-gap: 6px; align-items: center; }
.es-f-label { font-size: 14px; text-align: right; color: var(--text); }
.es-track { position: relative; height: 38px; background: var(--es-track); border-radius: 3px; display: flex; overflow: hidden; }
.es-seg { height: 100%; min-width: 0; transition: width .35s ease; }
.es-seg:hover { filter: brightness(1.12); }
.es-f-pct { font-size: 14.5px; font-weight: 600; text-align: center; padding: 8px 4px; border-radius: 6px; background: var(--es-track); }
.es-axis { grid-column: 2; position: relative; height: 22px; margin-top: 4px; }
.es-axis span { position: absolute; transform: translateX(-50%); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.es-legend { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 12px; font-size: 13.5px; }
.es-legend button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.es-legend button.off { opacity: .4; text-decoration: line-through; }
.es-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.es-dot.sq { border-radius: 2px; }

/* Performance analysis */
.es-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 12px; }
.es-stat { text-align: left; font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px 18px; cursor: pointer; }
.es-stat:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.es-stat.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.es-stat-t { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; }
.es-stat-t .ico { color: var(--muted); }
.es-stat-v { font-size: 32px; font-weight: 650; letter-spacing: -.02em; margin: 10px 0 8px; font-variant-numeric: tabular-nums; }
.es-delta { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.es-pill-d { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 13.5px; font-weight: 600; border: 1px solid; }
.es-pill-d.good { color: #15803d; border-color: #86d7a8; background: #f0fdf4; }
.es-pill-d.bad { color: #b42318; border-color: #f2a6a0; background: #fef3f2; }
.es-pill-d.flat { color: var(--muted); border-color: var(--line); background: var(--hover); }
:root[data-theme="midnight"] .es-pill-d.good { color: #6ee7a0; border-color: rgba(110, 231, 160, .45); background: rgba(34, 197, 94, .12); }
:root[data-theme="midnight"] .es-pill-d.bad { color: #fda29b; border-color: rgba(253, 162, 155, .45); background: rgba(240, 68, 56, .12); }

/* Trend chart */
.es-chart-wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: stretch; }
.es-metric-box { border: 1px solid var(--line); border-radius: 10px; padding: 18px; align-self: start; }
.es-metric-box .es-stat-v { font-size: 34px; margin: 8px 0 10px; }
.es-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; color: var(--muted); padding: 3px 0; }
.es-kv b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.es-plot { position: relative; min-width: 0; }
.es-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.es-plot text { fill: var(--muted); font-size: 12.5px; font-family: inherit; }
.es-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, .16); padding: 8px 10px; font-size: 12.5px; min-width: 150px; }
.es-tip b { display: block; margin-bottom: 4px; }
.es-tip div { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.es-tip i { display: inline-flex; align-items: center; gap: 6px; font-style: normal; color: var(--muted); }

/* Top performing emails */
.es-top-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.es-top-head .es-grow { flex: 1; min-width: 200px; }
.es-seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.es-seg-toggle button { border: 0; background: none; font: inherit; font-size: 14px; padding: 9px 18px; cursor: pointer; color: var(--text); }
.es-seg-toggle button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.es-table { width: 100%; border-collapse: collapse; margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 14px; }
.es-table th { text-align: left; font-weight: 500; padding: 12px 14px; background: var(--hover); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.es-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.es-table th:last-child { border-right: 0; }
.es-table tr:last-child td { border-bottom: 0; }
.es-table td:first-child { font-weight: 600; }
.es-table tr.clickable { cursor: pointer; }
.es-table tr.clickable:hover td { background: var(--hover); }
.es-empty { padding: 28px 0 8px; text-align: center; color: var(--muted); font-size: 13.5px; }
.es-foot { font-size: 12.5px; color: var(--muted); }

@media (max-width: 1100px) { .es-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .es-chart-wrap { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .es { padding: 12px; }
  .es-cards { grid-template-columns: 1fr; }
  .es-funnel { grid-template-columns: 58px minmax(0, 1fr) 54px; column-gap: 8px; }
  .es-banner { flex-wrap: wrap; }
}

.es-sections { display: flex; flex-direction: column; gap: 18px; }
