:root {
  --bg: #030303;
  --surface: #121212;
  --surface-soft: #191919;
  --surface-deep: #0a0a0a;
  --text: #f5f1eb;
  --muted: #a3988d;
  --line: #34302c;
  --line-strong: #665243;
  --accent: #ff8c35;
  --accent-strong: #ffb263;
  --accent-warm: #ffc97d;
  --danger: #dc6b63;
  --glow: rgba(255, 134, 45, 0.34);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.54);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 125, 36, 0.14), transparent 24rem),
    radial-gradient(circle at 50% 42%, rgba(118, 54, 16, 0.12), transparent 38rem),
    linear-gradient(180deg, #050505 0%, var(--bg) 42%, #000000 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 18px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
  border-bottom: 0;
  background: linear-gradient(180deg, rgba(3, 3, 3, 0.94), rgba(3, 3, 3, 0.72));
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand strong {
  display: block;
  color: #ffffff;
  font-size: 16px;
  line-height: 1.3;
}

.brand span:last-child {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.brand-mark,
.metric-icon {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 185, 102, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(255, 181, 101, 0.16), transparent 52%),
    var(--surface-soft);
  color: var(--accent-warm);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.nav-tabs {
  display: inline-flex;
  justify-self: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(255, 185, 102, 0.18);
  border-radius: 10px;
  background: rgba(17, 17, 17, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.nav-link,
.drawer-link,
.text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-link {
  min-width: 96px;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  color: #cab8a4;
}

.nav-link:hover,
.nav-link.active,
.drawer-link:hover,
.drawer-link.active {
  background: linear-gradient(180deg, rgba(255, 179, 97, 0.24), rgba(91, 44, 17, 0.42));
  color: #fff2df;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.primary-button,
.wallet-button,
.page-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: linear-gradient(180deg, #232323 0%, #101010 100%);
  color: var(--text);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.icon-button {
  width: 40px;
  height: 40px;
}

.icon-button:hover,
.primary-button:hover,
.wallet-button:hover,
.page-button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 18px rgba(255, 139, 53, 0.16);
}

.wallet-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  max-width: 210px;
  padding: 0 12px;
  border-color: rgba(255, 255, 255, 0.22);
  font-weight: 700;
}

.drawer-wallet {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  margin-top: 14px;
  border: 1px solid #ffab59;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffb765 0%, var(--accent) 52%, #e46a16 100%);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 5px 18px var(--glow);
}

.wallet-button .icon-wallet {
  color: var(--accent-warm);
}

.wallet-button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.5);
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(50vw, 320px);
  min-width: 240px;
  height: 100vh;
  padding: 26px 18px 18px;
  border-left: 1px solid rgba(255, 185, 102, 0.14);
  border-radius: 18px 0 0 18px;
  background:
    radial-gradient(circle at 50% 100%, rgba(255, 126, 24, 0.2), transparent 17rem),
    linear-gradient(155deg, rgba(255, 184, 104, 0.08), transparent 42%),
    #121212;
  box-shadow: -24px 0 42px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.mobile-drawer.open {
  transform: translateX(0);
}

.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer-link {
  display: block;
  width: 100%;
  height: 46px;
  margin-bottom: 8px;
  border-radius: 10px;
  color: #cab8a4;
  text-align: left;
  padding: 0 14px;
}

.layout {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 56px;
}

.view {
  max-width: 980px;
  margin: 0 auto;
}

#bindingsView {
  max-width: 1080px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  min-height: 170px;
  margin-bottom: 20px;
  padding: 28px clamp(20px, 4vw, 42px);
  border: 1px solid rgba(255, 185, 102, 0.14);
  border-radius: 20px;
  background:
    radial-gradient(circle at 78% 18%, rgba(255, 157, 68, 0.22), transparent 12rem),
    radial-gradient(circle at 82% 78%, rgba(255, 126, 24, 0.24), transparent 13rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
    #080808;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 22px 60px rgba(0, 0, 0, 0.48);
}

.page-heading h1 {
  margin: 0;
  color: #fff4e5;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.15;
  letter-spacing: 0;
}

.page-note,
.panel-heading span,
.eyebrow {
  color: var(--muted);
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
}

.text-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 185, 102, 0.24);
  border-radius: 10px;
  color: var(--accent-warm);
  background: rgba(20, 20, 20, 0.78);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.metric-card,
.panel,
.action-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 185, 102, 0.16);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 110%, rgba(255, 121, 18, 0.38), transparent 45%),
    linear-gradient(155deg, rgba(255, 184, 104, 0.08), transparent 38%),
    linear-gradient(180deg, #161616 0%, #090909 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 44px rgba(0, 0, 0, 0.48);
}

.metric-card {
  min-height: 148px;
  padding: 22px;
}

.wide-card {
  grid-column: span 2;
}

.metric-icon {
  margin-bottom: 14px;
}

.metric-card strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: #fff7ef;
  font-size: 30px;
  line-height: 1.2;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.action-panel {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 2px 14px;
  align-items: center;
  min-height: 132px;
  padding: 22px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.action-panel:hover {
  border-color: var(--accent);
}

.action-panel .metric-icon {
  grid-row: span 2;
  margin: 0;
}

.action-panel strong {
  color: #fff4e5;
  font-size: 20px;
}

.action-panel span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 0;
}

.panel-heading h2 {
  margin: 0;
  color: #fff4e5;
  font-size: 18px;
  line-height: 1.2;
}

.chart-box {
  height: 340px;
  padding: 12px 22px 22px;
}

.table-panel {
  margin-top: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  padding: 14px 22px 18px;
}

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

th,
td {
  height: 52px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #d7c0a5;
  font-weight: 600;
}

tbody tr:hover td {
  background: rgba(255, 149, 59, 0.06);
}

td.mono,
.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 22px 22px;
}

.page-button {
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
}

.page-button.wide {
  min-width: 68px;
}

.page-button.active {
  border-color: #ffb567;
  background: linear-gradient(180deg, #ffb765 0%, var(--accent) 52%, #e46a16 100%);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 5px 18px var(--glow);
}

.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.pagination-gap {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  padding: 22px;
}

.search-form input {
  width: 100%;
  height: 48px;
  min-width: 0;
  border: 1px solid #3c332b;
  border-radius: 12px;
  padding: 0 12px;
  background: #111111;
  color: var(--text);
  box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.32);
}

.search-form input:focus {
  border-color: var(--accent);
  outline: 1px solid rgba(255, 178, 99, 0.26);
}

.search-form input::placeholder {
  color: #756b62;
}

.primary-button {
  width: 48px;
  height: 48px;
  border-color: #ffb567;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffb765 0%, var(--accent) 52%, #e46a16 100%);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 5px 18px var(--glow);
}

.hierarchy-search-panel {
  margin-bottom: 16px;
}

.hierarchy-summary {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 16px;
}

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

.level-list {
  display: grid;
  gap: 10px;
  padding: 22px;
}

.level-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 185, 102, 0.13);
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(255, 148, 54, 0.08), transparent 45%),
    rgba(255, 255, 255, 0.025);
}

.level-item span,
.level-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.copy-value {
  max-width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-warm);
  cursor: copy;
  text-align: left;
}

.copy-value:hover,
.copy-value:focus-visible {
  color: var(--accent-strong);
  text-decoration: underline;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 173, 80, 0.16), transparent 54%),
    #151515;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.icon-chain::before,
.icon-refresh::before,
.icon-wallet::before,
.icon-users::before,
.icon-network::before,
.icon-block::before,
.icon-clock::before,
.icon-search::before,
.icon-menu::before,
.icon-close::before,
.icon-chart::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.icon-chain::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 7h8v2H8V7Zm-3 5 3-3h8l3 3-3 3H8l-3-3Zm3 3v2h8v-2h2v3a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-3h2Z'/%3E%3C/svg%3E"); }
.icon-refresh::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M17.7 6.3A8 8 0 1 0 20 12h-2a6 6 0 1 1-1.8-4.3L13 11h8V3l-3.3 3.3Z'/%3E%3C/svg%3E"); }
.icon-wallet::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6h15a2 2 0 0 1 2 2v2h-5a3 3 0 0 0 0 6h5v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2Zm12 6h6v2h-6a1 1 0 0 1 0-2ZM5 4h12v2H5V4Z'/%3E%3C/svg%3E"); }
.icon-users::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 11a4 4 0 1 1 0-8 4 4 0 0 1 0 8Zm8 1a3 3 0 1 1 0-6 3 3 0 0 1 0 6ZM2 20a6 6 0 0 1 12 0H2Zm12.5 0a7.5 7.5 0 0 0-2.2-5.3A5 5 0 0 1 22 17v3h-7.5Z'/%3E%3C/svg%3E"); }
.icon-network::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 3h2v5h4v6h4v7h-7v-7h2v-4H8v4h2v7H3v-7h4V8h4V3Zm-6 13v3h3v-3H5Zm11 0v3h3v-3h-3Z'/%3E%3C/svg%3E"); }
.icon-block::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m12 2 9 5v10l-9 5-9-5V7l9-5Zm0 2.3L5.3 8 12 11.7 18.7 8 12 4.3ZM5 9.7v6.1l6 3.4v-6.1L5 9.7Zm8 9.5 6-3.4V9.7l-6 3.4v6.1Z'/%3E%3C/svg%3E"); }
.icon-clock::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 5v4.6l3.2 3.2-1.4 1.4-3.8-3.8V7h2Z'/%3E%3C/svg%3E"); }
.icon-search::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 3a7 7 0 1 1-4.5 12.4l-3 3 1.4 1.4 3-3A7 7 0 0 1 10 3Zm0 2a5 5 0 1 0 0 10 5 5 0 0 0 0-10Z'/%3E%3C/svg%3E"); }
.icon-menu::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6h16v2H4V6Zm0 5h16v2H4v-2Zm0 5h16v2H4v-2Z'/%3E%3C/svg%3E"); }
.icon-close::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6.4 5 5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19 5 17.6l5.6-5.6L5 6.4 6.4 5Z'/%3E%3C/svg%3E"); }
.icon-chart::before { mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 19h16v2H2V3h2v16Zm3-2V9h3v8H7Zm5 0V5h3v12h-3Zm5 0v-6h3v6h-3Z'/%3E%3C/svg%3E"); }

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

  .nav-tabs {
    display: none;
  }

  .menu-toggle {
    display: inline-block;
  }

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

  .wide-card {
    grid-column: span 2;
  }

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

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    gap: 12px;
  }

  .toolbar {
    justify-content: flex-end;
  }

  .wallet-button {
    display: none;
  }

  .mobile-drawer {
    width: 50vw;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .metric-grid-3,
  .hierarchy-summary,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .wide-card {
    grid-column: span 1;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 185, 102, 0.14);
    border-radius: 14px;
    background:
      radial-gradient(circle at 80% 120%, rgba(255, 126, 24, 0.18), transparent 10rem),
      rgba(255, 255, 255, 0.025);
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 12px;
    height: auto;
    min-height: 32px;
    border-bottom: 0;
    padding: 6px 0;
    word-break: break-word;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
  }

  .level-item {
    grid-template-columns: 1fr;
  }
}
