/**
 * Membership Report Page
 *
 * Series colours are one entity each, fixed across every chart on the page
 * (active = slot 1, overdue = 2, new = 3, lapsed = 4 of the validated
 * categorical order). Dark values are separate steps validated against the
 * dark card surface, not an automatic flip.
 */

.mr-page {
  --mr-active: #2a78d6;
  --mr-overdue: #eb6834;
  --mr-new: #1baf7a;
  --mr-lapsed: #eda100;
  --mr-good: #006300;
  --mr-bad: #d03b3b;
  --mr-grid: var(--border-light);
  --mr-axis: var(--border-color);

  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1200px;
}

[data-theme="dark"] .mr-page {
  --mr-active: #3987e5;
  --mr-overdue: #d95926;
  --mr-new: #199e70;
  --mr-lapsed: #c98500;
  --mr-good: #0ca30c;
  --mr-bad: #e66767;
}

.mr-muted {
  color: var(--text-secondary);
}

/* ── Toolbar ─────────────────────────────────────────── */

.mr-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}

.mr-toolbar-actions {
  display: flex;
  gap: 8px;
}

.mr-refreshing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mr-spinner-inline {
  width: 12px;
  height: 12px;
  border-width: 2px;
  margin: 0;
}

.mr-empty {
  text-align: center;
  padding: 48px 24px;
}

/* ── Summary cards ───────────────────────────────────── */

.mr-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 16px;
}

.mr-summary-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mr-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mr-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.mr-summary-month {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}

.mr-tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px 20px;
}

/* Totals share the first row; in-month counts sit three across beneath */
.mr-tile-total {
  grid-column: span 2;
}

.mr-tile-flow {
  grid-column: span 2;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.mr-tile-flow .mr-tile-value {
  font-size: 24px;
}

@media (max-width: 480px) {
  .mr-tile-total,
  .mr-tile-flow {
    grid-column: span 3;
  }
}

.mr-tile-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.mr-tile-value {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-primary);
}

.mr-delta {
  font-size: 12px;
  margin-top: 2px;
}

.mr-delta-good {
  color: var(--mr-good);
}

.mr-delta-bad {
  color: var(--mr-bad);
}

.mr-summary-note {
  font-size: 12px;
  margin: 0;
}

/* ── Badges ──────────────────────────────────────────── */

.mr-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.mr-badge-live {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

[data-theme="dark"] .mr-badge-live {
  color: #86b6ef;
}

.mr-badge-provisional {
  background: var(--bg-warning-subtle);
  color: var(--text-primary);
  border-color: rgba(245, 158, 11, 0.45);
}

.mr-badge-final {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.mr-badge-estimated {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
  border-style: dashed;
}

/* ── Sections & table ────────────────────────────────── */

.mr-section-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.mr-section-note {
  font-size: 13px;
  margin: 0 0 12px;
}

.mr-page .mr-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Let multi-word headers wrap so every column fits without scrolling */
.mr-page #mr-table th {
  white-space: normal;
  line-height: 1.25;
  vertical-align: bottom;
}

.mr-page #mr-table td.mr-num {
  white-space: nowrap;
}

.mr-page tr.mr-row-highlight > td {
  background: var(--color-primary-light);
}

.mr-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 16px 24px;
  padding: 8px 4px;
  white-space: normal;
}

.mr-detail-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.mr-detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.mr-detail-list li {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ── Charts ──────────────────────────────────────────── */

.mr-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mr-chart-wide {
  grid-column: 1 / -1;
}

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

.mr-chart-card {
  margin: 0;
  padding: 20px;
  min-width: 0;
}

.mr-chart-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 13px;
}

.mr-chart-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.mr-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-secondary);
}

.mr-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mr-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.mr-chart {
  position: relative;
  width: 100%;
  min-width: 0;
}

/* Scales with the card until the resize observer redraws at the new width,
   so a stale pixel width can never hold the layout open */
.mr-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.mr-grid {
  stroke: var(--mr-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.mr-axis {
  stroke: var(--mr-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.mr-tick {
  fill: var(--text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.mr-end-label {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

.mr-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.mr-dot {
  stroke: var(--bg-surface);
  stroke-width: 2;
}

.mr-dot-open {
  fill: var(--bg-surface);
  stroke-width: 2;
}

.mr-crosshair {
  stroke: var(--mr-axis);
  stroke-width: 1;
}

.mr-overlay,
.mr-hit {
  fill: transparent;
  outline: none;
}

.mr-hit:hover,
.mr-hit-active,
.mr-hit:focus-visible {
  fill: var(--bg-tertiary);
}

.mr-overlay:focus-visible {
  stroke: var(--color-primary);
  stroke-width: 1;
}

/* Month-to-date column is still accumulating */
.mr-bar-partial {
  opacity: 0.55;
}

.mr-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  min-width: 140px;
  white-space: nowrap;
}

.mr-tooltip-title {
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.mr-tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
}

.mr-tooltip-key {
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

.mr-footnote {
  font-size: 12px;
  line-height: 1.7;
  margin: 0;
}

.mr-bar {
  pointer-events: none;
}

/* Month-on-month change shown beside each total in the table */
.mr-change-inline {
  display: inline-block;
  min-width: 3.2em;
  margin-left: 6px;
  font-size: 12px;
  text-align: right;
}
