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

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #172033;
  --muted: #637083;
  --line: #dce2ea;
  --line-strong: #c8d1dd;
  --brand: #1769aa;
  --brand-2: #0f4c81;
  --green: #16835f;
  --amber: #a16207;
  --red: #b42318;
  --violet: #6d4aff;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --panel: #171b22;
    --panel-2: #1e242d;
    --text: #f1f5f9;
    --muted: #9aa6b5;
    --line: #2b333f;
    --line-strong: #3a4655;
    --brand: #6aa7d8;
    --brand-2: #8bbde4;
    --green: #55b990;
    --amber: #d49b38;
    --red: #f07368;
    --violet: #9d8cff;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  }
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover { color: var(--brand-2); text-decoration: underline; }

svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto minmax(150px, 220px);
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--panel) 93%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.chain-control {
  justify-self: end;
  width: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
}

.brand:hover { text-decoration: none; color: var(--text); }

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--text);
  color: var(--panel);
  font-weight: 800;
}

.brand strong,
.brand span span {
  display: block;
  min-width: 0;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

#chain-name {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chain-control label,
.lookup label,
.auth-dialog label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  margin: 0 0 4px;
}

select,
input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

select:focus,
input:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 28%, transparent);
  border-color: var(--brand);
}

.top-links {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.top-links a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.icon-button,
.button {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

.button {
  padding: 0 14px;
}

.button.secondary {
  background: var(--panel);
  color: var(--text);
}

.icon-button:hover,
.button:hover {
  border-color: var(--brand);
  filter: brightness(0.98);
}

.icon-button:disabled,
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.layout {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
}

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

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

.metric {
  min-height: 92px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  font-family: var(--mono);
  font-size: 26px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 620px) minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  padding: 14px;
}

.lookup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.lookup label {
  grid-column: 1 / -1;
}

.status-line {
  color: var(--muted);
  font-size: 13px;
  justify-self: end;
  overflow-wrap: anywhere;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr);
  gap: 16px;
  align-items: start;
}

.instances-panel,
.bftsm-panel {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  min-height: 72px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-head svg {
  width: 22px;
  height: 22px;
  color: var(--brand);
}

.table-wrap {
  overflow: auto;
}

.blocks-scroll,
.transactions-scroll {
  max-height: 520px;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--panel);
  font-size: 11px;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 2;
}

td {
  font-size: 13px;
}

tbody tr {
  background: var(--panel);
}

tbody tr:hover {
  background: color-mix(in srgb, var(--brand) 7%, var(--panel));
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.pagination-bar .button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.mono {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.hash-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-family: var(--mono);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.hash-button:hover { text-decoration: underline; color: var(--brand-2); }

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 8px;
  min-height: 24px;
  font-size: 12px;
  font-weight: 750;
}

.pill.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, var(--line)); }
.pill.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, var(--line)); }
.pill.err { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.pill.info { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 35%, var(--line)); }
.warn-text { color: var(--amber); }

.instances-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 16px;
}

.instance-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  display: grid;
  gap: 12px;
}

.instance-card header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.instance-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.instance-sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.instance-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bftsm-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.bftsm-card {
  align-content: start;
}

.bftsm-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.instance-error {
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--red) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--red) 7%, var(--panel));
  color: var(--red);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.stat {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.stat strong {
  font-family: var(--mono);
  font-size: 15px;
  overflow-wrap: anywhere;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

dialog::backdrop {
  background: rgba(5, 10, 20, 0.6);
  backdrop-filter: blur(3px);
}

.auth-dialog {
  width: min(460px, calc(100vw - 28px));
}

.auth-dialog form {
  padding: 18px;
  display: grid;
  gap: 10px;
}

.tx-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  overflow: hidden;
}

.tx-dialog[open] {
  display: flex;
  flex-direction: column;
}

.dialog-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.dialog-head h2 {
  margin: 2px 0 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.dialog-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dialog-kicker svg {
  width: 15px;
  height: 15px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

.form-error {
  color: var(--red);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tx-detail-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px 14px;
  margin-bottom: 16px;
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 750;
  font-size: 12px;
}

.detail-grid dd {
  margin: 0;
  min-width: 0;
  font-family: var(--mono);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.json-block {
  display: grid;
  gap: 8px;
}

.json-block-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.json-block-head > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.json-copy-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.json-copy-button svg {
  width: 15px;
  height: 15px;
}

.json-block pre {
  max-height: min(560px, calc(100vh - 280px));
  overflow: auto;
  white-space: pre;
}

pre {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-row td,
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 26px 12px;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .brand {
    grid-column: span 1;
  }

  .chain-control {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .top-links {
    display: none;
  }

  .summary-strip,
  .content-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .status-line {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .layout,
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    gap: 10px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .summary-strip {
    gap: 8px;
  }

  .metric {
    min-height: 78px;
    padding: 12px;
  }

  .metric strong {
    font-size: 20px;
  }

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

  .button {
    width: 100%;
  }

  .bftsm-list {
    grid-template-columns: 1fr;
  }

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

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