:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #070b14;
  color: #eef3ff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 20% 0%, #182440 0, #070b14 38%); }
button, input, select { font: inherit; }
a { color: #8eb0ff; text-decoration: none; }
a:hover { color: #b8ccff; text-decoration: underline; }
.sort-button { padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-weight: inherit; letter-spacing: inherit; text-transform: inherit; }
.shell { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 10px 0 60px; }
.topbar { margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 12px; }
.page-link { margin-left: auto; padding: 9px 13px; border: 1px solid #2a3853; border-radius: 9px; font-size: 13px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(18px, 4vw, 36px); letter-spacing: -0.04em; white-space: nowrap; }
h2 { margin-top: 5px; font-size: 22px; }
.eyebrow { color: #7793c7; font-size: 11px; font-weight: 800; letter-spacing: 0.18em; }
.status-dot { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%; }
.status-dot--green { background: #38d996; box-shadow: 0 0 14px #38d996; }
.status-dot--red { background: #ff5c6c; box-shadow: 0 0 14px #ff5c6c; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 14px; }
.stats article { display: grid; gap: 8px; padding: 18px; border: 1px solid #202d45; border-radius: 14px; background: #0d1422cc; }
.stats span { color: #8190aa; font-size: 13px; }
.stats strong { font-size: 21px; }
.analysis-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; color: #9eacc2; font-size: 13px; }
.analysis-summary strong { color: #eef3ff; }
.analysis-feedback { color: #ff7b87; text-align: right; }
.panel { overflow: hidden; border: 1px solid #202d45; border-radius: 18px; background: #0b111ddd; box-shadow: 0 22px 70px #0005; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 20px; border-bottom: 1px solid #202d45; }
.filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.filters input, .filters select { min-width: 145px; padding: 10px 12px; border: 1px solid #2a3853; border-radius: 9px; outline: none; background: #0a101b; color: #eaf0ff; }
.filters input:focus, .filters select:focus { border-color: #638cff; }
.chain-combobox { position: relative; width: 180px; }
.chain-combobox input { width: 100%; min-width: 0; }
.chain-options { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; width: 100%; max-height: 260px; overflow-y: auto; border: 1px solid #2a3853; border-radius: 9px; background: #0a101b; box-shadow: 0 14px 30px #0008; }
.chain-option { display: block; width: 100%; padding: 9px 12px; border: 0; background: transparent; color: #eaf0ff; text-align: left; cursor: pointer; }
.chain-option:hover, .chain-option:focus { outline: none; background: #182642; }
.query-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border: 1px solid #638cff; border-radius: 9px; background: #315fda; color: #fff; cursor: pointer; }
.query-button:disabled { border-color: #2a3853; background: #202a3d; color: #7e8eaa; cursor: wait; }
.query-spinner { width: 13px; height: 13px; flex: 0 0 auto; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: query-spinner-rotate 0.7s linear infinite; }
@keyframes query-spinner-rotate { to { transform: rotate(360deg); } }
.analysis-panel-heading { display: block; padding: 10px; }
.analysis-controls { display: grid; width: 100%; grid-template-columns: repeat(60, minmax(0, 1fr)); align-items: end; }
.filter-row { display: grid; gap: 9px; }
.chain-filter-row, .time-filter-row, .select-filter-row, .analysis-action-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.analysis-controls .chain-filter-row { grid-column: span 12; }
.analysis-controls .time-filter-row { grid-column: span 15; }
.analysis-controls .preset-buttons { grid-column: span 11; }
.analysis-controls .select-filter-row { grid-column: span 12; }
.analysis-controls .analysis-action-row { grid-column: span 10; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.analysis-controls .chain-combobox { width: 100%; }
.analysis-controls .time-field input, .analysis-controls .select-filter-row select { width: 100%; min-width: 0; }
.time-field { display: grid; gap: 4px; color: #8190aa; font-size: 11px; }
.time-field input { min-width: 190px; }
.preset-buttons { display: flex; gap: 5px; }
.preset-buttons button { flex: 1; }
.preset-buttons button { padding: 4px; border: 1px solid #2a3853; border-radius: 9px; background: #0a101b; color: #bec9dc; cursor: pointer; }
.preset-buttons button:hover, .preset-button--active { border-color: #638cff !important; color: #fff !important; }
.nonce-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #bec9dc; font-size: 13px; }
.nonce-input { width: 120px; min-width: 0 !important; text-align: right; }
.query-button-wrap { display: flex; }
.analysis-controls .query-button { width: 100%; padding-right: 4px; padding-left: 4px; }

@media (min-width: 851px) {
  .analysis-controls .analysis-action-row .nonce-field { justify-content: flex-start; gap: 4px; font-size: 11px; }
  .analysis-controls .analysis-action-row .nonce-input { width: 45%; padding: 5px; }
  .analysis-controls .select-filter-row select { padding: 5px; }
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 16px; border-bottom: 1px solid #182338; text-align: left; font-size: 13px; }
th { color: #7e8eaa; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }
th:nth-child(1) { width: 18%; }
th:nth-child(2), th:nth-child(6) { width: 7%; }
tbody tr:hover { background: #111b2c; }
tbody td:first-child { color: #8eb0ff; }
.token-cell, .token-cell a { color: #eef3ff; }
.token-cell a:hover { color: #fff; }
.token-cell--check-fail, .token-cell--check-fail a { color: #f6bd73; }
.message-status { font-weight: 800; }
.message-status--delivered { color: #38d996; }
.message-status--inflight, .message-status--confirming { color: #ffca68; }
.message-status--failed, .message-status--blocked { color: #ff6a78; }
.empty-state { padding: 50px 20px; color: #7e8eaa; text-align: center; }

@media (max-width: 850px) {
  .shell { width: min(100% - 24px, 1500px); }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .stats { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
  .chain-combobox { width: 100%; }
  .analysis-controls { display: grid; grid-template-columns: minmax(0, 1fr); }
  .analysis-controls .chain-filter-row,
  .analysis-controls .time-filter-row,
  .analysis-controls .preset-buttons,
  .analysis-controls .select-filter-row,
  .analysis-controls .analysis-action-row { grid-column: 1; }
  .chain-filter-row, .time-filter-row, .select-filter-row, .analysis-action-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-controls .analysis-action-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .time-field input { min-width: 0; width: 100%; }
  .nonce-input { width: 110px; }
}

@media (max-width: 640px) {
  .shell { width: calc(100% - 12px); }
  .topbar { margin-bottom: 5px; }
  .table-wrap { overflow-x: visible; padding: 12px 0; }
  table, tbody { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 31.25%) minmax(0, calc(13.75% + 4px)) minmax(0, 32.5%) minmax(0, calc(22.5% - 4px));
    overflow: hidden;
    border: 1px solid #202d45;
    border-radius: 12px;
    background: #0d1422;
  }
  tbody tr:hover { background: #111b2c; }
  tbody td {
    display: grid;
    min-width: 0;
    gap: 5px;
    padding: 10px 8px;
    border-right: 1px solid #182338;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  tbody td:nth-child(4n) { border-right: 0; }
  tbody td:nth-child(n + 5) { border-bottom: 0; }
  tbody td:nth-child(1), tbody td:nth-child(5) { padding-right: 0; }
  tbody td:nth-child(2), tbody td:nth-child(6) { padding-right: 2px; padding-left: 2px; }
  tbody td:nth-child(3), tbody td:nth-child(7) { padding-right: 4px; padding-left: 4px; }
  tbody td:nth-child(4), tbody td:nth-child(8) { padding-right: 2px; padding-left: 2px; }
  tbody td::before {
    content: attr(data-label);
    color: #7e8eaa;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  tbody td a {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .empty-state { padding: 38px 8px; }
}
