/* ========== CSS Variables ========== */
/*
 * Dark theme calibrated to Material Design's dark-surface research rather than
 * pure OLED black. Google's studies showed pure #000 + high-contrast text
 * causes "halation" (text appears to glow/smear, rough on astigmatism) and
 * measurably increases eye fatigue during extended reading. Apple HIG, GitHub,
 * and Discord reached similar conclusions — none of them use pure black.
 *
 * Industry reference points for the base surface:
 *   Material Design:   #121212   (our base)
 *   GitHub Dark:       #0D1117
 *   Twitter "Dim":     #15202B
 *   Discord:           #2F3136
 *
 * Elevation ladder (slight lightness steps, no sharp jumps):
 *   #121212 → #181818 → #1E1E1E → #262626 (hover)
 *
 * Text tops out at #d4d4d4 (~83% white) instead of near-white. That's the
 * Material "high emphasis" token — high enough for WCAG AA on our surfaces
 * while cutting the halation you get from #e8e8e8 on a very dark bg.
 *
 * Still extremely dim on an OLED — the backlight savings and contrast feel
 * of a "dark theme" remain; we just stop short of the eye-strain cliff.
 */
:root {
  --bg-primary: #121212;          /* Material Design dark surface */
  --bg-secondary: #181818;        /* header — 01dp elevation */
  --bg-card: #1e1e1e;             /* cards / tables — 04dp elevation */
  --bg-hover: #262626;            /* hover state */
  --bg-raised: #1a1a1a;           /* sales rows, inline panels */
  --text-primary: #d4d4d4;        /* Material "high emphasis" (~83% white) */
  --text: #d4d4d4;                /* alias used by a few sales selectors */
  --text-secondary: #9a9a9a;      /* Material "medium emphasis" (~60%) */
  --text-muted: #6b7280;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --border: #2a2a2a;              /* visible edge against #121212 surface */
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ========== Header ========== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.app-version {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-muted);
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  vertical-align: middle;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.scrape-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.green { background: var(--green); }
.status-dot.yellow { background: #eab308; animation: pulse 2s infinite; }
.status-dot.red { background: var(--red); }

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

/* ========== Buttons ========== */
.btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== Split Button Dropdown ========== */
.btn-group {
  position: relative;
  display: inline-flex;
}

.btn-group-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.btn-group-toggle {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding: 8px 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.dropdown-arrow {
  font-size: 10px;
  line-height: 1;
}

.btn-group-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 200px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.btn-group-menu.open {
  display: block;
}

.btn-group-menu button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-group-menu button:hover {
  background: var(--bg-hover);
}

.btn-group-menu button + button {
  border-top: 1px solid var(--border);
}

.menu-desc {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ========== External Link Icon ========== */
.psa-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: #f87171;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  font-size: 13px;
  line-height: 1;
}

.psa-link-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.col-link {
  width: 70px;
  text-align: center;
}

.cl-link-btn {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #60a5fa !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}

.cl-link-btn:hover {
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
  color: white !important;
}

.modal-psa-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  margin-top: 8px;
}

.modal-psa-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  padding: 0 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.tab-content.active {
  display: block;
}

/* ========== Progress Banner ========== */
.progress-banner {
  padding: 12px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}

/* ========== Post-Scrape Notice ==========
   Shown after a completed scrape when the PC phase hit Cloudflare challenges
   or other recoverable failures. Dismissable. Amber accent so it reads as a
   heads-up (informational) rather than an error — Cloudflare skips are
   expected and recoverable on retry. */
.scrape-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 32px;
  background: rgba(234, 179, 8, 0.08);       /* amber @ low alpha */
  border-bottom: 1px solid rgba(234, 179, 8, 0.3);
  color: #f3e3a8;
  font-size: 13px;
}

.scrape-notice .notice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(234, 179, 8, 0.25);
  color: #fde68a;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.scrape-notice .notice-body {
  flex: 1;
  line-height: 1.4;
}

.scrape-notice .notice-body strong {
  color: #fde68a;
  font-weight: 600;
}

.scrape-notice .notice-close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}

.scrape-notice .notice-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* ========== Stats Grid ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid var(--border);
}

.stat-card.primary {
  grid-column: span 1;
  /* Subtle red-tinted gradient. Calibrated against the Material Design card
     base (#1e1e1e) — the end stop reads as a dark ember without disappearing
     into a black pit. */
  background: linear-gradient(135deg, var(--bg-card), #2a1010);
  border-color: rgba(239, 68, 68, 0.3);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-card.primary .stat-value {
  font-size: 26px;
}

.value-up { color: var(--green); }
.value-down { color: var(--red); }

/* ========== Chart ========== */
.chart-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  margin-bottom: 32px;
}

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

.chart-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.chart-range {
  display: flex;
  gap: 4px;
}

.range-btn {
  padding: 4px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.range-btn:hover {
  background: var(--bg-hover);
}

.range-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.chart-container {
  position: relative;
  height: 300px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ========== Top Cards ========== */
.top-cards-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
}

.top-cards-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.top-cards-list {
  display: flex;
  flex-direction: column;
}

.top-card-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.top-card-row:last-child {
  border-bottom: none;
}

.top-card-rank {
  width: 28px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.top-card-img {
  width: 40px;
  height: 56px;
  object-fit: contain;
  border-radius: 4px;
  margin-right: 12px;
  background: transparent;
}

.top-card-info {
  flex: 1;
  min-width: 0;
}

.top-card-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-card-detail {
  font-size: 12px;
  color: var(--text-muted);
}

.top-card-value {
  font-size: 16px;
  font-weight: 700;
  text-align: right;
  min-width: 80px;
}

/* ========== Collection Tab ========== */
.collection-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.select {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.collection-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ========== Card Table ========== */
.card-table-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

.card-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.card-table th {
  background: var(--bg-secondary);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.card-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.card-table th.sortable:hover {
  color: var(--text-secondary);
}

.card-table th.sortable.active {
  color: var(--text-primary);
}

.sort-arrow {
  font-size: 10px;
  margin-left: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.card-table th.sortable:hover .sort-arrow {
  opacity: 0.4;
}

.card-table th.sortable.active .sort-arrow {
  opacity: 1;
}


.card-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

.card-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.card-table tbody tr:hover {
  background: var(--bg-hover);
}

.col-img { width: 48px; }
.col-grade { width: 80px; }
.col-value { width: 130px; white-space: nowrap; }
.col-cost { width: 100px; }
.col-gain { width: 120px; }
.col-change { width: 90px; }

.card-thumb {
  width: 36px;
  height: 50px;
  object-fit: contain;
  border-radius: 3px;
  background: transparent;
}

.card-name-cell {
  max-width: 300px;
}

.card-name-primary {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-name-secondary {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.value-na {
  color: var(--text-muted);
  font-style: italic;
}

/* ========== Value Source Badges ========== */
.value-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1.4;
  letter-spacing: 0.3px;
}

.badge-cl {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.badge-psa {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-pc {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.pc-link-btn {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #22c55e !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

.pc-link-btn:hover {
  background: #22c55e !important;
  border-color: #22c55e !important;
  color: white !important;
}

.grade-non-psa {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  letter-spacing: 0.3px;
}

/* ========== Modal ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 32px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-card-header {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.modal-card-img {
  width: 120px;
  height: 170px;
  object-fit: contain;
  border-radius: var(--radius);
  background: transparent;
}

.modal-card-info h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.modal-card-info h3 {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 16px;
}

.modal-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.modal-value-item {
  background: var(--bg-primary);
  padding: 12px 16px;
  border-radius: var(--radius);
}

.modal-value-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.modal-value-amount {
  font-size: 20px;
  font-weight: 700;
}

.modal-chart-container {
  height: 200px;
  margin-top: 16px;
}

/* ========== Recent Sales ========== */
.modal-sales {
  margin-top: 24px;
}

.modal-sales h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.sales-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sale-row {
  display: grid;
  /* Tight fixed widths — just enough to fit the widest value ("FixedPrice",
     "Sep 30, 2025", "$9,999.99") with tabular figures. Price column is sized
     to fit a best-offer pair ("$276.05 $286.79") on one line so the row stays
     the same height as fixed-price rows. Everything left is handed to the
     title column (1fr). */
  grid-template-columns: 48px 1fr 80px 70px 130px;
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-raised, rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  font-size: 12px;
}

/* All three meta columns (Date, Type, Price) right-align their label and
   value so everything hugs the right edge of the row. */
.sale-meta-col {
  text-align: right;
}

.sale-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
}

.sale-img-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
}

.sale-body { min-width: 0; }

.sale-seller {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.sale-title {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.sale-title-link {
  color: var(--text);
  text-decoration: none;
  display: block;
}

.sale-title-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

.sale-meta-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sale-meta-value {
  font-weight: 600;
  font-size: 12px;
  /* Tabular figures so "Jun 9, 2025" and "Feb 9, 2022" render at identical
     widths and don't wobble between rows. */
  font-variant-numeric: tabular-nums;
}

.sale-price {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  text-align: right;
  /* Tabular numerals so dollar values line up at the decimal point. */
  font-variant-numeric: tabular-nums;
  /* Keep the accepted price + strikethrough listed price on one line so
     best-offer rows don't grow taller than fixed-price rows (which would
     push the PRICE label upward and break row alignment). */
  white-space: nowrap;
}

/* Original listing price on a best-offer sale — shown with a strikethrough
   next to the accepted price. Mirrors how PriceCharting renders best-offer
   rows (accepted price bold, listed price struck through). */
.sale-list-price {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: 4px;
}

.sale-link {
  display: inline-block;
  padding: 4px 8px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
  font-size: 11px;
}

.sale-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

/* ========== Empty State ========== */
.empty-state {
  padding: 48px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ========== Beacon (v3.5.0): Sparkline column ========== */
.col-spark {
  width: 90px;
  text-align: center;
  padding: 0 6px;
}

.spark-svg {
  display: block;
  margin: 0 auto;
}

.spark-empty {
  color: var(--text-muted);
  font-size: 11px;
  opacity: 0.6;
}

/* ========== Beacon: Sport chip in modal ========== */
.sport-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ========== Beacon: Comp median sub-label ========== */
.modal-value-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ========== Beacon: Dashboard 2-column layout ========== */
.dashboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

.dashboard-columns > .top-cards-section,
.dashboard-columns > .movers-section {
  margin-top: 0;
}

/* ========== Beacon: Hot Movers panel ========== */
.movers-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

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

.movers-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.movers-range {
  display: flex;
  gap: 4px;
}

.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.movers-column-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.movers-up-title { color: var(--green); }
.movers-down-title { color: var(--red); }

.movers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Show ~10 rows comfortably, scroll the rest. Each row is ~56px
     (28x40 img + 8px padding top/bottom) plus a 4px gap, so 10 rows ≈ 600px.
     If fewer than 10 cards moved, the list simply renders shorter — no
     scrollbar appears and no placeholder rows are added. */
  max-height: 600px;
  overflow-y: auto;
  /* Narrow scrollbar styling so it doesn't dominate the panel. WebKit-only,
     Firefox gets its default skinny bar via scrollbar-width. */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.movers-list::-webkit-scrollbar {
  width: 6px;
}

.movers-list::-webkit-scrollbar-track {
  background: transparent;
}

.movers-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.movers-list::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}

.mover-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.mover-row:hover {
  background: var(--bg-hover);
}

.mover-img {
  width: 28px;
  height: 40px;
  object-fit: contain;
  border-radius: 3px;
  flex-shrink: 0;
  background: transparent;
}

.mover-info {
  flex: 1;
  min-width: 0;
}

.mover-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mover-detail {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mover-change {
  text-align: right;
  flex-shrink: 0;
}

.mover-change-now {
  font-size: 11px;
  font-weight: 400;
  /* Override the green/red cascade from .value-up / .value-down on the
     parent — this line is the *current value*, not part of the change
     signal, so it should read as a neutral reference price. */
  color: var(--text-muted);
  margin-bottom: 1px;
}

.mover-change-dollar {
  font-size: 13px;
  font-weight: 600;
}

.mover-change-pct {
  font-size: 11px;
  opacity: 0.75;
}

/* ========== Beacon: Analytics tab ========== */
.analytics-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

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

.analytics-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.analytics-dim-picker {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.analytics-subheader {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 24px;
  margin-bottom: 12px;
}

.allocation-wrap {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 24px;
  align-items: center;
}

.allocation-chart-col {
  position: relative;
  height: 320px;
}

.allocation-table-col {
  min-width: 0;
  overflow-x: auto;
}

.allocation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.allocation-table th,
.allocation-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.allocation-table th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.alloc-swatch-cell { width: 24px; padding-right: 0; }

.alloc-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
}

.alloc-count,
.alloc-value,
.alloc-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* P&L summary grid */
.pnl-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}

.pnl-summary-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.pnl-summary-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.pnl-summary-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.pnl-summary-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.pnl-source-table,
.pnl-cards-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pnl-source-table th,
.pnl-source-table td,
.pnl-cards-table th,
.pnl-cards-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.pnl-source-table th,
.pnl-cards-table th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-secondary);
}

.pnl-cards-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.pnl-cards-table tbody tr:hover {
  background: var(--bg-hover);
}

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

.pnl-cards-header .analytics-subheader {
  margin: 0;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .tabs {
    padding: 0 16px;
  }

  .tab-content {
    padding: 16px;
  }

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

  .stat-card.primary {
    grid-column: span 2;
  }

  .collection-controls {
    flex-direction: column;
  }

  .col-cost {
    display: none;
  }

  .col-spark {
    display: none;
  }

  .modal-card-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

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

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

  .allocation-wrap {
    grid-template-columns: 1fr;
  }

  .pnl-summary {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Static mode (read-only mirror)
   ============================================================
   When app.js detects window.STATIC_MODE === true it adds
   .static-mode to <body>. These rules hide every control that
   would otherwise trigger a write against the live server, and
   pin a small "Read-only" pill next to the version so the
   visitor knows they're on the mirror.
   ============================================================ */

.static-mode #refresh-btn-group,
.static-mode #scrape-progress,
.static-mode #scrape-notice {
  display: none !important;
}

.static-badge {
  display: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-left: 6px;
  padding: 2px 8px;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-radius: 10px;
  vertical-align: middle;
  text-transform: uppercase;
}

.static-mode .static-badge {
  display: inline-block;
}

/* ========== Activity Tab (v3.7.0) ========== */
/* Timeline feed of card_added / sale / value_change events. Each item is
   a clickable row that opens the card modal. While a scrape is running,
   the tab polls /api/activity?after=... every 1.5s and prepends fresh
   events with a brief highlight pulse. */

.activity-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px 8px;
  flex-wrap: wrap;
}

.activity-filter-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.activity-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.activity-filter input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}

.activity-status {
  font-size: 12px;
  color: var(--text-muted);
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 32px 24px;
}

.activity-day-header {
  margin: 12px 4px 4px;
  padding-top: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.activity-day-header:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.activity-item:hover {
  background: var(--bg-hover);
  border-color: #3a3a3a;
}

.activity-item:active {
  transform: translateY(1px);
}

.activity-item-fresh {
  animation: activity-flash 2s ease-out;
}

@keyframes activity-flash {
  0% {
    background: rgba(239, 68, 68, 0.18);
    border-color: var(--accent);
  }
  100% {
    background: var(--bg-card);
    border-color: var(--border);
  }
}

.activity-img {
  width: 48px;
  height: 66px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.activity-img-placeholder {
  background: var(--bg-raised);
}

.activity-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-header-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  /* No wrap: the card name truncates with ellipsis so .activity-time
     never gets pushed to a second line. The anchor for the timestamp
     should always be the top-right corner of the entry. */
  flex-wrap: nowrap;
  min-width: 0;
}

.activity-card-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.activity-sep {
  color: var(--text-muted);
  padding: 0 2px;
}

.activity-grade {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.activity-type-chip {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

.activity-type-sale {
  background: rgba(99, 102, 241, 0.14);
  color: #a5a8f7;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.activity-type-up {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.activity-type-down {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.activity-type-new {
  background: rgba(234, 179, 8, 0.14);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

/* Muted gray — a removed card is a neutral state (the card left the
   collection), not a trend signal. Keeps the feed from shouting "DOWN"
   when the card simply isn't there anymore. */
.activity-type-removed {
  background: rgba(107, 114, 128, 0.18);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.35);
}

/* Slight desaturation of the whole row so removed cards don't
   visually compete with active-collection events in the feed. */
.activity-item-removed {
  opacity: 0.75;
}

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
  /* Hover tooltip carries the full date + relative time ("Apr 17, 2026
     3:45 PM (2h ago)"). See `timeTitle` in activity.js. */
  cursor: help;
}

.activity-line-1 {
  font-size: 13px;
  color: var(--text-primary);
}

.activity-line-2 {
  font-size: 12px;
  color: var(--text-secondary);
}

.activity-sub {
  color: var(--text-muted);
  font-size: 12px;
}

.activity-sale-price {
  font-weight: 600;
  color: var(--text-primary);
}

.activity-sale-list-price {
  color: var(--text-muted);
  text-decoration: line-through;
  font-size: 11px;
  margin-left: 4px;
}

.activity-full-title {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-ext-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  padding: 0 4px;
}

.activity-ext-link:hover {
  color: var(--accent);
}

.activity-footer {
  display: flex;
  justify-content: center;
  padding: 16px 32px 32px;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 4px;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: live-pulse 1.2s infinite;
  vertical-align: middle;
}

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
