.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(280px, 440px) auto;
  align-items: end;
  gap: 12px;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.3rem, 2vw, 2rem);
  line-height: 1.1;
}

.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.filter-panel {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfe;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.filter-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.filter-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.match-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(48px, auto));
  gap: 2px;
  min-width: 110px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.match-toggle legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.match-toggle label {
  position: relative;
  cursor: pointer;
}

.match-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.match-toggle span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0 10px;
}

.match-toggle input:checked + span {
  background: var(--accent);
  color: #fff;
}

.clear-filter-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-strong);
  padding: 0 12px;
}

.clear-filter-button:hover:not(:disabled) {
  background: var(--panel-muted);
}

.clear-filter-button:disabled {
  cursor: default;
}

.label-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.label-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  cursor: pointer;
}

.label-filter input {
  width: 15px;
  min-height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.label-filter input:not(:checked) + .badge {
  opacity: 0.58;
}

.label-filter input:checked + .badge {
  box-shadow: 0 0 0 2px rgba(20, 108, 148, 0.16);
}

.search-field {
  width: min(420px, 100%);
}

.table-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
}

#rowCountText,
#statusText {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

#rowCountText {
  color: var(--text);
  font-weight: 800;
}

#statusText.error {
  color: var(--warn);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-muted);
  color: #2c3a42;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  user-select: none;
}

th.sort-active::after {
  display: inline-block;
  margin-left: 7px;
  content: "";
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  vertical-align: 0.12em;
}

th.sort-asc::after {
  border-bottom: 6px solid currentColor;
}

th.sort-desc::after {
  border-top: 6px solid currentColor;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: left;
}

tbody tr:hover {
  background: #f8fbfc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.netuid {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.subnet-name {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.number {
  font-variant-numeric: tabular-nums;
}

.badges {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 150px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fafb;
  color: #3a4a52;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 0 8px;
  white-space: nowrap;
}

.badges .badge {
  cursor: help;
}

.label-filter .badge {
  cursor: pointer;
}

.label-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(320px, calc(100vw - 24px));
  border: 1px solid rgba(23, 32, 38, 0.14);
  border-radius: 8px;
  background: #172026;
  box-shadow: 0 12px 32px rgba(23, 32, 38, 0.22);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0;
  padding: 9px 10px;
  pointer-events: none;
  transform: translateY(-2px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.label-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.badge-top {
  border-color: rgba(20, 108, 148, 0.22);
  background: rgba(20, 108, 148, 0.1);
  color: var(--accent-strong);
}

.badge-nice {
  border-color: rgba(45, 132, 91, 0.24);
  background: rgba(45, 132, 91, 0.11);
  color: #236949;
}

.badge-muted {
  border-color: rgba(150, 92, 18, 0.22);
  background: rgba(150, 92, 18, 0.1);
  color: var(--warn);
}

.badge-risk {
  border-color: rgba(173, 47, 47, 0.24);
  background: rgba(173, 47, 47, 0.11);
  color: #8c2727;
}

.badge-semi {
  border-color: rgba(83, 91, 182, 0.24);
  background: rgba(83, 91, 182, 0.11);
  color: #41488f;
}

.badge-immune {
  border-color: rgba(101, 114, 124, 0.24);
  background: rgba(101, 114, 124, 0.11);
  color: #4b5961;
}

.empty {
  padding: 30px 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .toolbar,
  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .table-meta,
  #rowCountText,
  #statusText {
    justify-items: start;
    text-align: left;
  }

  .filter-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
