/* ============================================================
   Card Deal Finder — Design System
   Dark, data-dense, Market-Movers-class UI
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #0a0e17;
  --bg-2: #0d1322;
  --panel: #121a2c;
  --panel-2: #16213a;
  --line: #1f2b47;
  --line-2: #2c3d63;

  /* Text */
  --text: #eef2fb;
  --muted: #94a3c4;
  --dim: #64749a;

  /* Brand + semantic */
  --accent: #5b8cff;
  --accent-2: #8b5cf6;
  --grad: linear-gradient(135deg, #5b8cff 0%, #7c6bfa 100%);
  --good: #2fd07c;
  --bad: #ff5d73;
  --warn: #ffb454;

  /* Tints */
  --accent-tint: rgba(91, 140, 255, 0.12);
  --good-tint: rgba(47, 208, 124, 0.12);
  --bad-tint: rgba(255, 93, 115, 0.12);
  --warn-tint: rgba(255, 180, 84, 0.14);

  /* Geometry */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --glow-accent: 0 4px 20px rgba(91, 140, 255, 0.25);

  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(91, 140, 255, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(124, 107, 250, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}

/* Selection, scrollbar, focus */
::selection { background: rgba(91, 140, 255, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

/* ============================================================
   Header / Brand
   ============================================================ */
.header {
  padding: 18px 0 14px;
  border-bottom: 1px solid transparent;
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  filter: drop-shadow(0 4px 14px rgba(91, 140, 255, 0.35));
}

.brand-mark svg { display: block; }

/* Suit iconography: ♠ search · ♥ watchlist · ♦ deals · ♣ scheduler */
.suit {
  display: inline-block;
  font-size: 1.05em;
  line-height: 1;
  transform: translateY(0.5px);
}

.suit-red { color: var(--bad); }
h2 .suit { color: var(--accent); margin-right: 2px; }
h2 .suit-red { color: var(--bad); }
.section-title .suit { font-size: 12px; }

.header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.15;
}

.brand-sub {
  display: block;
  font-size: 11.5px;
  color: var(--dim);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.header-info {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Status badges */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
}

.badge.live, .badge.mock { padding-left: 9px; }

.badge.live::before, .badge.mock::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.badge.live { background: var(--good-tint); border-color: rgba(47, 208, 124, 0.35); color: var(--good); }
.badge.live::before { background: var(--good); }

.badge.mock { background: var(--warn-tint); border-color: rgba(255, 180, 84, 0.35); color: var(--warn); }
.badge.mock::before { background: var(--warn); }

.badge-info { background: var(--panel); color: var(--muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   Nav — sticky glass segmented tabs
   ============================================================ */
.nav-tabs {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.nav-tabs .container {
  display: flex;
  gap: 6px;
  padding-top: 8px;
  padding-bottom: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-tabs .container::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-width: fit-content;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(91, 140, 255, 0.07);
}

.tab-btn.active {
  color: #dbe6ff;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.16), rgba(124, 107, 250, 0.12));
  border-color: rgba(91, 140, 255, 0.35);
}

/* Tab content */
.tab-content { display: none; padding: 28px 0 56px; }
.tab-content.active { display: block; animation: fadeUp 0.25s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Typography helpers
   ============================================================ */
h2 {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title.good { color: var(--good); }

.page-desc {
  color: var(--muted);
  margin: -8px 0 20px;
  font-size: 13.5px;
}

/* Numbers everywhere should be tabular */
.price, .value, .stat-value, .deal-score, .avg-price, .drop-pct,
.player-card-price, .arb-leg-price, .arb-profit-amount, .table td,
.stat-card .value, .chip {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Forms & inputs
   ============================================================ */
form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.search-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.form-row { display: flex; gap: 8px; width: 100%; flex-wrap: wrap; align-items: center; }
.form-inline { gap: 8px; }

input, select, button {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

input::placeholder { color: var(--dim); }

input:hover, select:hover { border-color: var(--line-2); }

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15);
}

input { flex: 1; min-width: 140px; }
select { min-width: 110px; cursor: pointer; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 2px;
  user-select: none;
}

.checkbox input {
  flex: none;
  width: 17px;
  height: 17px;
  min-width: auto;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Buttons */
.btn {
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
  padding: 10px 18px;
  min-height: 42px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: -0.01em;
  transition: all var(--transition);
}

.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow-accent);
}

.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 26px rgba(91, 140, 255, 0.4); }

.btn-success {
  background: var(--good);
  border-color: transparent;
  color: #06210f;
}

.btn-secondary {
  background: var(--panel-2);
  border-color: var(--line-2);
  color: var(--text);
}

/* ============================================================
   Filter presets — outline pills
   ============================================================ */
.filter-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.preset-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-tint);
}

.preset-btn.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow-accent);
}

/* Advanced filters */
.filters { width: 100%; user-select: none; margin-top: 6px; }

.filters summary {
  color: var(--accent);
  font-size: 12.5px;
  padding: 8px 0 4px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filters summary::-webkit-details-marker { display: none; }
.filters summary::before {
  content: "▸";
  transition: transform var(--transition);
  font-size: 11px;
}
.filters[open] summary::before { transform: rotate(90deg); }

.filters summary:hover { color: #9db9ff; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  padding: 14px 0 4px;
  animation: fadeUp 0.2s ease;
}

.filter-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}

.filter-grid .checkbox {
  flex-direction: row;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  align-items: center;
}

/* ============================================================
   Results grid + cards
   ============================================================ */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 14px;
  animation: fadeUp 0.3s ease;
}

.results-meta {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  color: var(--dim);
  font-size: 12.5px;
  font-weight: 500;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--line-2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-header {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.favorite-btn {
  background: rgba(10, 14, 23, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--warn);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.favorite-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.watch-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(10, 14, 23, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(91, 140, 255, 0.5);
  border-radius: 9px;
  font-size: 14px;
}

/* Card media */
.card-media {
  position: relative;
  overflow: hidden;
  background: var(--bg-2);
}

.card-media img, .card > img {
  width: 100%;
  height: 185px;
  object-fit: cover;
  display: block;
  background: var(--bg-2);
  transition: transform 0.45s cubic-bezier(0.2, 0.6, 0.2, 1);
}

.card:hover .card-media img { transform: scale(1.06); }

.card-media::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 56px;
  background: linear-gradient(to top, rgba(10, 14, 23, 0.65), transparent);
  pointer-events: none;
}

/* Card-back pattern for missing images: diagonal weave + the mark */
.card-img-placeholder {
  width: 100%;
  height: 185px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect x='17' y='9' width='21' height='30' rx='4' fill='%23243456' transform='rotate(12 27 24)'/%3E%3Crect x='10' y='8' width='22' height='32' rx='4' fill='%232c3d63' transform='rotate(-6 21 24)'/%3E%3Cg transform='rotate(-6 21 24)' fill='%23445a8a'%3E%3Cpath d='M21 17 l4.2 7 -4.2 7 -4.2 -7 z'/%3E%3C/g%3E%3C/svg%3E") center / 56px no-repeat,
    repeating-linear-gradient(45deg, transparent 0 10px, rgba(91, 140, 255, 0.04) 10px 20px),
    repeating-linear-gradient(-45deg, transparent 0 10px, rgba(124, 107, 250, 0.04) 10px 20px),
    var(--bg-2);
}

.marketplace-pill {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cfe0ff;
  background: rgba(10, 14, 23, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 3px 8px;
  border-radius: 999px;
}

.card .body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.card-toprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card .title {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card .price {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.card .meta { font-size: 11px; color: var(--dim); }

.card .marketplace {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card a, .card-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  margin-top: auto;
  transition: color var(--transition);
}

.card a:hover, .card-link:hover { color: #9db9ff; }

/* Chips — Market Movers-style movement pills */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.chip-good { background: var(--good-tint); color: var(--good); }
.chip-bad { background: var(--bad-tint); color: var(--bad); }
.chip-neutral { background: var(--panel-2); color: var(--muted); }
.chip-warn { background: var(--warn-tint); color: var(--warn); }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

.tag {
  font-size: 10px;
  font-weight: 650;
  padding: 2.5px 7px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.tag.rc { background: var(--good-tint); color: var(--good); }
.tag.reprint { background: var(--warn-tint); color: var(--warn); border: 1px solid rgba(255, 180, 84, 0.35); }
.tag.graded { background: var(--accent-tint); color: var(--accent); }
.tag.deal { background: var(--warn-tint); color: var(--warn); }

/* Deal badges */
.deal-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  width: fit-content;
}

.deal-badge.great_deal { background: var(--good-tint); color: var(--good); border: 1px solid rgba(47, 208, 124, 0.35); }

/* Wildcard tier — the deal that doesn't belong in the deck (score ≥ 90) */
.deal-badge.wildcard {
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.2), rgba(124, 107, 250, 0.2));
  color: #cfe0ff;
  border: 1px solid rgba(124, 107, 250, 0.55);
}

.card.is-wildcard {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    var(--grad) border-box;
}

.card.is-wildcard:hover {
  box-shadow: 0 8px 28px rgba(124, 107, 250, 0.25);
}
.deal-badge.good_deal { background: var(--warn-tint); color: var(--warn); border: 1px solid rgba(255, 180, 84, 0.3); }
.deal-badge.ok_deal { background: var(--accent-tint); color: var(--accent); border: 1px solid rgba(91, 140, 255, 0.3); }
.deal-badge.fair { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.deal-badge.premium { background: rgba(255, 153, 153, 0.1); color: #ff9999; border: 1px solid rgba(255, 153, 153, 0.25); }
.deal-badge.overpriced { background: var(--bad-tint); color: var(--bad); border: 1px solid rgba(255, 93, 115, 0.3); }

/* Deal score — compact meter */
.score-pill {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  flex: none;
}

.score-track {
  width: 100%;
  height: 4px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--grad);
  transition: width 0.5s ease;
}

.deal-score {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.deal-info { font-size: 11px; color: var(--muted); }
.deal-info strong { color: var(--good); }

.deal-trend { font-size: 11px; font-weight: 650; }
.deal-trend.great-savings { color: var(--good); }
.deal-trend.savings { color: var(--warn); }
.deal-trend.fair { color: var(--muted); }
.deal-trend.premium { color: #ff9999; }

.roi-info { font-size: 11.5px; font-weight: 650; }
.roi-up { color: var(--good); }
.roi-down { color: var(--bad); }
.roi-flat { color: var(--muted); }

/* ============================================================
   Arbitrage — flagship component
   ============================================================ */
.arb-section {
  grid-column: 1 / -1;
  margin-bottom: 14px;
}

.arb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.arb-header .section-title { margin: 0; }

.arb-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}

.arb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.arb-card {
  background: linear-gradient(160deg, var(--panel) 0%, rgba(91, 140, 255, 0.05) 120%);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.arb-card:hover {
  border-color: rgba(91, 140, 255, 0.45);
  box-shadow: var(--shadow-md);
}

.arb-title {
  font-weight: 650;
  font-size: 13.5px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.arb-route {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.arb-leg { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.arb-leg.sell { text-align: right; align-items: flex-end; }

.arb-leg-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.arb-leg-site {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.arb-leg-price { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.arb-leg-price.buy { color: var(--good); }
.arb-leg-price.sell { color: var(--text); }

.arb-arrow {
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  opacity: 0.8;
}

.arb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.arb-profit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.arb-profit-amount {
  font-size: 17px;
  font-weight: 800;
  color: var(--good);
  letter-spacing: -0.02em;
}

.arb-actions { display: flex; gap: 6px; }

.btn-mini {
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none;
  transition: filter var(--transition), transform var(--transition);
}

.btn-mini:hover { filter: brightness(1.15); }
.btn-mini:active { transform: scale(0.96); }

.btn-mini.buy { background: var(--good); color: #06210f; }
.btn-mini.sell { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); }

/* ============================================================
   Grader analytics
   ============================================================ */
.panel-block { margin-bottom: 28px; }

.grader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.grader-stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--transition);
}

.grader-stat-card:hover { border-color: var(--line-2); }

.grader-stat-card .grader-name {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
  letter-spacing: -0.01em;
}

.grader-stat-card .avg-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  padding: 2px 0 6px;
}

.grader-stat-card .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}

.grader-stat-card .stat-label { color: var(--dim); }
.grader-stat-card .stat-value { font-weight: 650; color: var(--text); }
.stat-value.stat-up { color: var(--good); }
.stat-value.stat-down { color: var(--warn); }

.grader-stat-card .best-value {
  margin-top: 6px;
  background: var(--good-tint);
  border: 1px solid rgba(47, 208, 124, 0.35);
  padding: 5px 8px;
  border-radius: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--good);
}

/* ============================================================
   Tables
   ============================================================ */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--panel);
}

.table th {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  position: sticky;
  top: 0;
  z-index: 10;
}

.table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  color: var(--text);
}

.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(91, 140, 255, 0.05); }
.table tbody tr:last-child td { border-bottom: none; }

.table .btn { padding: 6px 12px; font-size: 12px; min-height: auto; }

.table .delete-btn {
  background: transparent;
  border: none;
  color: var(--bad);
  cursor: pointer;
  font-size: 15px;
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
  transition: all var(--transition);
}

.table .delete-btn:hover { background: var(--bad-tint); }

.table code {
  font-size: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--muted);
}

/* ============================================================
   Controls
   ============================================================ */
.alert-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.alert-controls input { flex: 1; min-width: 220px; }

/* ============================================================
   Empty & loading states
   ============================================================ */
.empty {
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  padding: 40px 24px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}

.results .empty { grid-column: 1 / -1; }

/* ============================================================
   Modal
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.18s ease;
  padding: 20px;
  overflow-y: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal.active { display: flex; }

.modal-content {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

@keyframes modalIn {
  from { transform: translateY(24px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(10, 14, 23, 0.6);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  z-index: 1001;
  width: 38px;
  height: 38px;
  min-height: auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: all var(--transition);
}

.modal-close:hover { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.modal-image { display: flex; align-items: flex-start; justify-content: center; }

.modal-image img {
  width: 100%;
  border-radius: var(--r-md);
  max-height: 420px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.modal-details h2 { margin: 0 0 18px; font-size: 17px; line-height: 1.45; letter-spacing: -0.02em; }

.modal-section { margin-bottom: 18px; }

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.detail-row .label { color: var(--dim); font-weight: 500; }
.detail-row .value { color: var(--text); font-weight: 650; text-align: right; }

.comparables-block { padding: 20px 24px; border-top: 1px solid var(--line); }

/* ============================================================
   Player research
   ============================================================ */
.player-section { margin-bottom: 30px; }

.stack { display: grid; gap: 10px; }

.player-news-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color var(--transition);
}

.player-news-item:hover { border-color: var(--line-2); }

.player-news-item .title {
  font-weight: 650;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.player-news-item .description { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.player-news-item .meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11.5px;
  color: var(--dim);
}

.sentiment-badge {
  display: inline-flex;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sentiment-badge.positive { background: var(--good-tint); color: var(--good); }
.sentiment-badge.negative { background: var(--bad-tint); color: var(--bad); }
.sentiment-badge.neutral { background: var(--panel-2); color: var(--muted); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 12px;
  text-align: center;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--line-2); }

.stat-card .label {
  font-size: 10px;
  font-weight: 700;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stats-extra {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.stats-extra strong { color: var(--text); font-weight: 650; }

/* Card listings rows */
.player-card-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  transition: border-color var(--transition), background var(--transition);
}

.player-card-item:hover { border-color: var(--line-2); background: var(--panel-2); }

.player-card-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.player-card-info .title {
  font-weight: 650;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.player-card-info .meta { font-size: 12px; color: var(--dim); }

.player-card-price { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }

.player-card-trend { display: flex; gap: 20px; justify-content: flex-end; }

.trend-item { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.trend-item .label { color: var(--dim); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.trend-item .value { font-weight: 700; font-size: 14px; }

/* Price drop deals */
.player-deal-item {
  background: var(--good-tint);
  border: 1px solid rgba(47, 208, 124, 0.3);
  border-radius: var(--r-md);
  padding: 13px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition);
}

.player-deal-item:hover { border-color: var(--good); }

.player-deal-item .left { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }

.player-deal-item .title {
  font-weight: 650;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.player-deal-item .price-info { font-size: 12px; color: var(--muted); }

.player-deal-item .drop-pct {
  font-size: 16px;
  font-weight: 800;
  color: var(--good);
  white-space: nowrap;
}

/* Auth */
#auth-widget { display: inline-flex; gap: 8px; align-items: center; }

.auth-action {
  cursor: pointer;
  font-family: inherit;
  background: var(--accent-tint);
  border-color: rgba(91, 140, 255, 0.35);
  color: var(--accent);
  transition: all var(--transition);
}

.auth-action:hover { background: var(--accent); color: #fff; }

.auth-email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-modal-content { max-width: 420px; }

.auth-body { padding: 28px 24px 24px; }
.auth-body h2 { margin-bottom: 8px; }

/* Easter egg: Wild card. */
.wc-toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: var(--glow-accent);
  z-index: 3000;
  animation: wcToast 2.6s ease forwards;
  pointer-events: none;
}

@keyframes wcToast {
  0% { opacity: 0; transform: translateX(-50%) translateY(12px); }
  12%, 82% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

.wc-rain {
  position: fixed;
  inset: 0;
  z-index: 2999;
  pointer-events: none;
  overflow: hidden;
}

.wc-card {
  position: absolute;
  top: -60px;
  width: 26px;
  height: 38px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 38'%3E%3Crect width='26' height='38' rx='4' fill='%235b8cff'/%3E%3Crect width='26' height='38' rx='4' fill='url(%23g)'/%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%235b8cff'/%3E%3Cstop offset='1' stop-color='%237c6bfa'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M13 8 l5 11 -5 11 -5 -11 z' fill='%23fff'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: wcFall linear forwards;
}

@keyframes wcFall {
  to {
    transform: translateY(115vh) translateX(var(--drift, 0)) rotate(var(--spin, 540deg));
  }
}

/* Sparklines */
.sparkline { display: block; }
.spark-up { color: var(--good); }
.spark-down { color: var(--bad); }
.spark-flat { color: var(--muted); }

.modal-history-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--dim);
  margin-bottom: 6px;
}

#modal-history-chart {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

#modal-history-chart .sparkline { width: 100%; }

/* News → price correlation */
.corr-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--dim);
  border-radius: var(--r-md);
  padding: 14px 16px;
  transition: border-color var(--transition);
}

.corr-card.positive { border-left-color: var(--good); }
.corr-card.negative { border-left-color: var(--bad); }

.corr-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.corr-title {
  font-weight: 650;
  font-size: 13.5px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.corr-meta { font-size: 11.5px; color: var(--dim); margin-bottom: 10px; }

.corr-impact {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.corr-impact-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--dim);
  margin-bottom: 6px;
}

.corr-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.corr-row:last-of-type { border-bottom: none; }

.corr-card-name {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.corr-delta { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.corr-delta.up { color: var(--good); }
.corr-delta.down { color: var(--bad); }
.corr-delta.flat { color: var(--muted); }

.corr-verdict {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-weight: 650;
  font-size: 12px;
}

.corr-verdict.matches { color: var(--good); }
.corr-verdict.contradicts { color: var(--warn); }
.corr-verdict.neutral { color: var(--muted); }

.corr-nodata { color: var(--dim); font-size: 12px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .results { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
  .arb-grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }

  h2 { font-size: 19px; }

  .tab-content { padding: 20px 0 44px; }

  input, select, button { font-size: 16px; } /* prevent iOS zoom */

  .btn { min-height: 44px; }

  .results { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

  .card-media img, .card > img, .card-img-placeholder { height: 155px; }

  .modal-body { grid-template-columns: 1fr; gap: 16px; padding: 18px; }

  .modal-content { max-height: 94vh; }

  .alert-controls { flex-direction: column; }
  .alert-controls input { min-width: 100%; }
  .alert-controls .btn { width: 100%; }

  .player-card-item { grid-template-columns: 1fr; gap: 10px; }
  .player-card-trend { justify-content: flex-start; }
  .trend-item { align-items: flex-start; }
  .trend-item .label { text-align: left; }

  .arb-grid { grid-template-columns: 1fr; }

  /* Stacked table rows */
  .table { display: block; overflow-x: auto; }
}

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

  .header { padding: 14px 0 10px; }
  .header h1 { font-size: 16px; }
  .brand-sub { font-size: 10.5px; }
  .brand-mark { width: 34px; height: 34px; font-size: 17px; border-radius: 9px; }

  .tab-btn { padding: 8px 12px; font-size: 12px; }

  .results { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .card .price { font-size: 16px; }
  .card .title { font-size: 11.5px; }

  .search-form { padding: 12px; }

  .filter-grid { grid-template-columns: 1fr 1fr; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .arb-route { grid-template-columns: 1fr; gap: 8px; }
  .arb-arrow { display: none; }
  .arb-leg.sell { text-align: left; align-items: flex-start; }
  .arb-footer { flex-direction: column; align-items: stretch; }
  .arb-actions { width: 100%; }
  .arb-actions .btn-mini { flex: 1; text-align: center; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-content { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
}

@media (max-width: 420px) {
  .filter-grid { grid-template-columns: 1fr; }
  .header-info { gap: 6px; }
  .badge { font-size: 10px; padding: 4px 8px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
