:root {
  color-scheme: dark;
  --bg: #111312;
  --panel: rgba(26, 29, 26, 0.9);
  --panel-deep: rgba(6, 8, 10, 0.74);
  --ink: #f4efe4;
  --muted: #a8aa9c;
  --line: #3a4034;
  --outline: #0b1012;
  --surface: rgba(255, 255, 255, 0.08);
  --accent: #ff9a2f;
  --accent-2: #ffd28a;
  --focus: #ff9438;
  --table-head: rgba(8, 9, 8, 0.96);
  --table-head-ink: #f4efe4;
  --row-hover: rgba(255, 148, 56, 0.08);
  --pill-bg: rgba(255, 154, 47, 0.12);
  --pill-border: rgba(255, 154, 47, 0.38);
  --rarity-common-bg: rgba(216, 223, 209, 0.12);
  --rarity-common-ink: #d8dfd1;
  --rarity-common-border: rgba(216, 223, 209, 0.36);
  --rarity-uncommon-bg: rgba(158, 235, 191, 0.12);
  --rarity-uncommon-ink: #9eebbf;
  --rarity-uncommon-border: rgba(158, 235, 191, 0.38);
  --rarity-rare-bg: rgba(229, 176, 255, 0.12);
  --rarity-rare-ink: #e5b0ff;
  --rarity-rare-border: rgba(229, 176, 255, 0.45);
  --rarity-epic-bg: rgba(255, 210, 138, 0.12);
  --rarity-epic-ink: #ffd28a;
  --rarity-epic-border: rgba(255, 210, 138, 0.45);
  --rarity-legend-bg: rgba(255, 90, 214, 0.12);
  --rarity-legend-ink: #ff5ad6;
  --rarity-legend-border: rgba(255, 90, 214, 0.45);
  --chart-grid: rgba(255, 255, 255, 0.08);
  --chart-bar: #ff9a2f;
  --chart-bar-alt: #9eebbf;
  --chart-line: #ffd28a;
  --chart-line-alt: #e5b0ff;
  --danger: #ff6b6b;
  --shadow: 6px 6px 0 rgba(0, 0, 0, 0.58);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(240, 124, 25, 0.14), transparent 30rem),
    linear-gradient(180deg, #151714 0%, #111312 48%, #080908 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

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

.brand-logo {
  width: 76px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.5));
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: 0;
}

.program {
  display: grid;
  gap: 5px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
}

.top-link {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  text-decoration: none;
}

.top-link:hover {
  color: var(--accent);
}

code {
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metrics div,
.address-summary div,
.chart-card,
.address-section,
.rarity-section,
.token-section,
.token-card,
.dex-chart-wrap,
.controls,
.table-wrap {
  background: var(--panel);
  border: 2px solid var(--outline);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics div {
  min-height: 86px;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.metrics span,
.address-summary span,
label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metrics strong {
  font-size: 28px;
  line-height: 1;
}

.address-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.address-summary div {
  min-height: 118px;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.address-summary strong {
  font-size: 22px;
  line-height: 1;
}

.address-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.metric-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
}

.analytics-toolbar {
  min-height: 52px;
  margin-bottom: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel);
  border: 2px solid var(--outline);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.analytics-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.analytics-toolbar strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.1;
}

.range-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 56px);
  gap: 4px;
  padding: 4px;
  background: rgba(6, 8, 10, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.range-button {
  height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.range-button.active {
  background: var(--pill-bg);
  border-color: var(--pill-border);
  color: var(--accent-2);
}

.insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.distribution-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.holder-history-section,
.holder-history-section .chart-card,
.distribution-grid .rarity-section {
  min-width: 0;
  height: 100%;
}

.chart-card {
  min-height: 252px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(150px, 1fr) auto;
  gap: 12px;
}

.chart-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.chart-head span,
.chart-note,
.legend {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.chart-head h2 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chart-head strong {
  color: var(--accent-2);
  font-size: 18px;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.chart {
  position: relative;
  min-height: 150px;
  overflow: hidden;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 150px;
}

.chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-axis {
  stroke: rgba(244, 239, 228, 0.22);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.chart-bar {
  fill: var(--chart-bar);
  cursor: crosshair;
}

.chart-bar-alt {
  fill: var(--chart-bar-alt);
  cursor: crosshair;
}

.chart-line {
  fill: none;
  stroke: var(--chart-line);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-line-alt {
  fill: none;
  stroke: var(--chart-line-alt);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-point {
  fill: var(--chart-line);
  stroke: rgba(8, 9, 8, 0.96);
  stroke-width: 1.5;
}

.chart-point-alt {
  fill: var(--chart-line-alt);
  stroke: rgba(8, 9, 8, 0.96);
  stroke-width: 1.5;
}

.chart-hit-area {
  fill: transparent;
  cursor: crosshair;
}

.chart-tooltip-target:focus-visible {
  outline: none;
  filter: drop-shadow(0 0 5px rgba(255, 210, 138, 0.9));
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  max-width: min(300px, calc(100% - 16px));
  padding: 8px 10px;
  border: 1px solid var(--pill-border);
  border-radius: 6px;
  background: rgba(6, 8, 10, 0.94);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 90ms ease, transform 90ms ease;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.58);
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-area {
  fill: rgba(255, 210, 138, 0.1);
}

.chart-note {
  margin: 0;
  line-height: 1.35;
  text-transform: none;
}

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

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 18px;
  height: 3px;
  display: inline-block;
  border-radius: 999px;
}

.legend-prisoners {
  background: var(--chart-line);
}

.legend-wallets {
  background: var(--chart-line-alt);
}

.token-section {
  margin-bottom: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.rarity-section {
  margin-bottom: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.section-head,
.token-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.section-head span,
.token-card-head span,
.token-stats span,
.change-grid span,
.token-note,
.section-note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.section-head h2 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-note {
  max-width: 460px;
  margin: 0;
  line-height: 1.35;
  text-align: right;
  text-transform: none;
}

.rarity-breakdown {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(240px, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 260px;
  background: var(--panel-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.pie-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.pie-chart {
  width: min(100%, 220px);
  aspect-ratio: 1;
  display: block;
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, 0.34));
}

.pie-slice {
  stroke: rgba(8, 9, 8, 0.92);
  stroke-width: 2;
}

.rarity-fill-0 {
  fill: var(--rarity-common-ink);
}

.rarity-fill-1 {
  fill: var(--rarity-uncommon-ink);
}

.rarity-fill-2 {
  fill: var(--rarity-rare-ink);
}

.rarity-fill-3 {
  fill: var(--rarity-epic-ink);
}

.rarity-fill-4 {
  fill: var(--rarity-legend-ink);
}

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

.rarity-legend-row {
  min-height: 44px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) minmax(54px, auto) minmax(68px, auto);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.rarity-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.rarity-dot-0 {
  background: var(--rarity-common-ink);
}

.rarity-dot-1 {
  background: var(--rarity-uncommon-ink);
}

.rarity-dot-2 {
  background: var(--rarity-rare-ink);
}

.rarity-dot-3 {
  background: var(--rarity-epic-ink);
}

.rarity-dot-4 {
  background: var(--rarity-legend-ink);
}

.rarity-legend-row span:nth-child(2) {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.rarity-legend-row span:nth-child(3) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rarity-legend-row strong {
  color: var(--accent-2);
  font-size: 18px;
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.external-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  height: 34px;
  border: 1px solid var(--pill-border);
  border-radius: 6px;
  background: var(--pill-bg);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.external-link:hover {
  border-color: rgba(255, 210, 138, 0.7);
}

.token-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 12px;
}

.token-card {
  min-height: 150px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  background: var(--panel-deep);
}

.token-card-main {
  background:
    linear-gradient(135deg, rgba(255, 154, 47, 0.12), transparent 48%),
    var(--panel-deep);
}

.token-card-head strong {
  color: var(--accent-2);
  font-size: 30px;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.token-card-change .token-card-head {
  align-items: baseline;
  flex-wrap: wrap;
  row-gap: 6px;
}

.token-card-change .token-card-head strong {
  min-width: 0;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.05;
  white-space: normal;
  overflow-wrap: anywhere;
}

.token-note {
  margin: 0;
  line-height: 1.35;
  text-transform: none;
}

.token-card-change .token-note {
  margin-top: -4px;
}

.token-stats,
.change-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

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

.token-stats div,
.change-grid div {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.token-stats strong,
.change-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.token-card-change .change-grid strong {
  font-size: clamp(13px, 1.45vw, 16px);
  overflow-wrap: anywhere;
}

.change-down {
  color: var(--danger) !important;
}

.change-up {
  color: var(--chart-bar-alt) !important;
}

.dex-chart-wrap {
  height: clamp(420px, 56vw, 680px);
  overflow: hidden;
  background: var(--panel-deep);
}

.dex-chart-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--panel-deep);
}

.address-section {
  margin-bottom: 14px;
  padding: 14px;
}

.address-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.address-table {
  min-width: 980px;
}

.address-table th,
.address-table td {
  vertical-align: top;
}

.address-table td:first-child {
  width: 190px;
  color: var(--ink);
  font-weight: 900;
}

.address-table td:nth-child(2) {
  width: 420px;
}

.address-table code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  min-width: 86px;
  justify-content: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.confirmed {
  color: var(--rarity-uncommon-ink);
  background: var(--rarity-uncommon-bg);
  border-color: var(--rarity-uncommon-border);
}

.status-pill.candidate {
  color: var(--accent-2);
  background: var(--pill-bg);
  border-color: var(--pill-border);
}

.status-pill.inferred {
  color: var(--rarity-rare-ink);
  background: var(--rarity-rare-bg);
  border-color: var(--rarity-rare-border);
}

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

.unknown-grid div {
  min-height: 118px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.unknown-grid h3 {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.2;
  text-transform: uppercase;
}

.unknown-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 1fr) repeat(3, 120px);
  gap: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 7px;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--panel-deep);
  font: inherit;
  padding: 0 11px;
}

input:focus,
select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: rgba(255, 148, 56, 0.78);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: var(--table-head-ink);
  font-size: 11px;
  text-transform: uppercase;
  box-shadow: inset 0 -1px 0 var(--line);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

tbody tr:hover {
  background: var(--row-hover);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:nth-child(even):hover {
  background: var(--row-hover);
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--accent);
  font-weight: 700;
}

.owner-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--accent-2);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.rarity-0 {
  background: var(--rarity-common-bg);
  border-color: var(--rarity-common-border);
  color: var(--rarity-common-ink);
}

.rarity-1 {
  background: var(--rarity-uncommon-bg);
  border-color: var(--rarity-uncommon-border);
  color: var(--rarity-uncommon-ink);
}

.rarity-2 {
  background: var(--rarity-rare-bg);
  border-color: var(--rarity-rare-border);
  color: var(--rarity-rare-ink);
}

.rarity-3 {
  background: var(--rarity-epic-bg);
  border-color: var(--rarity-epic-border);
  color: var(--rarity-epic-ink);
}

.rarity-4 {
  background: var(--rarity-legend-bg);
  border-color: var(--rarity-legend-border);
  color: var(--rarity-legend-ink);
}

.refresh-button:focus-visible,
.range-button:focus-visible,
.external-link:focus-visible,
.sort-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.power {
  color: var(--accent-2);
  font-weight: 800;
}

.mono {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.empty {
  height: 180px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .brand-logo {
    width: 64px;
    height: 38px;
  }

  .analytics-toolbar {
    align-items: stretch;
    display: grid;
  }

  .range-toggle {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .program {
    justify-items: start;
    max-width: 100%;
  }

  .program code {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  h1 {
    font-size: 26px;
  }

  .metrics,
  .insights,
  .address-summary,
  .distribution-grid,
  .rarity-breakdown,
  .unknown-grid,
  .token-grid,
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .section-head {
    display: grid;
  }

  .section-note {
    max-width: none;
    text-align: left;
  }

  .token-card-main,
  .search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .metrics,
  .insights,
  .address-summary,
  .distribution-grid,
  .rarity-breakdown,
  .unknown-grid,
  .token-grid,
  .token-stats,
  .change-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .dex-chart-wrap {
    height: 460px;
  }
}
