.token-page-body { background: #f7f8fa; }
.token-page-shell { width: min(1460px, 100%); }
.token-page-topbar { grid-template-columns: 1fr auto auto; }

.desk-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.desk-nav a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}
.desk-nav a:hover { color: var(--text); }
.desk-nav a.active { color: var(--blue); background: var(--surface); box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.ranking-connection { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ranking-connection i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ranking-connection.live { color: var(--green); }
.ranking-connection.stale { color: var(--amber); }
.ranking-connection.offline { color: var(--red); }

.ranking-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 48px;
  padding: 38px 0 28px;
  border-bottom: 1px solid var(--line);
}
.ranking-intro h1 { margin-top: 5px; font-size: 34px; }
.ranking-intro p { max-width: 760px; margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.ranking-source { min-width: 220px; display: grid; gap: 3px; text-align: right; }
.ranking-source span { color: var(--muted); font-size: 11px; }
.ranking-source b { font-size: 13px; }
.ranking-source a { color: var(--blue); font-size: 11px; text-decoration: none; }

.ranking-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  overflow: hidden;
}
.ranking-summary > div { min-width: 0; display: grid; gap: 3px; padding: 14px 16px; border-right: 1px solid var(--line); }
.ranking-summary > div:last-child { border-right: 0; }
.ranking-summary span, .ranking-summary small { color: var(--muted); font-size: 11px; }
.ranking-summary strong { font-size: 20px; line-height: 1.25; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.ranking-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) repeat(4, minmax(130px, .65fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.ranking-toolbar label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.ranking-toolbar input, .ranking-toolbar select { width: 100%; height: 40px; }
.ranking-toolbar input {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  padding: 0 11px;
  outline: 0;
  color: var(--text);
}
.ranking-toolbar input:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }
.ranking-scope-note {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 11px;
}

.ranking-table-shell {
  overflow: auto;
  max-height: calc(100vh - 315px);
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.ranking-table { width: 100%; min-width: 850px; border-collapse: collapse; table-layout: fixed; }
.ranking-table thead { position: sticky; top: 0; z-index: 5; background: #f8fafc; }
.ranking-table th {
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: left;
}
.ranking-table th:nth-child(2) { width: 255px; }
.ranking-table th.score-col { width: 124px; }
.ranking-table th.rank-col { width: 44px; }
.ranking-table th.numeric { text-align: right; }
.token-ranking-row { border-bottom: 1px solid var(--line); }
.token-ranking-row:hover { background: #fbfcfe; }
.ranking-table td { height: 68px; padding: 10px 12px; vertical-align: middle; }
.rank-number { color: #98a2b3; font: 12px var(--mono); text-align: center; }
.token-rank-identity { min-width: 0; }
.token-rank-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.token-rank-title b { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.token-rank-title span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.token-rank-meta { display: flex; align-items: center; gap: 7px; margin-top: 5px; min-width: 0; }
.token-rank-meta code { overflow: hidden; color: #667085; font: 10px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.token-rank-meta a { flex: 0 0 auto; color: var(--blue); font-size: 10px; text-decoration: none; }
.rank-tag { flex: 0 0 auto; border-radius: 4px; background: #f2f4f7; padding: 2px 5px; color: #475467; font-size: 9px; text-transform: uppercase; }
.rank-tag.watched { color: #1d4ed8; background: var(--blue-soft); }
.metric-cell { color: #344054; font: 13px var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.metric-cell.missing { color: #98a2b3; }
.change-positive { color: var(--green); }
.change-negative { color: var(--red); }
.change-neutral { color: var(--muted); }
.ai-score-cell { text-align: right; }
.score-toggle {
  width: 112px;
  min-height: 40px;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 4px 7px;
  text-align: left;
}
.score-toggle:hover { border-color: #9ba4b0; }
.score-toggle strong { grid-row: 1 / 3; color: var(--blue); font-size: 19px; font-variant-numeric: tabular-nums; }
.score-toggle span { color: #344054; font-size: 10px; }
.score-toggle small { color: var(--muted); font-size: 9px; }
.score-toggle.risk strong { color: var(--red); }
.score-toggle.watch strong { color: var(--amber); }
.score-toggle.active strong, .score-toggle.strong strong { color: var(--green); }
.score-detail-row { display: none; border-bottom: 1px solid var(--line); background: #f8fafc; }
.score-detail-row.open { display: table-row; }
.score-detail-row td { height: auto; padding: 14px 64px; }
.score-detail-grid { display: grid; grid-template-columns: minmax(360px, 1.3fr) 1fr 1fr; gap: 24px; }
.score-breakdown { display: grid; grid-template-columns: repeat(5, minmax(70px, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--line); }
.score-part { display: grid; gap: 2px; padding: 8px; background: var(--surface); }
.score-part span { color: var(--muted); font-size: 9px; }
.score-part b { font: 12px var(--mono); }
.score-part.penalty { color: var(--red); }
.score-notes { display: grid; align-content: start; gap: 5px; }
.score-notes > b { font-size: 11px; }
.score-notes span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.score-notes.risks span { color: #7a4b00; }
.score-evidence-line { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 10px; }
.score-evidence-line b { color: #344054; }
.ranking-empty { min-height: 280px; display: grid; place-content: center; gap: 4px; color: var(--muted); text-align: center; }
.ranking-empty b { color: var(--text); font-size: 15px; }
.loading-row td { height: 280px; color: var(--muted); text-align: center; }
.ranking-load-more { margin-bottom: 18px; }
.score-method { margin: 18px 0 0; border-top: 1px solid var(--line); color: var(--muted); }
.score-method summary { padding: 14px 0; color: #344054; font-size: 12px; cursor: pointer; }
.score-method > div { max-width: 860px; padding-bottom: 14px; }
.score-method p { margin: 0 0 7px; font-size: 12px; line-height: 1.65; }

@media (max-width: 980px) {
  .ranking-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ranking-search { grid-column: span 2; }
  .ranking-table-shell { max-height: none; }
}

@media (max-width: 720px) {
  .token-page-shell { padding: 0 14px 36px; }
  .token-page-topbar { margin: 0 -14px; padding: 10px 14px; grid-template-columns: 1fr auto; }
  .token-page-topbar .ranking-connection { display: none; }
  .desk-nav a { padding: 0 8px; }
  .desk-nav a:first-child { display: none; }
  .ranking-intro { display: block; padding: 25px 0 20px; }
  .ranking-intro h1 { font-size: 28px; }
  .ranking-intro p { font-size: 13px; }
  .ranking-source { margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--line); text-align: left; }
  .ranking-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ranking-summary > div:nth-child(2) { border-right: 0; }
  .ranking-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .ranking-summary strong { font-size: 18px; }
  .ranking-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ranking-search { grid-column: 1 / -1; }
  .ranking-scope-note { line-height: 1.5; }
  .ranking-table-shell { min-height: 240px; overflow: visible; border: 0; background: transparent; }
  .ranking-table { min-width: 0; display: block; }
  .ranking-table thead { display: none; }
  .ranking-table tbody { display: grid; gap: 10px; }
  .token-ranking-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 116px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
  }
  .ranking-table td { height: auto; padding: 0; }
  .rank-number { grid-column: 1; grid-row: 1; padding-top: 4px !important; text-align: left; }
  .token-rank-identity { grid-column: 2; grid-row: 1; padding-right: 8px !important; }
  .token-rank-title { display: grid; gap: 1px; }
  .token-rank-meta code { max-width: 140px; }
  .ai-score-cell { grid-column: 3; grid-row: 1; }
  .metric-cell {
    grid-column: 2 / 4;
    min-height: 31px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    font-size: 12px;
  }
  .metric-cell:first-of-type { margin-top: 10px; }
  .metric-cell::before { content: attr(data-label); color: var(--muted); font: 10px var(--sans); }
  .score-toggle { width: 112px; }
  .score-detail-row { display: none; }
  .score-detail-row.open { display: block; margin: -11px 0 0; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 9px 9px; background: #f8fafc; }
  .score-detail-row td { display: block; padding: 13px; }
  .score-detail-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
  .score-breakdown { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-breakdown .score-part:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .score-evidence-line { grid-column: auto; }
  .loading-row { display: block; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
  .loading-row td { display: block; height: 220px; padding-top: 95px; }
}
