:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #17202a;
  --muted: #61717f;
  --line: #d8e0e6;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c2413a;
  --green: #23865b;
  --shadow: 0 16px 34px rgba(28, 40, 52, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

code {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #27313a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100vh;
  padding: 24px 18px;
  background: #132126;
  color: #f7fbfb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
}

.brand:hover {
  text-decoration: none;
}

.brand.compact {
  margin-bottom: 20px;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #9eb3ba;
  font-size: 12px;
  font-weight: 500;
}

.brand.compact small {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  padding: 10px 12px;
  border-radius: 8px;
  color: #dce9eb;
  font-weight: 650;
}

.nav-list a:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.sidebar-user {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-user span,
.sidebar-user small {
  display: block;
}

.sidebar-user small {
  margin-bottom: 10px;
  color: #9eb3ba;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #b9f2e9;
  cursor: pointer;
  font-weight: 700;
}

.main {
  width: 100%;
  max-width: 1280px;
  padding: 34px;
}

.guest-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #eef3f5;
}

.guest-wrap {
  width: min(460px, calc(100% - 32px));
}

.auth-card,
.panel,
.analysis-search {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 30px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.16;
}

.muted {
  color: var(--muted);
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 650;
}

.notice.success {
  border-color: rgba(35, 134, 91, 0.25);
  color: var(--green);
}

.notice.warning {
  border-color: rgba(183, 121, 31, 0.25);
  color: var(--amber);
}

.notice.error {
  border-color: rgba(194, 65, 58, 0.25);
  color: var(--red);
}

.page-header,
.token-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-header h1,
.token-header h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.12;
}

.page-header p,
.token-header p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
}

.analysis-search {
  margin-bottom: 22px;
  padding: 20px;
}

.analysis-search label,
.form-stack label span {
  display: block;
  margin-bottom: 8px;
  color: #44525e;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.full {
  width: 100%;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.align-start {
  align-items: start;
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.feature-list,
.source-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
  color: #33414d;
}

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

.history-list a {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.history-list small,
.data-table small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: #52616d;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 6px;
  padding: 2px 8px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 800;
}

.status.ok {
  color: var(--green);
}

.status.partial,
.status.unknown {
  color: var(--amber);
}

.status.invalid {
  color: var(--red);
}

.token-header {
  align-items: center;
}

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

.token-identity img,
.token-fallback {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.token-fallback {
  display: grid;
  place-items: center;
  background: #132126;
  color: #ffffff;
  font-weight: 900;
}

.dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 0 8px;
  border-radius: 50%;
  background: var(--line);
  vertical-align: middle;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.address-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px 12px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.address-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.metric,
.mini-metrics > div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metric span,
.mini-metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong,
.mini-metrics strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 23px;
  line-height: 1.15;
}

.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.risk-high strong {
  color: var(--red);
}

.risk-medium strong,
.risk-unknown strong {
  color: var(--amber);
}

.risk-low strong {
  color: var(--green);
}

.detail-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 750;
}

.detail-list dd {
  min-width: 0;
  margin: 0;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.risk-list {
  display: grid;
  gap: 10px;
}

.risk-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #ffffff;
}

.risk-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

.risk-item.high {
  border-left-color: var(--red);
}

.risk-item.medium {
  border-left-color: var(--amber);
}

.risk-item.unknown {
  border-left-color: var(--blue);
}

.source-errors {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.source-errors p {
  margin: 0;
  color: var(--red);
  overflow-wrap: anywhere;
}

.source-errors.neutral p {
  color: var(--muted);
}

.match-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.match-list span {
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: #44525e;
  font-size: 12px;
  font-weight: 800;
}

.bond-card {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid #cddae2;
  border-radius: 8px;
  background: #f9fbfc;
}

.bond-card-head,
.bond-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bond-card-head span,
.bond-scale,
.bond-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.bond-card-head strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.bond-meter {
  position: relative;
  height: 18px;
  overflow: hidden;
  border: 1px solid #bed0d9;
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent calc(10% - 1px),
      rgba(23, 32, 42, 0.14) calc(10% - 1px),
      rgba(23, 32, 42, 0.14) 10%
    ),
    #e7eef2;
  box-shadow: inset 0 1px 3px rgba(17, 31, 43, 0.14);
}

.bond-meter-fill {
  display: block;
  width: var(--bond-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  box-shadow: 0 0 18px rgba(13, 148, 136, 0.32);
  transition: width 360ms ease;
}

.bond-card.complete .bond-meter-fill {
  background: linear-gradient(90deg, var(--green), var(--teal));
}

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

.bond-stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.bond-stats strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
}

.detail-list.compact {
  gap: 6px 14px;
  margin: 10px 0 12px;
}

.debug-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.debug-box summary {
  cursor: pointer;
  color: #1f2d3a;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.debug-trace {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #101820;
  color: #d9f7ee;
  font-size: 12px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .main {
    padding: 22px 16px;
  }

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

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

  .address-line {
    grid-template-columns: 1fr;
  }

  .token-header,
  .page-header {
    display: grid;
  }

  .header-actions,
  .search-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .wide-table {
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 18px 14px;
  }

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

  .nav-list a {
    text-align: center;
  }

  .page-header h1,
  .token-header h1 {
    font-size: 26px;
  }

  .mini-metrics {
    grid-template-columns: 1fr;
  }

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