.trace-shell {
  width: min(1560px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 38px;
}

.trace-topbar,
.panel-heading,
.trace-actions,
.identity-links {
  display: flex;
  gap: 14px;
}

.trace-topbar {
  align-items: flex-start;
  justify-content: space-between;
}

.trace-actions {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.sponsor-identity,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 23, 39, 0.92);
  box-shadow: var(--shadow);
}

.sponsor-identity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 16px;
  padding: 16px;
}

.identity-main {
  min-width: 0;
}

.identity-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.identity-list div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
}

.wrap,
.cell-main,
.cell-sub,
td,
th {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.identity-links {
  align-items: flex-end;
  flex-direction: column;
  white-space: nowrap;
}

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

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

.metric-card .label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card .value {
  margin-top: 8px;
  font-size: 1.28rem;
  font-weight: 850;
  line-height: 1.08;
}

.metric-card .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.35;
}

.trace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.7fr);
  gap: 12px;
}

.panel {
  min-width: 0;
  margin-top: 12px;
  padding: 14px;
}

.panel-heading {
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
}

.subtle {
  color: var(--muted);
  font-size: 0.78rem;
}

.note-copy {
  display: grid;
  gap: 12px;
  color: var(--soft);
  font-size: 0.88rem;
  line-height: 1.5;
}

.snapshot-history {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.snapshot-history h3 {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.snapshot-history-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--soft);
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.035);
}

.snapshot-history-time {
  color: var(--text);
  font-weight: 780;
}

.funding-panel {
  border-color: rgba(82, 224, 164, 0.35);
  background:
    linear-gradient(135deg, rgba(82, 224, 164, 0.08), rgba(13, 23, 39, 0.94) 34%),
    rgba(13, 23, 39, 0.94);
}

.funding-proof-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(420px, 1.12fr);
  gap: 14px;
  align-items: stretch;
}

.funding-proof,
.funding-tx-proof,
.funding-flow-lane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.funding-proof {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.funding-proof h3 {
  font-size: 0.94rem;
  line-height: 1.35;
}

.funding-proof-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.funding-stats,
.funding-mini-stats {
  display: grid;
  gap: 9px;
  margin: 0;
}

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

.funding-stats div,
.funding-mini-stats div {
  min-width: 0;
}

.funding-stats dd,
.funding-mini-stats dd {
  margin-top: 4px;
  color: var(--text);
  font-weight: 780;
  overflow-wrap: anywhere;
}

.funding-tx-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.funding-tx-proof {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.funding-tx-proof-heading,
.funding-register-tools,
.counterparty-main {
  display: flex;
  gap: 10px;
}

.funding-tx-proof-heading {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.funding-flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.funding-flow-lane {
  padding: 12px;
}

.funding-flow-lane h3 {
  margin-bottom: 10px;
}

.counterparty-list {
  display: grid;
  gap: 8px;
}

.funding-total,
.empty-note {
  color: var(--soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.counterparty-row {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px;
  border-top: 1px solid var(--line);
}

.counterparty-main {
  align-items: baseline;
  justify-content: space-between;
}

.counterparty-main > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.counterparty-main span {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 780;
  text-align: right;
}

.funding-register-heading {
  margin-top: 14px;
  padding-top: 8px;
}

.funding-register-heading h3 {
  font-size: 1rem;
}

.funding-register-tools {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.funding-table-wrap {
  max-height: 620px;
}

.upstream-panel {
  border-color: rgba(73, 209, 255, 0.34);
  background:
    linear-gradient(135deg, rgba(73, 209, 255, 0.07), rgba(13, 23, 39, 0.95) 36%),
    rgba(13, 23, 39, 0.94);
}

.upstream-summary-grid,
.post-summary-grid,
.upstream-wallet-grid,
.upstream-grid {
  display: grid;
  gap: 12px;
}

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

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

.upstream-summary-grid .metric-card,
.post-summary-grid .metric-card {
  min-height: 112px;
  box-shadow: none;
}

.upstream-wallet-grid,
.upstream-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.section-break {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.post-date-section .panel-heading {
  padding-bottom: 10px;
}

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

.upstream-wallet-card,
.upstream-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.upstream-wallet-card.emphasis {
  border-color: rgba(255, 191, 91, 0.48);
  background: rgba(255, 191, 91, 0.08);
}

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

.wallet-card-heading > * {
  min-width: 0;
}

.wallet-card-heading a {
  white-space: nowrap;
}

.upstream-wallet-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.upstream-wallet-stats div {
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.upstream-wallet-stats dd {
  margin-top: 5px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 780;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.wallet-address {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.72rem;
}

.upstream-box h3 {
  margin-bottom: 10px;
  font-size: 0.96rem;
}

.no-handle-box {
  border-color: rgba(255, 191, 91, 0.38);
}

.upstream-table-wrap {
  max-height: 620px;
}

.upstream-handle-wrap {
  max-height: 560px;
}

#upstream-handle-table-shell {
  min-width: 1220px;
}

.flow-board {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 0.85fr) minmax(240px, 1fr);
  gap: 12px;
  min-height: 340px;
}

.flow-lane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 12px;
}

.flow-lane h3 {
  margin-bottom: 10px;
}

.flow-node {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
}

.flow-node > * {
  min-width: 0;
}

.flow-node.primary {
  border-color: rgba(73, 209, 255, 0.55);
  background: rgba(73, 209, 255, 0.11);
}

.flow-node.warning {
  border-color: rgba(255, 191, 91, 0.48);
  background: rgba(255, 191, 91, 0.1);
}

.flow-node strong {
  font-size: 0.86rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.flow-node span {
  color: var(--muted);
  font-size: 0.75rem;
}

.flow-node .mono {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.trace-filter {
  width: min(420px, 100%);
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 12px;
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap.tall {
  max-height: 680px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.78rem;
}

#handle-table {
  min-width: 980px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111d30;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

td {
  color: var(--soft);
}

.cell-main {
  display: block;
  color: var(--text);
  font-weight: 780;
}

.cell-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.69rem;
}

.class-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.72rem;
  font-weight: 800;
}

.class-pill.drain {
  border-color: rgba(255, 107, 125, 0.45);
  background: rgba(255, 107, 125, 0.1);
  color: #ffd4da;
}

.class-pill.funding {
  border-color: rgba(82, 224, 164, 0.42);
  background: rgba(82, 224, 164, 0.1);
  color: #bdf7dc;
}

.class-pill.incoming {
  border-color: rgba(73, 209, 255, 0.42);
  background: rgba(73, 209, 255, 0.1);
  color: #c2f0ff;
}

.class-pill.outgoing {
  border-color: rgba(255, 191, 91, 0.48);
  background: rgba(255, 191, 91, 0.1);
  color: #ffe2b5;
}

.handle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.handle-chip {
  border: 1px solid rgba(73, 209, 255, 0.34);
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(73, 209, 255, 0.08);
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trace-grid,
  .flow-board,
  .funding-proof-grid,
  .funding-flow-grid,
  .upstream-summary-grid,
  .post-summary-grid,
  .upstream-wallet-grid,
  .upstream-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .trace-shell {
    width: min(100vw - 16px, 680px);
    padding-top: 12px;
  }

  .trace-topbar,
  .panel-heading,
  .sponsor-identity {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .trace-actions,
  .identity-links {
    align-items: flex-start;
    justify-content: flex-start;
  }

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

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

  .metric-card {
    min-height: 76px;
  }

  .funding-stats {
    grid-template-columns: 1fr;
  }

  .wallet-card-heading {
    flex-direction: column;
  }

  .wallet-card-heading a {
    white-space: normal;
  }

  .upstream-wallet-stats {
    grid-template-columns: 1fr;
  }

  .funding-register-tools {
    align-items: stretch;
    justify-content: flex-start;
  }
}
