:root {
  --pokedex-red: #cc0000;
  --pokedex-red-dark: #a10000;
  --pokedex-cream: #f5f5f0;
  --card-bg: #ffffff;
  --border: #ddd;
  --text: #222;
  --muted: #888;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: var(--pokedex-cream);
  color: var(--text);
}

.topbar {
  background: var(--pokedex-red);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 1.4rem; flex: 1; }
.admin-link {
  color: white;
  text-decoration: none;
  background: rgba(0,0,0,0.15);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.admin-link:hover { background: rgba(0,0,0,0.3); }

.progress { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.progress-bar { width: 160px; height: 10px; background: rgba(255,255,255,0.3); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; background: #ffd23f; }

.total-value { font-size: 0.9rem; background: rgba(0,0,0,0.15); padding: 0.4rem 0.8rem; border-radius: 6px; }

.filters {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  flex-wrap: wrap;
  background: white;
  border-bottom: 1px solid var(--border);
}
.filters input, .filters select, .filters button {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.filters button { background: var(--pokedex-red); color: white; border: none; cursor: pointer; }
.filters button:hover { background: var(--pokedex-red-dark); }

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1.5rem;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.bulk-actions button {
  padding: 0.5rem 0.9rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: var(--pokedex-red);
  color: white;
}
.bulk-actions button:hover { background: var(--pokedex-red-dark); }
.bulk-actions button:disabled { opacity: 0.6; cursor: default; }
.bulk-actions #bulk-cancel-btn { background: #444; }
.bulk-actions #bulk-cancel-btn:hover { background: #222; }
#bulk-fetch-status { color: var(--muted); }

.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  padding: 1.5rem 1.5rem 0;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); }

.overall-progress-bar {
  height: 8px;
  background: #e6e6e6;
  border-radius: 4px;
  margin: 1rem 1.5rem;
  overflow: hidden;
}
.overall-progress-fill { height: 100%; background: #ffb020; }

.gen-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1.5rem 1.5rem;
}
.gen-pill {
  background: #f0f0ef;
  color: var(--text);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
}
.gen-pill strong { font-weight: 700; }
.gen-pill:hover { background: #e4e4e2; }
.gen-pill.active { background: var(--pokedex-red); color: white; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

.empty-state { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 2rem; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.15s ease;
}
.card.owned { border-color: #2e9e4e; }
.card.missing { opacity: 0.75; }
.card:hover { transform: translateY(-2px); }

.dex-number { font-size: 0.75rem; color: var(--muted); font-weight: 600; align-self: flex-start; }
.card img { width: 100%; max-width: 120px; height: 120px; object-fit: contain; }
.card img.placeholder { filter: grayscale(1) brightness(0.9); opacity: 0.6; }
.card-name { font-weight: 600; font-size: 0.95rem; }
.card-types { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: center; }
.type {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #eee;
  color: #333;
  text-transform: uppercase;
}
.card-note { font-size: 0.75rem; color: var(--muted); font-style: italic; }
.card-value { font-size: 0.8rem; font-weight: 600; color: #2e9e4e; }

.admin-card { gap: 0.5rem; }
.admin-card input[type="file"], .admin-card input[type="text"] { width: 100%; font-size: 0.8rem; padding: 0.3rem; }
.admin-card button {
  width: 100%;
  padding: 0.4rem;
  background: var(--pokedex-red);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.admin-card button:hover { background: var(--pokedex-red-dark); }
.owned-toggle { font-size: 0.85rem; display: flex; align-items: center; gap: 0.3rem; }

.card-actions { display: flex; gap: 0.4rem; width: 100%; }
.card-actions button { flex: 1; }
.fetch-price-btn { background: #444 !important; }
.fetch-price-btn:hover { background: #222 !important; }

.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-form {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 280px;
}
.login-form input { padding: 0.6rem; border: 1px solid var(--border); border-radius: 6px; }
.login-form button { padding: 0.6rem; background: var(--pokedex-red); color: white; border: none; border-radius: 6px; cursor: pointer; }
.login-form .error { color: var(--pokedex-red); font-size: 0.85rem; }
.login-form a { font-size: 0.85rem; color: var(--muted); text-align: center; text-decoration: none; }

.flash { margin: 0.8rem 1.5rem; padding: 0.6rem 1rem; border-radius: 6px; }
.flash.success { background: #e3f7e6; color: #2e9e4e; }
.flash.error { background: #fde3e3; color: var(--pokedex-red); }

.card img.zoomable { cursor: zoom-in; }

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 2rem;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
