/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --bg: #fafbfc;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────── */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.site-header__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1.site-header__title, .site-header__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.site-header__title a { color: inherit; }
.site-header__title a:hover { text-decoration: none; }

.site-header__link {
  font-size: 13px;
  color: var(--text-muted);
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ── Search Bar ─────────────────────────────────────────────── */
.search-bar {
  margin-bottom: 16px;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}

/* ── Game Tabs ──────────────────────────────────────────────── */
.game-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab:hover { border-color: var(--blue); color: var(--blue); }
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Set Pills ──────────────────────────────────────────────── */
.set-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

a.pill:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.pill.active { background: var(--blue); color: #fff; border-color: var(--blue); cursor: default; }

/* ── Catalog Stats ──────────────────────────────────────────── */
.catalog-stats {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

h2.page-title, .page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.count, .range {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Catalog Table ──────────────────────────────────────────── */
.catalog-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.catalog-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

.catalog-table th.sortable { cursor: pointer; user-select: none; }
.catalog-table th.sortable:hover { color: var(--blue); }

.catalog-table td {
  padding: 10px 12px;
  font-size: 14px;
  border-bottom: 1px solid #f3f4f6;
}

.catalog-table tbody tr:last-child td { border-bottom: none; }
.catalog-table tbody tr:hover { background: #f9fafb; }

.set-link { font-weight: 500; }
.set-name-hint { color: var(--text-muted); font-size: 12px; }

/* ── Intro ──────────────────────────────────────────────────── */
.intro {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 16px;
}

/* ── Table Buy Link ────────────────────────────────────────── */
.table-buy-link {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
  transition: all 0.15s;
}

.table-buy-link:hover {
  background: var(--blue);
  color: #fff;
  text-decoration: none;
}

/* ── Section Title ─────────────────────────────────────────── */
.price-section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumb .sep { margin: 0 4px; }

/* ── SKU Detail ─────────────────────────────────────────────── */
.sku-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.sku-code {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
}

/* ── Range Buttons ──────────────────────────────────────────── */
.range-buttons {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.range-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.range-btn:hover { border-color: var(--blue); color: var(--blue); }
.range-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Chart ──────────────────────────────────────────────────── */
.chart-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  height: 320px;
}

/* ── Price Grid ─────────────────────────────────────────────── */
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.price-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.price-card__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.price-card__value {
  font-size: 22px;
  font-weight: 700;
}

.price-card__buy {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  transition: all 0.15s;
}

.price-card__buy:hover {
  background: var(--blue);
  color: #fff;
  text-decoration: none;
}

/* ── Price Stats ────────────────────────────────────────────── */
.price-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat__value {
  font-size: 18px;
  font-weight: 600;
}

/* ── Actions ────────────────────────────────────────────────── */
.sku-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.buy-link {
  display: inline-block;
  padding: 8px 20px;
  background: var(--blue);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
}

.buy-link:hover { background: #1d4ed8; text-decoration: none; }

/* ── Header Nav ────────────────────────────────────────────── */
.site-header__nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-header__nav a {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.15s;
}

.site-header__nav a:hover { color: var(--blue); text-decoration: none; }
.site-header__nav a.active { color: var(--blue); }

/* ── Index Cards ───────────────────────────────────────────── */
.index-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.index-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.index-card__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.index-card__value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.index-card__change {
  font-size: 14px;
  font-weight: 600;
}

.index-card__meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Index Change Colors ───────────────────────────────────── */
.index-up, .change-positive { color: var(--green); }
.index-down, .change-negative { color: var(--red); }
.index-flat, .change-zero { color: var(--text-muted); }

/* ── Set Breakdown Table ───────────────────────────────────── */
.set-breakdown {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.set-breakdown th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

.set-breakdown td {
  padding: 10px 12px;
  font-size: 14px;
  border-bottom: 1px solid #f3f4f6;
}

.set-breakdown tbody tr:last-child td { border-bottom: none; }
.set-breakdown tbody tr:hover { background: #f9fafb; }
.set-breakdown td:nth-child(n+3) { text-align: right; }
.set-breakdown th:nth-child(n+3) { text-align: right; }

/* ── Index Ticker ──────────────────────────────────────────── */
.index-ticker {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 0.15s;
  overflow-x: auto;
}

.index-ticker:hover { border-color: var(--blue); }

.ticker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 13px;
}

.ticker-item__label {
  font-weight: 600;
  color: var(--text-muted);
}

.ticker-item__value {
  font-weight: 600;
}

.ticker-item__change {
  font-size: 12px;
  font-weight: 600;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Error ──────────────────────────────────────────────────── */
.error-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ── Loading ────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .price-grid {
    grid-template-columns: 1fr;
  }

  .index-cards {
    grid-template-columns: 1fr;
  }

  .index-card__value { font-size: 24px; }

  .catalog-table th:nth-child(2),
  .catalog-table td:nth-child(2) {
    display: none;
  }

  .set-breakdown th:nth-child(5),
  .set-breakdown td:nth-child(5),
  .set-breakdown th:nth-child(6),
  .set-breakdown td:nth-child(6) {
    display: none;
  }

  .chart-container { height: 240px; }

  .price-stats { flex-wrap: wrap; gap: 16px; }

  .sku-title { font-size: 20px; }

  .site-header__inner { flex-direction: column; gap: 4px; }
}

@media (max-width: 480px) {
  .catalog-table th, .catalog-table td { padding: 8px; font-size: 13px; }
  .set-name-hint { display: none; }
}
