.stats-topbar {
  margin-bottom: 8px;
}

.stats-scope {
  margin-bottom: 14px;
  font-size: 12px;
}

.stats-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-controls label {
  min-width: 180px;
}

.stats-workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.stats-view-tabs {
  display: inline-grid;
  width: fit-content;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(8, 21, 16, 0.92);
}

.stats-view-tabs button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 7px 14px;
  color: #82988d;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.stats-view-tabs button.active {
  color: #06140e;
  background: #5ce8a3;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stats-summary article {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 17px 18px;
  background: linear-gradient(145deg, rgba(13, 31, 23, 0.98), rgba(8, 21, 16, 0.95));
}

.stats-summary span,
.stats-summary strong {
  display: block;
}

.stats-summary span {
  color: #82988d;
  font-size: 12px;
}

.stats-summary strong {
  margin-top: 7px;
  color: #e9f7ef;
  font-size: clamp(22px, 2.4vw, 30px);
}

.stats-table-panel {
  min-height: 0;
  margin-top: 0;
  min-width: 0;
}

.stats-failures-panel {
  min-width: 0;
}

.failures-table {
  min-width: 1180px;
}

.stats-table-panel .table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.stats-table {
  min-width: 900px;
}

.stats-table thead {
  position: sticky;
  z-index: 1;
  top: 0;
  background: #0a1b14;
}

.stats-table td strong,
.stats-table td small {
  display: block;
}

.stats-table td small {
  margin-top: 4px;
}

.success-value {
  color: #72eeb0;
}

.failure-value {
  color: #ff9999;
}

.rate-cell {
  display: grid;
  min-width: 112px;
  gap: 7px;
}

.rate-cell > span {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.rate-cell i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #51e59c;
}

.rate-good { color: #72eeb0; }
.rate-medium { color: #ffd28a; }
.rate-low { color: #ff9999; }
.rate-empty { color: #82988d; }

.stats-status {
  display: inline-block;
  white-space: nowrap;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 800;
}

.stats-status.healthy {
  color: #72eeb0;
  background: rgba(81, 229, 156, 0.12);
}

.stats-status.busy {
  color: #9fcbff;
  background: rgba(76, 155, 255, 0.12);
}

.stats-status.warning {
  color: #ffd28a;
  background: rgba(255, 166, 34, 0.14);
}

.pool-stats-message {
  min-height: 22px;
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (min-width: 1101px) {
  body.pool-stats-page .admin-content {
    display: grid;
    height: calc(100vh - 40px);
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  body.pool-stats-page .stats-workspace {
    grid-template-rows: auto auto minmax(280px, 1fr) minmax(240px, 0.8fr) auto;
    min-height: 0;
  }

  body.pool-stats-page .stats-table-panel {
    display: flex;
    overflow: hidden;
    flex-direction: column;
  }

  body.pool-stats-page .stats-table-panel .table-wrap {
    min-height: 0;
    flex: 1;
    overflow: auto;
  }

  body.pool-stats-page .stats-failures-panel {
    display: flex;
    overflow: hidden;
    flex-direction: column;
  }

  body.pool-stats-page .stats-failures-panel .table-wrap {
    min-height: 0;
    flex: 1;
    overflow: auto;
  }
}

@media (max-width: 1100px) {
  .stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .stats-topbar,
  .stats-controls {
    align-items: stretch;
  }

  .stats-controls {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .stats-summary {
    grid-template-columns: 1fr;
  }
}
