:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f8fafd;
  --border: #eff2f5;
  --border-strong: #dfe4ea;
  --text: #0d1421;
  --muted: #58667e;
  --muted-2: #808a9d;
  --blue: #3861fb;
  --blue-soft: #eef3ff;
  --green: #16c784;
  --green-soft: #e8fff5;
  --red: #ea3943;
  --red-soft: #fff1f2;
  --shadow: 0 8px 28px rgba(88, 102, 126, 0.08);
  --font: Inter, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.promo-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto auto 24px;
  gap: 14px;
  align-items: center;
  min-height: 32px;
  padding: 6px 20px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  text-align: center;
}

.promo-bar span {
  justify-self: end;
  opacity: 0.88;
}

.promo-bar a {
  font-weight: 700;
  text-decoration: underline;
}

.promo-close {
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
}

.site-header {
  position: sticky;
  top: 32px;
  z-index: 25;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  width: 100%;
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: #ffffff;
  font-weight: 900;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
  flex: 1;
}

.nav-links a,
.ghost-link {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ghost-link,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.search-shell,
.table-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--muted-2);
}

.search-shell {
  width: 180px;
  height: 36px;
  padding: 0 12px;
}

.search-shell svg,
.table-search svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex: 0 0 auto;
}

.search-shell input,
.table-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

.login-button,
.signup-button,
.tool-button,
.pager-buttons button {
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.login-button {
  background: var(--blue-soft);
  color: var(--blue);
}

.signup-button {
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(56, 97, 251, 0.18);
}

.icon-button {
  display: none;
  font-size: 22px;
}

main {
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 42px;
}

.page-tabs {
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 74px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.page-tabs a {
  position: relative;
  color: var(--muted);
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.page-tabs a.active {
  color: var(--text);
}

.page-tabs a.active::after {
  position: absolute;
  right: 0;
  bottom: -22px;
  left: 0;
  height: 3px;
  border-radius: 99px;
  background: var(--blue);
  content: "";
}

.premium-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  border: 1px solid rgba(22, 199, 132, 0.28);
  border-radius: 999px;
  background: rgba(22, 199, 132, 0.1);
  padding: 2px 7px;
  color: #16c784;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
  padding: 16px 0 10px;
}

.stat-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  min-height: 104px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  line-height: 1.1;
}

.stat-card em {
  display: block;
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 12px;
  font-style: normal;
}

.mini-chart {
  align-self: end;
  width: 100%;
  height: 52px;
}

.mini-chart polyline {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mini-chart.down polyline {
  stroke: #ff9aa2;
}

.mini-chart.up polyline {
  stroke: var(--green);
}

.gauge-card {
  grid-template-columns: minmax(0, 1fr) 82px;
}

.gauge {
  position: relative;
  align-self: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 47%, transparent 48%),
    conic-gradient(var(--green) 0 33%, #f5d05f 33% 66%, var(--red) 66% 100%);
}

.gauge::after {
  position: absolute;
  bottom: 34px;
  left: 35px;
  width: 30px;
  height: 3px;
  border-radius: 99px;
  background: var(--text);
  transform: rotate(var(--needle-angle, 0deg));
  transform-origin: 3px center;
  content: "";
}

.gauge span {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: var(--text);
}

.ad-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 12px;
  overflow-x: auto;
}

.news-pill,
.network-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  font-weight: 700;
  white-space: nowrap;
}

.news-pill.hot {
  border-color: #b7f5de;
}

.news-pill.hot span {
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  padding: 2px 8px;
  font-size: 11px;
}

.wide-ad {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 420px;
  min-height: 56px;
  margin-left: auto;
  border-radius: 11px;
  background:
    linear-gradient(90deg, rgba(13, 20, 33, 0.92), rgba(13, 20, 33, 0.62)),
    repeating-linear-gradient(135deg, #f3b255 0 10px, #2f5cff 10px 20px);
  color: #ffffff;
  padding: 0 18px;
}

.wide-ad span {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
}

.network-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 12px;
  overflow-x: auto;
}

.network-chip {
  background: var(--surface-muted);
  color: var(--muted);
  border-color: transparent;
}

.network-chip.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 0 12px;
}

.table-search {
  width: min(100%, 360px);
  height: 40px;
  margin-right: auto;
  padding: 0 14px;
}

.tool-button {
  background: var(--surface-muted);
  color: var(--text);
}

.panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
  padding: 14px;
}

.panel-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.panel-row select {
  min-width: 190px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

.checkbox-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 999px;
  background: #ffffff;
  padding: 0 12px;
}

.market-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-copy {
  padding: 22px 18px 10px;
}

.table-heading-line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-copy h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
}

.premium-preview-badge {
  border: 1px solid rgba(22, 199, 132, 0.35);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(22, 199, 132, 0.16), rgba(56, 97, 251, 0.1));
  padding: 6px 10px;
  color: #108b5e;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table-copy p {
  max-width: 860px;
  margin: 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 1420px;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  position: static;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

th,
td {
  height: 68px;
  padding: 0 12px;
  vertical-align: middle;
}

thead th[data-sort] {
  cursor: pointer;
}

thead th[data-sort]::after {
  margin-left: 5px;
  color: var(--muted-2);
  content: "↕";
  font-size: 10px;
}

thead th.sorted-asc::after {
  color: var(--blue);
  content: "↑";
}

thead th.sorted-desc::after {
  color: var(--blue);
  content: "↓";
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: #fbfcff;
}

td {
  text-align: right;
  font-weight: 700;
}

.graded-price {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  line-height: 1.1;
}

.graded-price small {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.raw-multiple {
  color: #16c784;
}

.net-multiple {
  color: #627eea;
}

.grading-tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 138px;
  border: 1px solid rgba(56, 97, 251, 0.2);
  border-radius: 999px;
  background: rgba(56, 97, 251, 0.08);
  padding: 4px 8px;
  color: #3861fb;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  text-align: right;
}

body.view-multipliers td {
  height: 96px;
}

.population-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  line-height: 1.1;
}

.confidence-badge {
  display: none;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

body.view-multipliers .confidence-badge {
  display: inline-flex;
}

.confidence-high {
  background: rgba(22, 199, 132, 0.12);
  color: #16c784;
}

.confidence-medium {
  background: rgba(245, 166, 35, 0.14);
  color: #c98212;
}

.confidence-low {
  background: rgba(234, 57, 67, 0.12);
  color: #ea3943;
}

.watch-col,
.rank-col {
  width: 42px;
  color: var(--muted-2);
  text-align: center;
}

.name-col,
td.name-cell {
  width: 370px;
  text-align: left;
}

.marketcap-col {
  width: 118px;
}

.spark-col {
  width: 170px;
}

.watch-star {
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 18px;
}

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

.card-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.card-meta {
  min-width: 0;
}

.card-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.card-title {
  overflow: hidden;
  color: var(--text);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-symbol {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 800;
}

.card-set {
  display: block;
  overflow: hidden;
  max-width: 250px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-cap {
  display: none;
}

.market-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 24px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.ebay-link {
  border-color: #e1c04f;
  color: #b48a00;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

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

.sparkline {
  width: 150px;
  height: 46px;
}

.sparkline path {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline.positive path {
  stroke: var(--green);
}

.sparkline.negative path {
  stroke: var(--red);
}

.loading-row td,
.empty-row td {
  height: 130px;
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding: 16px 18px;
  color: var(--muted);
  font-weight: 700;
}

.pager-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pager-buttons button {
  border-color: var(--border-strong);
  background: #ffffff;
  color: var(--text);
}

.pager-buttons button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding: 22px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer code {
  color: var(--text);
}

body.promo-dismissed .promo-bar {
  display: none;
}

body.promo-dismissed .site-header {
  top: 0;
}

body.hide-raw [data-column="raw"],
body.hide-psa8 [data-column="psa8"],
body.hide-psa9 [data-column="psa9"],
body.hide-psa10 [data-column="psa10"],
body.hide-psa9cap [data-column="psa9cap"],
body.hide-population [data-column="population"],
body.hide-gem [data-column="gem"] {
  display: none;
}

body.view-multipliers [data-column="psa9cap"],
body.view-multipliers .spark-col {
  display: none;
}

body.view-multipliers table {
  min-width: 1180px;
}

@media (max-width: 1180px) {
  .nav-links,
  .ghost-link,
  .login-button {
    display: none;
  }

  .icon-button {
    display: inline-flex;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .wide-ad {
    min-width: 360px;
  }
}

@media (max-width: 760px) {
  .promo-bar {
    grid-template-columns: 1fr auto 24px;
    text-align: left;
  }

  .promo-bar span {
    display: none;
  }

  .site-header {
    top: 32px;
  }

  .main-nav {
    height: 56px;
    gap: 14px;
    padding: 0 16px;
  }

  .brand span:last-child,
  .signup-button,
  .search-shell {
    display: none;
  }

  main {
    padding: 0 10px 32px;
  }

  .page-tabs {
    min-height: 54px;
    gap: 22px;
  }

  .page-tabs a {
    font-size: 17px;
  }

  .stat-strip {
    display: flex;
    grid-template-columns: none;
    gap: 10px;
    overflow-x: auto;
    padding: 12px 0 8px;
    scrollbar-width: none;
  }

  .stat-card {
    grid-template-columns: minmax(0, 1fr) 110px;
    min-width: 280px;
    min-height: 96px;
    padding: 14px;
  }

  .stat-card strong {
    font-size: 20px;
  }

  .stat-strip::-webkit-scrollbar,
  .ad-row::-webkit-scrollbar,
  .network-row::-webkit-scrollbar,
  .page-tabs::-webkit-scrollbar {
    display: none;
  }

  .wide-ad {
    display: none;
  }

  .ad-row {
    padding: 4px 0 8px;
  }

  .network-row {
    padding: 6px 0 10px;
  }

  .toolbar {
    flex-wrap: wrap;
    padding-bottom: 10px;
  }

  .table-search {
    width: 100%;
    flex: 0 0 100%;
  }

  .tool-button {
    flex: 1;
  }

  .table-copy {
    padding: 14px 14px 8px;
  }

  .table-copy h1 {
    font-size: 22px;
  }

  .table-copy p {
    display: none;
  }

  table {
    min-width: 100%;
    table-layout: auto;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
  }

  tbody tr {
    display: grid;
    grid-template-columns: 28px 28px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 76px;
    padding: 0 12px;
  }

  th,
  td {
    height: auto;
    padding: 0;
    font-size: 12px;
  }

  td {
    text-align: left;
  }

  .watch-col {
    width: auto;
    grid-column: 1;
  }

  .rank-col {
    width: auto;
    grid-column: 2;
  }

  .name-col,
  td.name-cell {
    width: auto;
    min-width: 0;
    grid-column: 3;
  }

  .card-set {
    max-width: none;
    font-size: 11px;
  }

  .mobile-cap {
    display: block;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 600;
  }

  .card-name {
    gap: 8px;
  }

  .card-avatar {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .card-title {
    max-width: none;
  }

  .card-symbol,
  .market-link,
  [data-column="raw"],
  [data-column="psa8"],
  [data-column="psa9"],
  [data-column="psa10"],
  [data-column="psa9cap"],
  [data-column="population"],
  [data-column="gem"],
  .spark-col {
    display: none;
  }

  .marketcap-col {
    display: none;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pager-buttons {
    justify-content: space-between;
  }
}

@media (max-width: 520px) {
  .main-nav {
    padding: 0 10px;
  }

  .market-card {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    margin-right: -10px;
    margin-left: -10px;
  }

  .table-copy {
    padding: 18px 14px 8px;
  }

  .table-copy h1 {
    font-size: 20px;
  }

  .table-copy p {
    font-size: 12px;
  }
  .card-title {
    max-width: calc(100vw - 190px);
  }
}
