/* Karta Rabatowa — paleta marki Smak Natury, mobile-first, wysoki kontrast (v0.4.0) */
:root {
  --brand-green:       #788837;  /* główny kolor marki */
  --brand-green-dark:  #5f6c2b;  /* stany active/hover */
  --brand-gold:        #d9c826;  /* akcent */
  --brand-gray:        #6d6e71;  /* napisy neutralne */
  --bg:                #f4f5ee;  /* tło "naturalne" off-white */
  --surface:           #ffffff;
  --text:              #3a3a3c;
  --text-soft:         #6d6e71;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* --- Nagłówek z logo --- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 16px 12px 6px;
}
.app-header img { height: 48px; width: auto; flex: 0 1 auto; min-width: 0; }
.header-spacer, .lang-switch { flex: 0 0 auto; }
.lang-switch { display: flex; gap: 4px; }
.header-spacer { width: 64px; }
.app-version { display: flex; align-items: center; font-size: 0.65rem; color: #c3c8b4; }
.lang-btn { background: transparent; border: 1px solid #cdd2bd; color: var(--text-soft);
            border-radius: 8px; padding: 5px 9px; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.lang-btn.is-active { background: var(--brand-green); color: #fff; border-color: var(--brand-green); }
@media (max-width: 380px) {
  .app-header img { height: 40px; }
  .header-spacer { width: 56px; }
  .lang-btn { padding: 4px 7px; }
}

/* --- pasek / nota offline --- */
.offline-bar { background: #6d6e71; color: #fff; text-align: center; font-size: 0.82rem;
               padding: 7px 12px; }
.offline-bar[hidden] { display: none; }
.maintenance-bar { background: var(--brand-gold); color: #3a3a1a; font-weight: 600; }
.offline-note { background: #fdf4f4; border: 1px solid #ecc9c9; color: #b23b3b;
                border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; font-size: 0.9rem; }
.offline-note[hidden] { display: none; }
.entry-back { display: inline-block; margin: 0 0 12px; }
.entry-back[hidden] { display: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.view { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 20px 84px; }
.view.view-top { align-items: flex-start; }
.view[hidden] { display: none; }
.view-title { font-size: 1.25rem; color: var(--brand-green-dark); margin: 4px 0 14px; text-align: center; }

/* --- KARTA: podsumowanie --- */
.card-wrap { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 16px; }
.card-owner { display: flex; align-items: center; justify-content: space-between; }
.owner-label { font-size: 0.8rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: 1px; }
.owner-name { font-size: 1.35rem; font-weight: 700; color: var(--brand-green-dark); }
.badge { font-size: 0.8rem; font-weight: 700; padding: 5px 12px; border-radius: 999px; }
.badge-ok { background: #e6efce; color: var(--brand-green-dark); }
.badge-off { background: #f3d9d9; color: #b23b3b; }

.stats { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--surface); border: 1px solid #e6e8da; border-radius: 14px;
        padding: 14px 8px; text-align: center; }
.stat-val { font-size: 1.4rem; font-weight: 800; color: var(--brand-green-dark); line-height: 1.1; }
.stat-lbl { font-size: 0.78rem; color: var(--text-soft); margin-top: 4px; }

.card-meta { display: flex; align-items: center; justify-content: space-between;
             font-size: 0.9rem; color: var(--text-soft); }
.link-btn { background: none; border: none; color: var(--brand-green-dark);
            font-weight: 700; cursor: pointer; padding: 4px; text-decoration: underline; }

/* --- HISTORIA --- */
.history-wrap { width: 100%; max-width: 480px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hist-item { display: flex; justify-content: space-between; align-items: center; gap: 12px;
             background: var(--surface); border: 1px solid #e6e8da; border-radius: 12px; padding: 12px 14px;
             cursor: pointer; }
.hist-docid { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.hist-store { font-size: 0.8rem; color: var(--brand-green); margin-top: 1px; }
.hist-date { font-size: 0.8rem; color: var(--text-soft); margin-top: 1px; }
.hist-amounts { text-align: right; white-space: nowrap; }
.hist-total { font-weight: 800; color: var(--brand-green-dark); }
.hist-points { font-size: 0.8rem; color: var(--text-soft); margin-top: 2px; }
.hist-item.is-return .hist-total,
.hist-item.is-return .hist-points { color: #c0392b; }
.hist-item.is-return { border-color: #ecc9c9; background: #fdf4f4; }
.history-empty { text-align: center; color: var(--text-soft); margin-top: 30px; }

/* --- PROMOCJE --- */
.promo-section-title { font-size: 1rem; color: var(--brand-green-dark); margin: 18px 0 8px; }
.promo-section-title:first-of-type { margin-top: 4px; }
.promo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.promo-list:empty { display: none; }
.promo-card { display: flex; gap: 12px; background: var(--surface); border: 1px solid #e6e8da;
               border-radius: 12px; padding: 12px 14px; align-items: flex-start; }
.promo-img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: #eee; }
.promo-body { flex: 1; min-width: 0; }
.promo-title { font-weight: 700; color: var(--text); }
.promo-desc { font-size: 0.85rem; color: var(--text-soft); margin-top: 2px; }
.promo-prices { margin-top: 6px; display: flex; align-items: baseline; gap: 8px; }
.promo-price-new { font-weight: 800; color: var(--brand-green-dark); font-size: 1.1rem; }
.promo-price-old { color: var(--text-soft); text-decoration: line-through; font-size: 0.9rem; }
.promo-until { font-size: 0.8rem; color: var(--text-soft); margin-top: 4px; }

/* --- DOLNA NAWIGACJA --- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex;
              background: var(--surface); border-top: 1px solid #e0e3d3; z-index: 40;
              padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav[hidden] { display: none; }
.nav-btn { flex: 1; background: none; border: none; cursor: pointer; padding: 10px 4px 12px;
           display: flex; flex-direction: column; align-items: center; gap: 3px;
           font-size: 0.78rem; color: var(--text-soft); font-weight: 600; }
.nav-btn[hidden] { display: none; }
.nav-btn .nav-ico { font-size: 1.3rem; line-height: 1; filter: grayscale(0.4); opacity: 0.7; }
.nav-btn.is-active { color: var(--brand-green-dark); }
.nav-btn.is-active .nav-ico { filter: none; opacity: 1; }

/* --- WIDOK KOD KRESKOWY --- */
.barcode-wrap { width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.barcode-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px 16px 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 24px rgba(95,108,43,0.18);
  border: 1px solid #e6e8da;
}
#barcode { width: 100%; height: auto; }
.barcode-number {
  margin-top: 8px;
  font-family: "Courier New", monospace;
  font-size: 1.5rem;
  letter-spacing: 4px;
  color: #111;
  font-weight: 700;
}

/* --- WIDOK WPISZ KARTĘ --- */
.entry-wrap { width: 100%; max-width: 440px; text-align: center; }
.entry-wrap h1 { font-size: 1.5rem; margin: 0 0 6px; color: var(--brand-green-dark); }
.entry-wrap .sub { color: var(--text-soft); margin: 0 0 24px; }
#card-input {
  width: 100%;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 3px;
  padding: 16px;
  border-radius: 12px;
  border: 2px solid #d3d7c2;
  background: var(--surface);
  color: var(--text);
  font-family: "Courier New", monospace;
}
#card-input:focus { outline: none; border-color: var(--brand-green); }
.error { color: #c0392b; font-size: 0.9rem; margin: 10px 0 0; }

/* --- separator "albo" --- */
.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 6px; color: var(--text-soft); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #d3d7c2; }

/* --- skaner kamerą --- */
.scan-modal { background: #000; padding: 0; }
.scan-box { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column;
            align-items: center; justify-content: center; }
#scan-video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.scan-frame { position: relative; z-index: 2; width: 78%; max-width: 360px; aspect-ratio: 16/10;
              border: 3px solid var(--brand-gold); border-radius: 14px;
              box-shadow: 0 0 0 100vmax rgba(0,0,0,0.45); }
.scan-hint { position: relative; z-index: 2; color: #fff; margin-top: 22px; text-align: center;
             padding: 0 24px; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }
.btn-on-dark { position: relative; z-index: 2; width: auto; min-width: 160px; margin-top: 24px;
               color: #fff; border-color: rgba(255,255,255,0.6); background: rgba(0,0,0,0.3); }

/* --- przyciski --- */
.btn { display: inline-block; border: none; border-radius: 12px; font-size: 1.1rem;
       font-weight: 700; padding: 16px 24px; cursor: pointer; width: 100%; margin-top: 18px; }
.btn-primary { background: var(--brand-green); color: #fff; }
.btn-primary:active { background: var(--brand-green-dark); }
.btn-ghost { background: transparent; color: var(--brand-green-dark); border: 1px solid #cdd2bd; }
.btn-ghost:active { background: #eceee0; }

.app-footer { text-align: center; color: #a7ad95; font-size: 0.75rem; padding: 8px; }

/* --- Baner instalacji --- */
.install-banner {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--brand-green); border-top: 1px solid var(--brand-green-dark);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  z-index: 50;
}
.install-banner[hidden] { display: none; }
.install-text { flex: 1; font-size: 0.95rem; color: #fff; }
.btn-install {
  background: var(--brand-gold); color: #3a3a1a; border: none; border-radius: 10px;
  font-weight: 700; font-size: 1rem; padding: 10px 18px; cursor: pointer; white-space: nowrap;
}
.btn-install:active { filter: brightness(0.92); }
.btn-install-close {
  background: transparent; color: rgba(255,255,255,0.8); border: none; font-size: 1.1rem;
  cursor: pointer; padding: 6px 4px;
}

/* --- Modal (instrukcja iOS) --- */
.modal {
  position: fixed; inset: 0; background: rgba(58,58,60,0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface); border-radius: 16px; padding: 24px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-card h2 { margin: 0 0 16px; font-size: 1.2rem; color: var(--brand-green-dark); }
.ios-steps { margin: 0 0 20px; padding-left: 20px; color: var(--text); line-height: 1.7; }
.ios-steps strong { color: var(--brand-green-dark); }
.ios-share { display: inline-block; }

/* --- Modal: pozycje dokumentu --- */
.doc-modal-info { margin: -10px 0 14px; }
.doc-info-docid { font-size: 0.8rem; font-weight: 600; color: var(--text-soft); }
.doc-info-date  { font-size: 0.8rem; color: var(--text-soft); }
.doc-info-store { font-size: 0.8rem; color: var(--brand-green); }
.doc-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px;
            max-height: 50vh; overflow-y: auto; }
.doc-item { background: var(--bg); border: 1px solid #e6e8da; border-radius: 10px; padding: 10px 12px; }
.doc-name { font-weight: 600; color: var(--text); font-size: 0.92rem; margin-bottom: 4px; }
.doc-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px;
            font-size: 0.85rem; color: var(--text-soft); }
.doc-qty { margin-right: auto; }
.doc-price-old { text-decoration: line-through; color: var(--text-soft); }
.doc-discount { color: #c0392b; font-weight: 700; }
.doc-price { font-weight: 800; color: var(--brand-green-dark); }
