/* ═══════════════════════════════════════════════════════════════
   Jack's Pokémon Portfolio — Light Theme Design System
   Inspired by Robinhood / Polymarket
   Font: Inter | Bg: #fafafa | Cards: #fff
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --color-bg:         #fafafa;
  --color-surface:    #ffffff;
  --color-border:     #e5e7eb;
  --color-border-md:  #d1d5db;
  --color-text:       #111827;
  --color-text-muted: #6b7280;
  --color-text-light: #9ca3af;
  --color-positive:   #16a34a;
  --color-pos-bg:     #f0fdf4;
  --color-pos-light:  #dcfce7;
  --color-negative:   #dc2626;
  --color-neg-bg:     #fef2f2;
  --color-neg-light:  #fee2e2;
  --color-neutral:    #6b7280;
  --color-primary:    #1d4ed8;
  --color-primary-hover: #1e40af;
  --color-hover:      #f9fafb;
  --color-accent:     #f59e0b;
  --font:             'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        14px;
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:        0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:        0 20px 40px rgba(0,0,0,0.10), 0 8px 16px rgba(0,0,0,0.06);
  --transition:       150ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── TOP BAR ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-logo {
  font-size: 22px;
  line-height: 1;
}

.topbar-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.topbar-portfolio {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-left: 24px;
}

.portfolio-total {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--color-text);
}

.portfolio-change {
  font-size: 14px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100px;
}

/* ── STATS ROW ───────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 24px;
  border-right: 1px solid var(--color-border);
}
.stat-card:last-child { border-right: none; }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--color-text);
}

/* ── COLOR UTILITIES ─────────────────────────────────────────── */
.positive { color: var(--color-positive); }
.negative { color: var(--color-negative); }
.neutral  { color: var(--color-neutral); }

.badge-positive {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--color-positive);
  background: var(--color-pos-bg);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
}
.badge-negative {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--color-negative);
  background: var(--color-neg-bg);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
}
.badge-neutral {
  display: inline-flex;
  align-items: center;
  color: var(--color-text-muted);
  background: #f3f4f6;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 100px;
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-primary:hover { background: var(--color-primary-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-secondary:hover { background: #eff6ff; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { background: var(--color-hover); color: var(--color-text); border-color: var(--color-border-md); }
.btn-ghost.loading svg { animation: spin 1s linear infinite; }

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--color-negative);
  border: 1px solid var(--color-neg-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}
.btn-danger-outline:hover { background: var(--color-neg-bg); border-color: var(--color-negative); }

.badge-negative {
  color: #dc2626;
  background: #fee2e2;
}

.badge-neutral {
  color: #6b7280;
  background: #f3f4f6;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── MAIN CONTENT ────────────────────────────────────────────── */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* ── CONTROLS BAR ────────────────────────────────────────────── */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.view-btn.active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }
.view-btn:hover:not(.active) { color: var(--color-text); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  flex: 1;
  max-width: 320px;
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--color-primary); }

.search-box input {
  border: none;
  outline: none;
  background: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--color-text);
  width: 100%;
}
.search-box input::placeholder { color: var(--color-text-light); }

.refresh-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.last-updated {
  font-size: 12px;
  color: var(--color-text-light);
  white-space: nowrap;
}

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-title { font-size: 22px; font-weight: 700; color: var(--color-text); margin-bottom: 8px; }
.empty-subtitle { font-size: 15px; color: var(--color-text-muted); margin-bottom: 28px; max-width: 420px; margin-left: auto; margin-right: auto; }

/* ── PORTFOLIO TABLE ─────────────────────────────────────────── */
.table-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.portfolio-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.portfolio-table thead th {
  background: var(--color-hover);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.portfolio-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.portfolio-table thead th.sortable:hover { color: var(--color-text); }
.portfolio-table thead th.sort-asc .sort-icon,
.portfolio-table thead th.sort-desc .sort-icon { color: var(--color-primary); }
.portfolio-table thead th.sort-desc .sort-icon { transform: rotate(180deg); }
.sort-icon { transition: transform var(--transition), color var(--transition); vertical-align: middle; margin-left: 4px; }

.portfolio-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}
.portfolio-table tbody tr:last-child { border-bottom: none; }
.portfolio-table tbody tr:hover { background: var(--color-hover); }

.portfolio-table td { padding: 10px 14px; vertical-align: middle; }

/* Column widths */
.col-thumb { width: 52px; padding-right: 4px; }
.col-name  { min-width: 160px; }
.col-set   { min-width: 120px; color: var(--color-text-muted); }
.col-rarity { min-width: 90px; }
.col-condition { min-width: 100px; }
.col-price { min-width: 80px; font-weight: 600; text-align: right; }
.col-change { min-width: 80px; text-align: right; }
.col-sparkline { min-width: 80px; }
.col-source { min-width: 80px; }
.col-actions { width: 40px; text-align: right; }

/* Thumbnail */
.card-thumb {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  display: block;
}

.card-thumb-placeholder {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  background: linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.card-name-cell .card-name    { font-weight: 600; color: var(--color-text); }
.card-name-cell .card-badges  { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.badge-holo  { font-size: 10px; font-weight: 600; color: #7c3aed; background: #f5f3ff; padding: 1px 5px; border-radius: 100px; }
.badge-first { font-size: 10px; font-weight: 600; color: #b45309; background: #fffbeb; padding: 1px 5px; border-radius: 100px; }

/* Delete row button */
.delete-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.portfolio-table tbody tr:hover .delete-row-btn { color: var(--color-text-light); }
.delete-row-btn:hover { background: var(--color-neg-bg) !important; color: var(--color-negative) !important; }

/* Price source badge */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: #f3f4f6;
  padding: 2px 7px;
  border-radius: 100px;
  white-space: nowrap;
}

/* ── SPARKLINE ───────────────────────────────────────────────── */
.sparkline {
  display: block;
  overflow: visible;
}

/* ── CARDS GRID VIEW ─────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.grid-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.grid-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--color-border-md); }

.grid-card-img {
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  object-fit: cover;
  background: linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.grid-card-img img { width: 100%; height: 100%; object-fit: cover; }
.grid-card-placeholder { width: 100%; aspect-ratio: 2.5 / 3.5; display: flex; align-items: center; justify-content: center; font-size: 36px; background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%); }

.grid-card-body {
  padding: 12px;
}

.grid-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-card-set {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-card-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid-card-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
}

/* ── UPLOAD MODAL ────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 150ms ease;
}
.modal-overlay.open { display: flex; }

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

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 200ms ease;
  overflow: hidden;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}
.modal-title { font-size: 18px; font-weight: 700; }

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--color-hover); color: var(--color-text); }

.modal-body { padding: 24px; }

/* ── CHARTS ──────────────────────────────────────────────────── */
.chart-empty-state {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6b7280;
  padding: 1rem;
  font-size: 0.85rem;
  background: #f9fafb;
}
.chart-empty-state .empty-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}
.chart-empty-state p {
  color: #9ca3af;
  margin-top: 0.25rem;
  line-height: 1.3;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--color-border-md);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}
.drop-zone.drag-over {
  border-color: var(--color-primary);
  background: #eff6ff;
}
.drop-icon { font-size: 40px; margin-bottom: 12px; }
.drop-text { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.drop-subtext { font-size: 13px; color: var(--color-text-muted); margin: 8px 0; }
.drop-hint { font-size: 12px; color: var(--color-text-light); margin-top: 12px; line-height: 1.6; }

/* Upload Queue */
.upload-queue {
  margin-top: 16px;
}
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.queue-title { font-size: 14px; font-weight: 600; }
.queue-status { font-size: 13px; color: var(--color-positive); font-weight: 500; }
.queue-items { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.queue-item-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--color-border);
  flex-shrink: 0;
}

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

.queue-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-status {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.queue-item-progress {
  height: 3px;
  border-radius: 2px;
  background: var(--color-border);
  margin-top: 6px;
  overflow: hidden;
}
.queue-item-progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 300ms ease;
}

.queue-item-status-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.queue-card-detail {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fdfdfd;
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 8px;
  animation: fadeUp 0.3s ease-out;
}

.queue-mini-img {
  width: 32px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
}

.queue-mini-placeholder {
  width: 32px;
  height: 45px;
  background: #f3f4f6;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.queue-mini-info {
  flex: 1;
}

.queue-mini-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text);
}

.queue-mini-set {
  font-weight: 400;
  color: var(--color-text-muted);
  margin-left: 6px;
}

.queue-mini-price {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-positive);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* ── CARD DETAIL DRAWER ──────────────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  z-index: 200;
  animation: fadeIn 150ms ease;
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideInRight 250ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  flex-shrink: 0;
}

.drawer-card-name {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.drawer-card-meta {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.drawer-body { padding: 20px; flex: 1; }

.drawer-price-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.drawer-current-price {
  display: block;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
}
.drawer-change {
  display: inline-block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 100px;
}

.drawer-card-img-wrap {
  width: 90px;
  flex-shrink: 0;
}
.drawer-card-img {
  width: 90px;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  object-fit: contain;
}

/* Chart */
.chart-container {
  background: var(--color-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}
.chart-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.chart-tab {
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 100px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: all var(--transition);
}
.chart-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* Drawer Details Grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.detail-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

/* ── LOADING SKELETON ────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

/* ── RARITY COLORS ───────────────────────────────────────────── */
.rarity-common   { color: var(--color-text-muted); }
.rarity-uncommon { color: #16a34a; }
.rarity-rare     { color: #2563eb; }
.rarity-holo     { color: #7c3aed; }
.rarity-ultra    { color: #ea580c; }
.rarity-secret   { color: #db2777; }
.rarity-special  { color: var(--color-accent); }

/* ── NOTIFICATIONS / TOAST ───────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 200ms ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--color-positive); }
.toast.error   { border-left: 3px solid var(--color-negative); }
.toast.info    { border-left: 3px solid var(--color-primary); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .col-condition, .col-rarity { display: none; }
}

@media (max-width: 900px) {
  .col-source, .col-sparkline { display: none; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .stat-card:nth-child(4), .stat-card:nth-child(5) { border-top: 1px solid var(--color-border); }
}

@media (max-width: 700px) {
  .topbar { padding: 0 16px; gap: 8px; }
  .topbar-name { display: none; }
  .portfolio-total { font-size: 18px; }

  .stats-row {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  
  .stats-row::-webkit-scrollbar {
    display: none;
  }

  .stat-card {
    min-width: 140px;
    scroll-snap-align: start;
    border-right: 1px solid var(--color-border);
    border-top: none !important;
  }

  .main-content { padding: 14px 16px 40px; }

  /* On mobile: View controls are hidden but let JS handle visibility naturally */
  .view-toggle { display: none; }
  .controls-bar { gap: 8px; }
  .search-box { max-width: unset; flex: 1; margin-bottom: 8px; }
  .refresh-section { width: 100%; justify-content: space-between; margin-left: 0; }
  .last-updated { margin-left: auto; }

  .drawer { width: 100vw; }

  .drawer-price-row { flex-direction: column-reverse; }
  .drawer-card-img-wrap { width: 70px; }
  .drawer-card-img { width: 70px; }
}

@media (max-width: 480px) {
  .stat-value { font-size: 16px; }
  .cards-grid { 
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); 
    gap: 12px; 
  }
  .grid-card-name { font-size: 13px; }
  .grid-card-set { font-size: 11px; }
  .grid-card-price { font-size: 15px; }
  
  .empty-icon { font-size: 40px; }
  .empty-title { font-size: 18px; }
}

/* ── AUTH GATEWAY ─────────────────────────────────────────── */
.auth-gateway {
  position: fixed;
  inset: 0;
  background-color: var(--color-background);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 3rem 2rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.auth-header {
  margin-bottom: 2rem;
}

.auth-logo {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.auth-header h2 {
  font-size: 1.5rem;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-header p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-form input {
  width: 100%;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  font-size: 1rem;
  color: var(--color-text);
  outline: none;
  transition: all var(--transition);
}

.auth-form input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.auth-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.auth-actions button {
  flex: 1;
  padding: 0.875rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

.auth-error {
  color: var(--color-danger);
  font-size: 0.875rem;
  min-height: 1.2rem;
  margin-top: 0.5rem;
}