/* =====================================================================
   STATS PAGE
   ===================================================================== */

.stats-hero {
  padding: 34px 0 22px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 26px;
}
.stats-hero h1 {
  font-size: clamp(24px, 3.6vw, 34px);
  font-weight: 700;
  color: var(--text-hi);
  line-height: 1.15;
}
.stats-hero p {
  margin-top: 10px;
  max-width: 640px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
}
.stats-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.stats-controls .range-chips { margin-top: 0; }
.stats-controls .sort-select { min-width: 150px; }

/* --- KPI row: averages + records, same tile for both --- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 30px;
}
.kpi-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-surface);
}
a.kpi-tile { transition: border-color .15s, transform .15s; }
a.kpi-tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.kpi-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.kpi-value {
  font-family: ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
}
.kpi-sub {
  font-size: 12.5px;
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- chart cards --- */
.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-surface);
  padding: 20px 20px 8px;
  margin-bottom: 22px;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 6px;
}
.chart-head h2 { font-size: 16px; font-weight: 700; color: var(--text-hi); }
.chart-sub {
  margin-top: 4px;
  max-width: 560px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}
.chart-legend {
  display: flex;
  gap: 14px;
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--text-mid);
}
.chart-legend .legend-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend .legend-line {
  width: 14px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
}

.chart-body { position: relative; width: 100%; }
.chart-body svg { display: block; width: 100%; height: auto; overflow: visible; }

/* --- donut charts: leadership split + channel share --- */
.donut-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 22px;
  margin-bottom: 22px;
}
.donut-card { margin-bottom: 0; }
.donut-body { display: flex; justify-content: center; padding: 6px 0 2px; }
.donut-body svg { width: 200px; height: 200px; }
.donut-legend { flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin: 6px 0 4px; }
.donut-legend .legend-key { gap: 7px; cursor: default; }
.donut-legend .legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.donut-slice { stroke: var(--bg-surface); stroke-width: 2; transition: opacity .1s; pointer-events: none; }
.donut-hit { fill: transparent; cursor: pointer; }
.donut-hit:hover + .donut-slice { opacity: 0.82; }
.donut-center-value { font-family: ui-monospace, monospace; font-size: 22px; font-weight: 700; fill: var(--text-hi); text-anchor: middle; }
.donut-center-label { font-size: 9.5px; fill: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; text-anchor: middle; }

/* --- histogram: grouped columns, verifier vs. showcase per view-count bucket --- */
.chart-col-verifier { fill: var(--text-mid); pointer-events: none; }
.chart-col-showcase { fill: var(--primary); pointer-events: none; }

.chart-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* SVG chart chrome — hairline axes/gridlines, never dashed, one step off the surface. */
.chart-axis { stroke: var(--line-soft); stroke-width: 1; }
.chart-axis-text {
  fill: var(--text-dim);
  font-size: 10px;
  font-family: ui-monospace, monospace;
}
.chart-ref-line { stroke: var(--line); stroke-width: 1; }

.chart-dot-verifier { fill: var(--text-mid); pointer-events: none; transition: r .12s, stroke-width .12s, stroke .12s; }
.chart-dot-showcase { fill: var(--primary); pointer-events: none; transition: r .12s, stroke-width .12s, stroke .12s; }
.chart-line-verifier { stroke: var(--text-mid); pointer-events: none; }
.chart-line-showcase { stroke: var(--primary); pointer-events: none; }
.chart-bar-showcase { fill: var(--primary); pointer-events: none; transition: filter .12s; }
.chart-bar-verifier { fill: var(--text-mid); pointer-events: none; transition: filter .12s; }
.chart-bar-other { fill: var(--text-dim); pointer-events: none; transition: filter .12s; }
.chart-bar-identity { pointer-events: none; transition: filter .12s; }

.chart-mark-label {
  fill: var(--text-hi);
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  pointer-events: none;
}
.chart-bar-name {
  fill: var(--text-mid);
  font-size: 11.5px;
  pointer-events: none;
}

/* Hover: a bigger transparent hit target than the painted mark, per
   dataviz's "the hit target is bigger than the mark" rule — every
   decorative mark above is pointer-events:none precisely so hover
   always resolves to the .chart-hit layer beneath it, never to
   whichever painted shape happens to be on top at that pixel. */
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit:hover + .chart-dot-showcase,
.chart-hit:hover + .chart-dot-verifier { stroke: var(--bg-surface); stroke-width: 2; r: 6; }
.chart-bar-row:hover .chart-bar-showcase,
.chart-bar-row:hover .chart-bar-verifier,
.chart-bar-row:hover .chart-bar-other,
.chart-bar-row:hover .chart-bar-identity { filter: brightness(1.15); }

.chart-tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-surface-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-mid);
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity .1s;
  white-space: nowrap;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-title { color: var(--text-hi); font-weight: 600; margin-bottom: 2px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip .tt-key { width: 10px; height: 2px; border-radius: 1px; display: inline-block; flex-shrink: 0; }
.chart-tooltip .tt-value { color: var(--text-hi); font-weight: 600; font-family: ui-monospace, monospace; }

/* --- table-view fallback, one per chart --- */
.chart-table-toggle {
  margin: 10px 0 16px;
  font-size: 12px;
  color: var(--text-dim);
}
.chart-table-toggle summary {
  cursor: pointer;
  color: var(--text-mid);
  width: fit-content;
  transition: color .15s;
}
.chart-table-toggle summary:hover { color: var(--text-hi); }
.chart-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12.5px;
}
.chart-table th, .chart-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-family: ui-monospace, monospace;
}
.chart-table tbody tr { transition: background-color .12s; }
.chart-table tbody tr:hover { background-color: var(--bg-surface-2); }
.chart-table th {
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
}
.chart-table td { color: var(--text-mid); }
.chart-table td:first-child { color: var(--text-hi); font-family: inherit; }
