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

.controls.mempool-controls {
  display: grid;
  width: min(560px, 100%);
  grid-template-columns: minmax(120px, 160px) minmax(190px, 1fr);
  align-items: end;
  gap: 12px;
}

.controls.mempool-controls .field-wide {
  grid-column: 1 / -1;
}

.action-field {
  display: grid;
  gap: 6px;
}

.action-field > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(84px, 1fr));
  gap: 8px;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 148, 0.14);
  outline: none;
}

.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);
}

.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: 1040px;
  border-collapse: collapse;
}

th:nth-child(3),
td:nth-child(3) {
  width: 28%;
  max-width: 360px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 180px;
  max-width: 180px;
}

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

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:last-child,
td:last-child {
  text-align: right;
}

tbody tr:hover {
  background: #f8fbfc;
}

.summary-row {
  cursor: pointer;
}

.summary-row:focus-visible {
  outline: 3px solid rgba(20, 108, 148, 0.22);
  outline-offset: -3px;
}

.summary-row[aria-expanded="true"] {
  background: #f8fbfc;
}

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

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

.call-name {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 850;
}

.call-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.expand-indicator::before {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--accent);
  content: "";
  transition: transform 140ms ease;
}

.summary-row[aria-expanded="true"] .expand-indicator::before {
  transform: rotate(90deg);
}

.fingerprint,
.hex-preview,
.signer,
.raw-json-preview,
.json-block,
.encoded-block {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.fingerprint {
  margin-top: 4px;
  color: var(--muted);
}

.hex-preview {
  margin-top: 7px;
  color: var(--muted);
}

.signer {
  max-width: 170px;
  overflow: hidden;
  color: var(--text);
  font-weight: 750;
  text-overflow: ellipsis;
}

.signature-type {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.raw-json-preview {
  display: block;
  max-width: 340px;
  overflow: hidden;
  color: #334047;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expanded-row:hover {
  background: transparent;
}

.expanded-cell {
  padding: 0;
  text-align: left !important;
  white-space: normal;
}

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

.expanded-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.decoded-overview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.overview-item {
  min-width: 0;
  border: 1px solid #d6e1e5;
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

.overview-item span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.overview-item strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: #20303a;
  font-size: 0.84rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decode-error {
  margin-bottom: 12px;
  border: 1px solid #efc1bc;
  border-radius: 8px;
  background: #fff7f5;
  color: var(--warn);
  font-size: 0.84rem;
  font-weight: 750;
  padding: 9px 10px;
}

.tree-group {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.tree-group-label {
  color: #2c3a42;
  font-size: 0.82rem;
  font-weight: 850;
}

.tree-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.tree-list-nested {
  margin: 6px 0 0 15px;
  border-left: 1px solid #d6e1e5;
  padding-left: 10px;
}

.tree-item,
.tree-empty,
.tree-more {
  list-style: none;
}

.tree-row {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  border: 1px solid #d6e1e5;
  border-radius: 8px;
  background: #fff;
  padding: 7px 9px;
}

.tree-key {
  color: #172026;
  font-weight: 850;
}

.tree-type {
  border-radius: 999px;
  background: #eef3f6;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 6px;
}

.tree-value {
  min-width: 120px;
  color: #334047;
  overflow-wrap: anywhere;
}

.tree-empty,
.tree-more {
  color: var(--muted);
  font-size: 0.84rem;
  padding: 4px 0;
}

.json-block,
.encoded-block {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border: 1px solid #d6e1e5;
  border-radius: 8px;
  background: #fff;
  color: #20303a;
  line-height: 1.5;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-list {
  display: flex;
  max-width: 620px;
  flex-wrap: wrap;
  gap: 6px;
  white-space: normal;
}

.detail-chip,
.detail-muted {
  display: inline-flex;
  max-width: 100%;
  align-items: baseline;
  gap: 5px;
  border: 1px solid #d6e1e5;
  border-radius: 999px;
  background: #f8fbfc;
  color: #334047;
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  padding: 4px 8px;
  white-space: normal;
}

.detail-chip strong {
  color: #1d2a31;
  font-weight: 850;
}

.detail-chip-error {
  border-color: #efc1bc;
  background: #fff7f5;
  color: var(--warn);
}

.detail-muted {
  color: var(--muted);
}

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

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

  .controls.mempool-controls {
    width: 100%;
  }

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

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

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

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

  .controls.mempool-controls .field-wide {
    grid-column: auto;
  }

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

  .decoded-overview {
    grid-template-columns: 1fr;
  }
}
