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

:root {
  --primary: #16a34a;
  --primary-light: #dcfce7;
  --primary-dark: #15803d;
  --bg: #f0fdf4;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --shadow: 0 2px 8px rgba(0,0,0,0.07);
  --nav-height: 60px;
  --header-height: 56px;
}

/* ── Tryb ciemny ───────────────────────────────────────────── */

body.dark {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --primary-light: #166534;
  --danger-light: #450a0a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ── Nagłówek ──────────────────────────────────────────────── */

header {
  background: var(--primary);
  color: white;
  height: var(--header-height);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex: 1;
}

.back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  line-height: 1;
}

.dark-toggle {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.dark-toggle:hover { background: rgba(255,255,255,0.25); }

/* ── Animacje ──────────────────────────────────────────────── */

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

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

.screen {
  padding: 16px 16px calc(var(--nav-height) + 16px);
  min-height: calc(100vh - var(--header-height));
  animation: fadeSlideIn 0.22s ease;
}

.hidden { display: none !important; }

/* ── Wyszukiwarka ──────────────────────────────────────────── */

.search-bar { margin-bottom: 10px; }

.search-bar input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.3s;
  box-shadow: var(--shadow);
}

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

/* ── Logo na ekranie głównym ───────────────────────────────── */

.home-logo {
  text-align: center;
  padding: 8px 0 18px;
  margin-bottom: 4px;
}

.home-logo img {
  max-width: 88%;
  height: auto;
  max-height: 140px;
  object-fit: contain;
}

/* ── Baner instalacji PWA ──────────────────────────────────── */

.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
}

.install-banner span { flex: 1; }

.install-banner button {
  background: white;
  color: var(--primary);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.install-close {
  background: transparent !important;
  color: white !important;
  padding: 4px 6px !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  opacity: 0.7;
}

/* ── Stopka autora ─────────────────────────────────────────── */

.author-footer {
  text-align: center;
  padding: 24px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.author-footer a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.author-footer a:hover { color: var(--primary); }

/* ── Filtry kategorii ──────────────────────────────────────── */

.category-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar { display: none; }

.cat-chip {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.cat-chip.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

/* ── Sortowanie ────────────────────────────────────────────── */

.sort-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.sort-bar::-webkit-scrollbar { display: none; }

.sort-chip {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}

.sort-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}

/* ── Karty produktów ───────────────────────────────────────── */

.product-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  border-left-width: 4px;
  box-shadow: var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s;
  animation: cardIn 0.18s ease both;
}

.product-card:active {
  transform: scale(0.975);
  box-shadow: none;
}

.product-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }

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

.product-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}

.product-name {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-meta { font-size: 13px; color: var(--text-muted); }

.product-price { text-align: right; flex-shrink: 0; }

.price-current { font-size: 20px; font-weight: 700; color: var(--primary); }

.price-range { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Odznaki ───────────────────────────────────────────────── */

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-cheap  { background: #dcfce7; color: #15803d; }
.badge-expensive { background: #fee2e2; color: #b91c1c; }

body.dark .badge-cheap    { background: #166534; color: #86efac; }
body.dark .badge-expensive { background: #450a0a; color: #fca5a5; }

/* ── Dolna nawigacja (5 przycisków) ────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--card);
  border-top: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 100;
  transition: background 0.3s;
}

.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 2px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.15s;
}

.bottom-nav button span:first-child { font-size: 20px; }

.bottom-nav button.active { color: var(--primary); font-weight: 600; }

/* ── Formularze ────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.15s, background 0.3s;
  box-shadow: var(--shadow);
}

.form-group input:focus { border-color: var(--primary); }

/* ── Przyciski ─────────────────────────────────────────────── */

.btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { opacity: 0.85; transform: scale(0.98); }
.btn-primary  { background: var(--primary); color: white; }
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-small { width: auto; padding: 8px 16px; font-size: 14px; border-radius: 10px; }

/* ── Separator "lub" ───────────────────────────────────────── */

.or-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 14px 0;
  position: relative;
}

.or-divider::before,
.or-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}

.or-divider::before { left: 0; }
.or-divider::after  { right: 0; }

/* ── Baner porównania cen ──────────────────────────────────── */

.price-comparison {
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
  background: var(--primary-light);
  border: 1.5px solid #86efac;
}

.price-comparison.expensive {
  background: var(--danger-light);
  border-color: #fca5a5;
}

/* ── Szczegóły produktu ────────────────────────────────────── */

.chart-container {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}

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

.section-header h3 { font-size: 15px; color: var(--text-muted); font-weight: 600; }

/* ── Porównanie sklepów ─────────────────────────────────────── */

.store-comparison { display: flex; flex-direction: column; gap: 8px; }

.store-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--card);
  border-radius: 10px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  animation: cardIn 0.18s ease both;
}

.store-row.cheapest {
  border-color: var(--primary);
  background: var(--primary-light);
}

.store-left { display: flex; flex-direction: column; gap: 2px; }

.store-name { font-weight: 600; font-size: 15px; }

.store-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.store-price { font-size: 18px; font-weight: 700; color: var(--primary); }

/* ── Historia cen ──────────────────────────────────────────── */

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

.entry-item {
  background: var(--card);
  border-radius: 10px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  animation: cardIn 0.18s ease both;
}

.entry-price { font-size: 18px; font-weight: 700; color: var(--primary); }
.entry-info  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.entry-delete {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.35;
  padding: 4px;
  transition: opacity 0.15s;
}

.entry-delete:hover { opacity: 0.7; }

/* ── Pusty ekran ───────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 50px 24px 30px;
  color: var(--text-muted);
}

.empty-illustration { position: relative; display: inline-block; margin-bottom: 20px; }

.empty-cart { font-size: 72px; display: block; filter: grayscale(20%); }

.empty-coin {
  font-size: 32px;
  position: absolute;
  bottom: -4px;
  right: -16px;
  animation: coinBounce 2s ease-in-out infinite;
}

@keyframes coinBounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.empty-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-desc  { font-size: 15px; line-height: 1.6; }

/* ── Lista zakupów ─────────────────────────────────────────── */

.list-add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.list-add-row input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.3s;
}

.list-add-row input:focus { border-color: var(--primary); }

.list-add-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  width: 48px;
  height: 48px;
  font-size: 26px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.list-add-btn:active { opacity: 0.8; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  animation: cardIn 0.18s ease both;
  transition: opacity 0.2s, background 0.3s;
}

.list-item.checked { opacity: 0.5; }

.list-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

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

.list-item-name {
  font-weight: 600;
  font-size: 15px;
  transition: text-decoration 0.15s;
}

.list-item.checked .list-item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.list-item-hint { font-size: 12px; color: var(--primary); margin-top: 2px; }

.list-item-delete {
  background: none;
  border: none;
  font-size: 18px;
  opacity: 0.35;
  cursor: pointer;
  padding: 4px;
  transition: opacity 0.15s;
}

.list-item-delete:hover { opacity: 0.7; }

/* ── Statystyki ────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  transition: background 0.3s;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.stat-sublabel { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

.highlight-card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  transition: background 0.3s;
  animation: cardIn 0.18s ease both;
}

.highlight-title {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.highlight-value { font-size: 18px; font-weight: 700; margin-bottom: 3px; }
.highlight-sub   { font-size: 13px; color: var(--text-muted); }

/* ── Skanowanie ────────────────────────────────────────────── */

.scan-area {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--card);
  transition: border-color 0.15s, background 0.3s;
}

.scan-area:hover { border-color: var(--primary); }
.scan-area p { margin-top: 10px; color: var(--text-muted); font-size: 15px; }

.scan-area img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
  object-fit: contain;
}

.scan-info-bar {
  background: var(--primary-light);
  border: 1.5px solid #86efac;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.scan-result-item {
  background: var(--card);
  border-radius: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.scan-result-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.scan-name-input {
  flex: 1;
  border: none;
  border-bottom: 1.5px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  padding: 2px 0;
  background: transparent;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.scan-name-input:focus { border-bottom-color: var(--primary); }

.scan-price-wrapper { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }

.scan-price-input {
  width: 68px;
  text-align: right;
  border: 1.5px solid var(--border) !important;
  border-radius: 6px !important;
  padding: 4px 6px !important;
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
  background: var(--card) !important;
}

.scan-price-label { font-size: 13px; color: var(--text-muted); }

/* ── Ładowanie ─────────────────────────────────────────────── */

.loading { text-align: center; padding: 24px; color: var(--text-muted); }

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Toast ─────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 1000;
  white-space: nowrap;
  pointer-events: none;
  animation: toast-in 0.2s ease;
}

body.dark .toast { background: #f1f5f9; color: #0f172a; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Overlay sukcesu ───────────────────────────────────────── */

.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: fadeIn 0.2s ease;
}

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

.success-box {
  background: var(--card);
  border-radius: 20px;
  padding: 36px 32px;
  text-align: center;
  max-width: 280px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.success-icon  { font-size: 56px; margin-bottom: 12px; }
.success-title { font-size: 24px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.success-desc  { font-size: 15px; color: var(--text-muted); line-height: 1.5; }
