:root {
  --bg: #07071a;
  --bg2: #0f0f23;
  --bg3: #1a1a3e;
  --border: #2d2d4e;
  --text: #e2e8f0;
  --muted: #718096;
  --faint: #4a5568;
  --yellow: #f6e05e;
  --green: #68d391;
  --blue: #63b3ed;
  --purple: #a78bfa;
  --red: #fc8181;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── HEADER ─────────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--bg2) 0%, #1a0533 50%, var(--bg2) 100%);
  border-bottom: 1px solid var(--border);
  padding: 24px;
}
.header-inner { max-width: 1400px; margin: 0 auto; }
.header-top { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.logo { font-size: 40px; line-height: 1; }
.site-title {
  font-size: 32px; font-weight: 900; margin: 0;
  background: linear-gradient(135deg, #f6e05e, #f687b3, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.site-sub { color: var(--faint); font-size: 13px; margin-top: 2px; }

/* ── STATS BAR ───────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
}
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 800; }

/* ── TOOLBAR ─────────────────────────────── */
.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.filter-btn {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg2); color: var(--muted);
  cursor: pointer; font-size: 13px; transition: all .15s;
}
.filter-btn.active {
  border: 2px solid var(--purple);
  background: #2d1b69; color: #c4b5fd; font-weight: 600;
}
.gen-jumps { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.gen-jump {
  padding: 4px 10px; border-radius: 6px; font-size: 12px;
  font-weight: 600; cursor: pointer; border: 1px solid; transition: opacity .15s;
}
.gen-jump:hover { opacity: .75; }

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

/* ── GENERATION SECTION ──────────────────── */
.gen-section { margin-bottom: 40px; }
.gen-header {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom-width: 2px; border-bottom-style: solid;
  padding-bottom: 10px; margin-bottom: 16px; cursor: pointer;
}
.gen-title-group { display: flex; align-items: center; gap: 14px; }
.gen-bar { width: 4px; height: 28px; border-radius: 2px; }
.gen-title { font-size: 22px; font-weight: 800; color: var(--text); }
.gen-range { color: var(--muted); font-size: 12px; margin-top: 2px; }
.gen-meta { display: flex; align-items: center; gap: 18px; }
.gen-count { text-align: right; }
.gen-count strong { font-size: 16px; font-weight: 700; }
.gen-count span { color: var(--faint); }
.gen-count small { color: var(--muted); font-size: 11px; display: block; }
.gen-value { text-align: right; }
.gen-value strong { color: var(--yellow); font-size: 14px; font-weight: 700; }
.gen-value small { color: var(--muted); font-size: 11px; display: block; }
.gen-progress { width: 60px; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.gen-progress-fill { height: 100%; border-radius: 3px; transition: width .5s; }
.gen-toggle { color: var(--faint); font-size: 16px; }

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

/* ── POKEMON CARD ────────────────────────── */
.poke-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  color: #1a202c;
}
.poke-card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,.15); }
.poke-card.owned   { border-color: #c6f6d5; background: #fff; }
.poke-card.incoming{ border-color: #bee3f8; background: #fff; }
.poke-card.seeking { border-color: #e2e8f0; background: #f8fafc; }

/* Badge statusu */
.poke-status-badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase;
}
.poke-status-badge.owned    { background: #276749; color: #c6f6d5; }
.poke-status-badge.incoming { background: #2b6cb0; color: #bee3f8; }
.poke-status-badge.seeking  { background: #c53030; color: #fed7d7; }

/* Obszar obrazka */
.poke-img-area {
  width: 100%; aspect-ratio: 3/4;
  background: #f0f4f8;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  border-radius: 12px 12px 0 0;
}
.poke-card.seeking .poke-img-area { background: #edf2f7; }

.poke-img-area img {
  width: 100%; height: 100%; object-fit: contain;
  transition: transform .2s;
}
.poke-card:hover .poke-img-area img { transform: scale(1.04); }
.poke-card.seeking .poke-img-area img { filter: grayscale(.5) opacity(.6); }

/* Zdjęcie karty — wypełnia cały obszar */
.poke-img-area img.card-photo {
  object-fit: cover;
  filter: none !important;
}

.poke-placeholder {
  width: 64px; height: 64px; border-radius: 50%;
  background: #e2e8f0; display: flex; align-items: center; justify-content: center;
}

/* Informacje pod zdjęciem */
.poke-info {
  padding: 10px 12px 8px;
  flex: 1; display: flex; flex-direction: column; gap: 4px;
}
.poke-dex {
  font-size: 11px; color: #a0aec0; font-family: monospace;
}
.poke-name {
  font-weight: 700; font-size: 15px; color: #1a202c;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.poke-set-line {
  font-size: 11px; color: #718096;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.poke-price-line {
  font-size: 13px; font-weight: 700; color: #2d3748;
  margin-top: 2px;
}
.poke-price-line span { color: #718096; font-weight: 400; font-size: 11px; margin-left: 4px; }

/* Typy */
.poke-types { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.type-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  color: #fff; font-size: 10px; font-weight: 700; text-transform: capitalize;
  text-shadow: 0 1px 2px rgba(0,0,0,.4); letter-spacing: .4px;
}

/* Przyciski CM / TCG na dole */
.poke-actions {
  display: flex; gap: 6px; padding: 8px 12px 10px;
  border-top: 1px solid #e2e8f0;
}
.poke-action-btn {
  flex: 1; padding: 5px 0; border-radius: 6px; font-size: 11px;
  font-weight: 600; cursor: pointer; border: 1px solid #e2e8f0;
  background: #f7fafc; color: #4a5568; text-align: center;
  text-decoration: none; display: block;
  transition: background .1s;
}
.poke-action-btn:hover { background: #edf2f7; }
.poke-action-btn.cm  { color: #2b6cb0; border-color: #bee3f8; background: #ebf8ff; }
.poke-action-btn.tcg { color: #553c9a; border-color: #d6bcfa; background: #faf5ff; }

/* ── MODAL OVERLAY ───────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal {
  background: var(--bg2); border-radius: 16px;
  padding: 28px; width: 440px; max-width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; gap: 18px; margin-bottom: 20px; }
.modal-img { width: 90px; height: 90px; object-fit: contain; flex-shrink: 0; }
.modal-dex { color: var(--faint); font-size: 12px; font-family: monospace; }
.modal-name { font-size: 22px; font-weight: 800; margin: 4px 0 6px; }

.status-row { display: flex; gap: 8px; margin-bottom: 16px; }
.status-btn {
  flex: 1; padding: 9px 0; border-radius: 8px; cursor: pointer;
  font-size: 12px; border: 1px solid var(--border);
  background: var(--bg); color: var(--muted);
  transition: all .15s; font-weight: 400;
}
.status-btn.active { border-width: 2px; background: var(--bg3); color: var(--text); font-weight: 700; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { color: var(--muted); font-size: 12px; }
.form-input, .form-textarea {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 10px; color: var(--text); font-size: 13px;
  width: 100%;
}
.form-input:focus, .form-textarea:focus { outline: none; border-color: var(--purple); }
.form-textarea { resize: vertical; min-height: 56px; font-family: inherit; }

.price-row {
  background: var(--bg3); border-radius: 8px; padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.price-row-label { color: var(--muted); font-size: 13px; }
.price-row-value { color: var(--yellow); font-size: 16px; font-weight: 800; }

.btn-row { display: flex; gap: 10px; }
.btn-save {
  flex: 1; padding: 11px 0; border-radius: 8px; border: none;
  color: #fff; font-weight: 800; font-size: 14px; cursor: pointer;
  transition: opacity .15s;
}
.btn-save:hover { opacity: .85; }
.btn-cancel {
  padding: 11px 16px; border-radius: 8px; background: var(--bg);
  color: var(--muted); border: 1px solid var(--border); cursor: pointer; font-size: 13px;
}
.btn-delete {
  padding: 11px 14px; border-radius: 8px; background: transparent;
  color: var(--red); border: 1px solid #4a1c1c; cursor: pointer; font-size: 13px;
}
.links-row { display: flex; gap: 8px; margin-top: 10px; }
.ext-link {
  flex: 1; text-align: center; padding: 8px 0; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  font-size: 12px; text-decoration: none; transition: opacity .15s;
}
.ext-link:hover { opacity: .75; }

/* ── ADMIN PANEL ─────────────────────────── */
.admin-toggle {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--purple); color: #fff; border: none;
  border-radius: 50%; width: 48px; height: 48px;
  font-size: 22px; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  z-index: 500; display: flex; align-items: center; justify-content: center;
}
.admin-panel {
  position: fixed; bottom: 80px; right: 20px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6); z-index: 500;
}
.admin-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--purple); }
.admin-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 10px; color: var(--text); font-size: 13px;
  margin-bottom: 10px;
}
.admin-btn {
  width: 100%; padding: 10px; border-radius: 8px; border: none;
  background: var(--purple); color: #fff; font-weight: 700;
  cursor: pointer; font-size: 13px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.admin-btn:disabled { opacity: .5; cursor: not-allowed; }
.admin-msg { font-size: 12px; color: var(--green); margin-top: 6px; text-align: center; min-height: 18px; }
.admin-msg.error { color: var(--red); }
.admin-last { font-size: 11px; color: var(--faint); margin-top: 6px; text-align: center; }

/* ── TOAST ───────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a2740; border: 1px solid #2d4a7a;
  color: var(--blue); padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 500; z-index: 2000;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.ok   { background: #1a2a1a; border-color: #2d6a2d; color: var(--green); }
.toast.err  { background: #2a1a1a; border-color: #6a2d2d; color: var(--red); }

/* ── LOADER ───────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--purple);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR ────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 640px) {
  .header { padding: 16px; }
  .site-title { font-size: 22px; }
  .main { padding: 16px; }
  .gen-jumps { display: none; }
  .pokemon-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .admin-panel { width: calc(100vw - 40px); }
}

/* ── CARD SEARCH ─────────────────────────────── */
.search-wrap { position: relative; margin-bottom: 10px; }
.search-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 36px 8px 10px; color: var(--text);
  font-size: 13px; transition: border-color .15s;
}
.search-input:focus { outline: none; border-color: var(--purple); }
.search-spinner {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: none;
}

.search-results {
  max-height: 320px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 10px;
}
.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg3); }
.search-result-item.selected { background: #2d1b69; }
.sri-id {
  font-family: monospace; font-size: 11px; color: var(--faint);
  min-width: 56px; flex-shrink: 0;
}
.sri-info { flex: 1; min-width: 0; }
.sri-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sri-set  { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sri-price { text-align: right; flex-shrink: 0; }
.sri-price strong { color: var(--yellow); font-size: 12px; display: block; }
.sri-price span   { color: var(--faint); font-size: 10px; }

.search-hint { font-size: 11px; color: var(--faint); padding: 8px 12px; text-align: center; }
.search-no-catalog {
  background: #2a1a10; border: 1px solid #5a3a1a; border-radius: 8px;
  padding: 10px 14px; font-size: 12px; color: #f6ad55; margin-bottom: 10px;
  line-height: 1.6;
}
