/* Stat tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--color-rule);
  box-shadow: var(--shadow-card);
}

.tile {
  display: grid;
  align-content: start;
  gap: 0.2rem;
  min-width: 0;
  padding: var(--space-card);
  background: var(--color-surface);
}

.tile-label {
  color: var(--color-ink-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tile-value {
  font-size: var(--text-figure);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.tile-value.is-name {
  font-size: 1.375rem;
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tile-note {
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

/* Chart card */
.chart-card {
  min-width: 0;
  margin: 0;
  padding: var(--space-card);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.chart-card figcaption {
  margin-bottom: 0.75rem;
}

.chart-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.chart-card figcaption p {
  margin: 0.15rem 0 0;
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

.chart-host {
  min-width: 0;
}

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

.chart-host svg:focus-visible {
  outline-offset: 6px;
}

/* Series identity */
.series-1 { --series: var(--series-1); }
.series-2 { --series: var(--series-2); }
.series-3 { --series: var(--series-3); }
.series-4 { --series: var(--series-4); }
.series-5 { --series: var(--series-5); }
.series-plain { --series: var(--chart-emphasis); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.swatch {
  width: 0.875rem;
  height: 0.1875rem;
  border-radius: 2px;
  background: var(--series);
}

.swatch.is-ring {
  width: 0.625rem;
  height: 0.625rem;
  border: 2px solid var(--series);
  border-radius: 50%;
  background: var(--color-surface);
}

/* Marks */
.grid-line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.axis-line {
  stroke: var(--chart-axis);
  stroke-width: 1;
}

.tick-label,
.mark-label {
  fill: var(--color-ink-muted);
  font-family: var(--font-text);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.mark-label {
  fill: var(--color-ink-soft);
}

.mark-label.is-strong {
  fill: var(--color-ink);
  font-weight: 700;
}

.series-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-ring {
  fill: var(--color-surface);
  stroke: var(--series);
  stroke-width: 2;
}

.series-dot {
  fill: var(--series);
  stroke: var(--color-surface);
  stroke-width: 2;
}

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

.bar {
  fill: var(--chart-neutral);
  transition: opacity var(--duration-fast) var(--ease-out);
}

.bar.is-emphasis {
  fill: var(--chart-emphasis);
}

.bar-row:hover .bar,
.heat-cell:hover {
  opacity: 0.8;
}

.heat-cell {
  stroke: var(--color-surface);
  stroke-width: 2;
}

.hit-area {
  fill: transparent;
}

.is-hidden {
  visibility: hidden;
}

.scale-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

.scale-ramp {
  width: 8rem;
  height: 0.5rem;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--diverging-negative),
    var(--diverging-neutral),
    var(--diverging-positive)
  );
}

/* Tooltip */
.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  min-width: 9rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-ink);
  font-size: var(--text-small);
  pointer-events: none;
}

.tooltip[hidden] {
  display: none;
}

.tooltip-title {
  margin: 0 0 0.25rem;
  color: var(--color-ink-muted);
  font-weight: 700;
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tooltip-row span:last-child {
  margin-left: auto;
  padding-left: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Table view */
.table-view {
  margin-top: 0.75rem;
  font-size: var(--text-small);
}

.table-view summary {
  width: fit-content;
  color: var(--color-ink-muted);
  cursor: pointer;
}

.table-view summary:hover {
  color: var(--color-ink);
}

.table-scroll {
  max-height: 18rem;
  margin-top: 0.5rem;
  overflow: auto;
}

.table-view table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table-view th,
.table-view td {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--color-rule);
  text-align: right;
  white-space: nowrap;
}

.table-view th:first-child,
.table-view td:first-child {
  text-align: left;
}

.table-view thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  color: var(--color-ink-muted);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .bar {
    transition: none;
  }
}
