.admin-actions {
  display: flex;
  gap: 0.5rem;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.96);
}

.login-box {
  width: min(90%, 380px);
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.login-box h1 {
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.login-button {
  width: 100%;
  justify-content: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.stat-card .val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .lbl {
  font-size: 0.72rem;
  color: var(--muted);
}

.filter-card {
  padding-bottom: 0.25rem;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.section-heading h2 {
  font-size: 1rem;
}

.result-count,
.details-subtitle {
  color: var(--muted);
  font-size: 0.78rem;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 0.65rem;
}

.filters .field {
  margin-bottom: 0.75rem;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-wrap {
  max-height: 650px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  padding: 0.62rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
  color: var(--muted);
  cursor: default;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  user-select: none;
}

th[data-sort] {
  cursor: pointer;
}

th[data-sort]:hover,
th.sorted {
  color: var(--accent);
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: rgba(56, 189, 248, 0.07);
}

.empty-cell {
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.token-cell {
  max-width: 125px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  text-overflow: ellipsis;
}

.description-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.country-cell img {
  width: 20px;
  height: 14px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.details-button {
  padding: 0.35rem 0.65rem;
  font-size: 0.76rem;
}

.test-status {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}

.test-status-complete {
  background: rgba(52, 211, 153, 0.16);
  color: var(--success);
}

.test-status-partial {
  background: rgba(251, 191, 36, 0.16);
  color: #fbbf24;
}

.test-status-failed {
  background: rgba(248, 113, 113, 0.16);
  color: var(--danger);
}

.hidden,
[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.82);
}

.modal-card {
  width: min(1180px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-heading h2 {
  font-size: 1.15rem;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.details-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.detail-item {
  min-width: 0;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.detail-item .label {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.detail-item .value {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

.json-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.json-grid h3 {
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

pre {
  max-height: 430px;
  overflow: auto;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #020617;
  color: #cbd5e1;
  font: 0.75rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .json-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.65rem;
  }

  .admin-actions {
    width: 100%;
  }

  .admin-actions .btn {
    flex: 1;
    justify-content: center;
  }
}
