/* Statistics page: same operations-console tokens as styles.css. */

:root {
  --page-background: var(--map-background);
  --card: #20252c;
  --card-border: var(--border);
  --grid-line: rgba(255, 255, 255, 0.07);
  --axis-line: rgba(255, 255, 255, 0.18);
  --track: rgba(255, 255, 255, 0.06);
  /* Chart steps of the tile source colours, validated as a set on the
     dark surface (lightness band, CVD separation, contrast). */
  --chart-pack: #2aa85a;
  --chart-cache: #3d9bff;
  --chart-render: #d98a22;
  --chart-other: #5b636e;
  --chart-single: var(--accent);
  --status-good: #0aac23;
  --status-warning: #fbb315;
  --status-critical: var(--source-error);
  --unused-row: rgba(251, 179, 21, 0.07);
  --disk-tiles: var(--chart-cache);
  --disk-unused: var(--status-warning);
  --disk-other: #4a515b;
}

body.admin {
  height: auto;
  min-height: 100%;
  overflow: auto;
  background: var(--page-background);
}

.admin a {
  color: var(--focus);
}

/* Top bar */

.admin__bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(4px);
}

.admin__title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.admin__back {
  font-size: 12px;
}

.admin__controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin__status {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.admin__button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.admin__button:hover {
  border-color: var(--text-muted);
}

.admin__button[aria-pressed='true'] {
  border-color: var(--accent);
  color: var(--focus);
}

.admin__page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.admin__error {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--status-critical);
  border-radius: var(--radius);
  color: var(--text);
}

.admin__error::before {
  content: '\26A0  ';
  color: var(--status-critical);
}

.admin__footnote {
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.admin code {
  font-family: var(--font-mono);
}

/* Data dims while a refresh is outstanding, keeping its frame. */

.admin--stale .admin__page {
  opacity: 0.6;
  transition: opacity 0.2s;
}

/* Headline figures */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

.tile--hero {
  grid-column: span 2;
}

.tile__label {
  color: var(--text-muted);
  font-size: 12px;
}

.tile__value {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tile--hero .tile__value {
  font-size: 40px;
}

.tile__detail {
  color: var(--text-muted);
  font-size: 12px;
}

/* Cards */

.card {
  position: relative;
  min-width: 0;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}

.card__title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.card__note {
  color: var(--text-muted);
  font-size: 12px;
}

.card__table {
  margin-top: 8px;
  font-size: 12px;
}

.card__table summary {
  color: var(--text-muted);
  cursor: pointer;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
  align-items: start;
}

.stack {
  min-width: 0;
}

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

  .tile--hero {
    grid-column: 1 / -1;
  }
}

/* Legend */

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 12px;
}

.legend-row li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-key {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Timeline chart */

.chart {
  position: relative;
  width: 100%;
}

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

.chart__grid {
  stroke: var(--grid-line);
  stroke-width: 1;
}

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

.chart__tick {
  fill: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart__column {
  outline: none;
}

.chart__hit {
  fill: transparent;
}

.chart__column:hover .chart__hit,
.chart__column:focus .chart__hit {
  fill: rgba(255, 255, 255, 0.06);
}

.chart__column:focus-visible .chart__hit {
  stroke: var(--focus);
  stroke-width: 1;
}

.chart__empty {
  fill: var(--text-muted);
  font-size: 12px;
}

.chart__tooltip {
  position: absolute;
  z-index: 3;
  min-width: 150px;
  padding: 8px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
}

.tooltip__time {
  margin-bottom: 4px;
  color: var(--text-muted);
}

.tooltip__row {
  display: grid;
  grid-template-columns: 12px auto 1fr;
  align-items: center;
  gap: 6px;
}

.tooltip__key {
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

.tooltip__value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

/* Tables */

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--grid-line);
  text-align: left;
  vertical-align: middle;
}

.data-table thead th {
  color: var(--text-muted);
  font-weight: 500;
}

.data-table tfoot th,
.data-table tfoot td {
  border-bottom: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.data-table .num {
  padding-right: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table .num:not(:last-child) {
  padding-right: 16px;
}

.data-table .muted {
  color: var(--text-muted);
}

.bar-table__bar {
  width: 60%;
}

.bar {
  display: block;
  height: 10px;
  background: var(--track);
  border-radius: 0 4px 4px 0;
}

.bar__fill {
  display: block;
  height: 100%;
  min-width: 0;
  background: var(--chart-single);
  border-radius: 0 4px 4px 0;
}

.swatch-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

/* Storage */

.disk {
  margin: 4px 0 10px;
}

.disk__bar {
  display: flex;
  gap: 2px;
  height: 8px;
  overflow: hidden;
  background: var(--track);
  border-radius: 4px;
}

.disk__part {
  height: 100%;
  border-radius: 4px;
}

.disk__legend {
  margin-top: 6px;
}

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.total {
  flex: 1 1 150px;
  padding: 6px 10px;
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  font-size: 12px;
}

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

.total__value {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.total--unused {
  border-color: var(--status-warning);
}

.storage-table td:first-child {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.storage-table .zooms {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.storage-row--unused {
  background: var(--unused-row);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.tag--unused::before {
  content: '\26A0';
  color: var(--status-warning);
}

.sort {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sort::after {
  content: '';
  display: inline-block;
  width: 0.9em;
  color: var(--text-muted);
}

th[aria-sort='ascending'] .sort::after {
  content: ' \2191';
}

th[aria-sort='descending'] .sort::after {
  content: ' \2193';
}

/* Facts lists (renderer, settings) */

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 14px;
  margin: 0;
  font-size: 12px;
}

.facts dt {
  color: var(--text-muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.status::before {
  font-weight: 700;
}

.status--good::before {
  content: '\2713';
  color: var(--status-good);
}

.status--critical::before {
  content: '\2715';
  color: var(--status-critical);
}
