/* public/assets/css/pages/admin-event-reports.css
 * Event Reports module — self-contained: the same markup renders inside the
 * admin Home "Event reports" section and on /admin-event-reports, so nothing
 * here leans on an admin-only or Home-only stylesheet. Everything is scoped
 * under .aer except the at-risk popup, which Modal mounts in
 * #modal-container. Charts style themselves (Components.LineChart). Tokens
 * only. */

.aer {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  min-width: 0;
}
.aer .aer-icon { width: 18px; height: 18px; flex: none; }

/* ===== Head ===== */
.aer .aer-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.aer .aer-head__id { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.aer .aer-head__badge {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: var(--color-tile-popular);
  color: var(--color-tile-popular-ink);
}
.aer .aer-head__title { margin: 0; font-size: var(--text-lg); font-weight: 800; color: var(--color-text); }
.aer .aer-head__sub { margin: 2px 0 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.aer .aer-head__actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); }
.aer .aer-picker { display: flex; flex-direction: column; gap: 4px; min-width: 260px; }
.aer .aer-picker label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); }
.aer .aer-picker select {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); font: inherit; font-size: var(--text-sm);
}

/* ===== Stage strip ===== */
.aer .aer-stages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.aer .aer-stages[hidden] { display: none; }
.aer .aer-stage {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px 12px;
  border: 1px dashed var(--color-border);
  border-top: 4px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.aer .aer-stage--done { background: var(--color-surface-muted); border-style: solid; border-top-color: var(--color-text-subtle); }
.aer .aer-stage--now { background: var(--color-accent-soft); border: 2px solid var(--color-accent); border-top-width: 4px; }
.aer .aer-stage__top { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--text-xs); font-weight: 700; color: var(--color-text-muted); }
.aer .aer-stage--now .aer-stage__top { color: var(--color-accent-text); }
.aer .aer-stage__tag { font-weight: 600; }
.aer .aer-stage__label { font-size: var(--text-sm); font-weight: 700; color: var(--color-text); }
.aer .aer-stage__sub { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ===== Tiles ===== */
.aer .aer-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.aer .aer-tile {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface);
  min-width: 0;
}
.aer .aer-tile__icon { width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.aer .aer-tile--provider .aer-tile__icon { background: var(--color-tile-popular); color: var(--color-tile-popular-ink); }
.aer .aer-tile--buyer .aer-tile__icon { background: var(--color-accent-soft); color: var(--color-accent); }
.aer .aer-tile--neutral .aer-tile__icon { background: var(--color-surface-muted); color: var(--color-text-muted); }
.aer .aer-tile__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.aer .aer-tile__label { font-size: var(--text-sm); color: var(--color-text-muted); }
.aer .aer-tile__value { font-size: var(--text-2xl); font-weight: 800; line-height: 1.15; color: var(--color-text); }
.aer .aer-tile--provider .aer-tile__value { color: var(--color-tile-popular-ink); }
.aer .aer-tile--buyer .aer-tile__value { color: var(--color-accent); }
.aer .aer-tile__sub { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ===== Chart grid + panels ===== */
.aer .aer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.aer .aer-panel { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.aer .aer-panel__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-4) var(--space-2); }
.aer .aer-panel__head h3 { margin: 0; font-size: var(--text-md); font-weight: 700; color: var(--color-text); }
.aer .aer-panel__head p { margin: 2px 0 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.aer .aer-panel__body { padding: 4px var(--space-3) 0; min-height: 200px; }
.aer .aer-panel__foot { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) var(--space-4) var(--space-4); }
.aer .aer-note { margin: 0; font-size: var(--text-xs); color: var(--color-text-muted); }
.aer .aer-risk-count { font-weight: 700; }

/* ===== States (panels and popup) ===== */
.aer-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); min-height: 180px; padding: var(--space-6) var(--space-4); text-align: center; color: var(--color-text-muted); font-size: var(--text-sm); }
.aer-state strong { color: var(--color-text); font-size: var(--text-md); }
.aer-state__icon { width: 26px; height: 26px; color: var(--color-text-subtle); }
.aer-state--error .aer-state__icon { color: var(--color-danger); }
.aer-spinner { width: 24px; height: 24px; border: 3px solid var(--color-border); border-top-color: var(--color-accent); border-radius: 50%; animation: aer-spin 0.8s linear infinite; }
@keyframes aer-spin { to { transform: rotate(360deg); } }

/* ===== At-risk popup (mounts in #modal-container, outside .aer) ===== */
.modal.aer-risk-modal { width: min(1080px, calc(100vw - 32px)); max-width: none; }
.aer-risk { display: flex; flex-direction: column; gap: var(--space-3); }
.aer-risk .aer-icon { width: 16px; height: 16px; }
.aer-risk__toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; }
.aer-search { position: relative; flex: 1 1 280px; }
.aer-search .aer-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-subtle); }
.aer-search input { width: 100%; height: 40px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0 12px 0 36px; font: inherit; font-size: var(--text-sm); }
.aer-risk__count { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.aer-risk__note { margin: 0; font-size: var(--text-xs); color: var(--color-text-muted); }
.aer-risk__note--warn { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--color-warning-soft); color: var(--color-warning-text); }
.aer-risk__table { max-height: 60vh; overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.aer-table { width: 100%; min-width: 860px; border-collapse: collapse; }
.aer-table th { position: sticky; top: 0; background: var(--color-surface-muted); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); padding: 10px 12px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.aer-table td { padding: 10px 12px; border-bottom: 1px solid var(--color-divider); font-size: var(--text-sm); color: var(--color-text); white-space: nowrap; }
.aer-table .aer-firm { font-weight: 600; }
.aer-risk__nomatch { padding: var(--space-4); text-align: center; font-size: var(--text-sm); color: var(--color-text-muted); }
.aer-risk__nomatch[hidden] { display: none; }
.aer-risk__footer { display: flex; justify-content: flex-end; gap: var(--space-2); }
.aer-share { display: inline-flex; align-items: center; gap: 8px; }
.aer-share__bar { display: inline-block; width: 90px; height: 6px; border-radius: 999px; background: var(--color-divider); overflow: hidden; }
.aer-share__fill { display: block; height: 6px; background: var(--color-tile-popular-ink); }
.aer-yn { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--color-surface-muted); font-size: 12px; font-weight: 600; }
.aer-yn--no { background: transparent; border: 1px dashed var(--color-border); color: var(--color-text-muted); }

/* ===== Narrow ===== */
@media (max-width: 1100px) {
  .aer .aer-grid { grid-template-columns: minmax(0, 1fr); }
  .aer .aer-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .aer .aer-tiles { grid-template-columns: minmax(0, 1fr); }
  .aer .aer-picker { min-width: 0; flex: 1 1 100%; }
}
