/* Full-width dashboard layout, keeping every data block inside the viewport. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 760px) {
  .monitoring-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-table, .batch-table tbody, .batch-table tr { display: block; }
  .batch-table thead { display: none; }
  .batch-table tr { padding: .65rem 0; border-bottom: 1px solid #ffffff12; }
  .batch-table td { display: grid; grid-template-columns: minmax(7rem,34%) minmax(0,1fr); gap: .75rem; padding: .42rem 0; border: 0; }
  .batch-table td::before { color: #8fa0b4; font-size: .72rem; }
  .batch-table td:nth-child(1)::before { content: 'Batch / sequence'; }
  .batch-table td:nth-child(2)::before { content: 'Status'; }
  .batch-table td:nth-child(3)::before { content: 'Attempts'; }
  .batch-table td:nth-child(4)::before { content: 'Events'; }
  .batch-table td:nth-child(5)::before { content: 'Создан'; }
  .batch-table td:nth-child(6)::before { content: 'Следующая попытка'; }
  .batch-table td:nth-child(7)::before { content: 'HTTP / error'; }
  .batch-table td:nth-child(8)::before { content: 'Действие'; }
}

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

header {
  min-width: 0;
  padding-inline: clamp(1rem, 3vw, 3rem);
  flex-wrap: wrap;
  gap: .75rem;
}

/* Keep the wallet list bounded so the rest of the dashboard remains reachable. */
.table-wrap.tron-wallets-scroll {
  max-height: 34rem;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #58d5b566 #ffffff08;
  scrollbar-width: thin;
}

.table-wrap.api-users-scroll {
  max-height: 25rem;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #58d5b566 #ffffff08;
  scrollbar-width: thin;
}

.api-users-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111a26;
}

.tron-wallets-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.15rem;
}

.tron-wallets-search {
  display: grid;
  gap: .35rem;
  width: min(100%, 28rem);
  color: #8fa0b4;
  font-size: .72rem;
  letter-spacing: .03em;
}

.tron-wallets-search input {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: .65rem .8rem;
  border-radius: 8px;
  font-size: .82rem;
}

#tron-filter-count {
  padding-bottom: .65rem;
  font-size: .72rem;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .tron-wallets-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: .55rem;
  }

  .tron-wallets-search {
    width: 100%;
  }

  #tron-filter-count {
    padding-bottom: 0;
  }
}

nav {
  min-width: 0;
  flex-wrap: wrap;
}

main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(2.5rem, 5vw, 5rem) clamp(1rem, 3vw, 3rem) 4rem;
}

.panel,
.table-wrap {
  min-width: 0;
}

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

.api-users-panel table,
.tron-panel table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.api-users-panel th,
.api-users-panel td,
.tron-panel th,
.tron-panel td {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tron-panel th {
  white-space: normal;
}

.address-cell {
  white-space: normal;
}

.address-cell code {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  word-break: normal;
}

.tron-panel th:nth-child(3),
.tron-panel td:nth-child(3),
.tron-panel th:nth-child(4),
.tron-panel td:nth-child(4) {
  display: none !important;
}

.tron-panel th:first-child,
.tron-panel td:first-child {
  width: 2rem;
}

.tron-panel th:first-child {
  font-size: 0;
}

.tron-panel td.address-cell {
  display: flex !important;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}

.tron-panel td.address-cell::before {
  display: none;
}

.tron-panel td.address-cell code {
  flex: 1;
  min-width: 0;
  margin-right: 0;
}

.tron-wallets-scroll {
  max-height: 34rem;
}

.copy-address {
  white-space: nowrap;
}

@media (max-width: 760px) {
  .section-heading {
    align-items: flex-start;
  }

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

  .api-users-panel table,
  .tron-panel table {
    display: block;
  }

  .api-users-panel thead,
  .tron-panel thead {
    display: none;
  }

  .api-users-panel tbody,
  .tron-panel tbody {
    display: block;
  }

  .api-users-panel tr,
  .tron-panel tr {
    display: block;
    padding: .65rem 0;
    border-bottom: 1px solid #ffffff12;
  }

  .api-users-panel td,
  .tron-panel td {
    display: grid;
    grid-template-columns: minmax(7rem, 34%) minmax(0, 1fr);
    gap: .75rem;
    width: 100% !important;
    padding: .42rem 0;
    border: 0;
  }

  .api-users-panel td::before,
  .tron-panel td::before {
    color: #8fa0b4;
    font-size: .72rem;
    line-height: 1.35;
  }

  .api-users-panel td:nth-child(1)::before { content: 'Пользователь'; }
  .api-users-panel td:nth-child(2)::before { content: 'JWT'; }
  .api-users-panel td:nth-child(3)::before { content: 'Активность'; }
  .tron-panel td:nth-child(1)::before { content: 'Состояние'; }
  .tron-panel td:nth-child(2)::before { content: 'Address'; }
  .tron-panel td:nth-child(3)::before { content: 'TRX'; }
  .tron-panel td:nth-child(4)::before { content: 'USDT'; }
  .tron-panel td:nth-child(5)::before { content: 'Cursor block'; }
  .tron-panel td:nth-child(6)::before { content: 'Успешный scan'; }
  .tron-panel td:nth-child(7)::before { content: 'Scan error'; }
  .tron-panel td:nth-child(8)::before { content: 'Pending'; }
  .tron-panel td:nth-child(9)::before { content: 'Webhook доставлен'; }
  .tron-panel td:nth-child(10)::before { content: 'Последняя транзакция'; }
  .tron-panel td:nth-child(11)::before { content: 'Постановка'; }
  .tron-panel td:nth-child(12)::before { content: 'API user'; }
}

@media (max-width: 480px) {
  header {
    height: auto;
    padding-block: 1rem;
  }

  nav {
    width: 100%;
    justify-content: space-between;
    gap: .5rem;
    font-size: .8rem;
  }

  main {
    padding-inline: .75rem;
  }

  .panel {
    padding: 1rem;
    border-radius: 14px;
  }

  .dashboard-controls,
  .dashboard-controls button {
    width: 100%;
  }

  .api-users-panel td,
  .tron-panel td {
    grid-template-columns: minmax(6rem, 38%) minmax(0, 1fr);
    gap: .5rem;
  }

  form input {
    min-width: 0;
    width: 100%;
  }

}
