/* WartoWracać – wspólny wygląd karty i panelu.
   Kolory lokalu przychodzą z bazy: --brand (tło karty) i --accent (pieczątki, przyciski). */
:root {
  --brand: #14110F;
  --accent: #E0B354;
  --on-brand: #FFFFFF;
  --on-accent: #1A1407;
  --bg: #F6F4F0;
  --surface: #FFFFFF;
  --surface-2: #F0EDE7;
  --line: #E2DDD3;
  --text: #1D1B18;
  --text-2: #57524A;
  --muted: #6F695F;
  --ok: #2E7D4F;
  --danger: #B3402F;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 17, 15, .06), 0 8px 24px rgba(20, 17, 15, .06);
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 800; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: calc(12px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.app--wide { max-width: 960px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* Nagłówek lokalu */
.head { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.head__logo { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--brand); flex: none; display: grid; place-items: center; color: var(--on-brand); font-weight: 800; }
.head__name { font-weight: 800; font-size: 1.1rem; }
.head__sub { color: var(--muted); font-size: .85rem; }

/* Karta lojalnościowa */
.lcard { background: var(--brand); color: var(--on-brand); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; position: relative; overflow: hidden; }
.lcard__top { display: flex; align-items: center; gap: 12px; }
.lcard__logo { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: rgba(255,255,255,.12); flex: none; display: grid; place-items: center; font-weight: 800; }
.lcard__name { font-weight: 800; }
.lcard__who { font-size: .85rem; opacity: .8; }
.lcard__msg { font-weight: 700; font-size: 1.05rem; }
.lcard__msg small { display: block; font-weight: 500; font-size: .85rem; opacity: .8; margin-top: 2px; }

.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stamps--6 { grid-template-columns: repeat(6, 1fr); }
.stamps--4 { grid-template-columns: repeat(4, 1fr); }
.stamp { aspect-ratio: 1; border-radius: 50%; border: 2px dashed currentColor; opacity: .55; display: grid; place-items: center; font-size: .8rem; font-weight: 700; position: relative; }
.stamp.is-filled { opacity: 1; border: none; background: var(--accent); color: var(--on-accent); }
.stamp.is-filled svg { width: 55%; height: 55%; }
.stamp.is-reward { opacity: .95; border-style: solid; }
.stamp.is-reward:not(.is-filled) { color: var(--accent); border-color: var(--accent); }
.stamp__gift { width: 50%; height: 50%; }
.stamp.is-new { animation: pop .6s ease-out; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.lcard .stamp { color: var(--on-brand); }
.lcard .stamp.is-filled { color: var(--on-accent); }
.stamp.is-filled.is-reward { border: none; box-shadow: 0 0 0 2px var(--brand), 0 0 0 4px var(--accent); }

.rewards { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.reward { display: flex; gap: 10px; align-items: center; }
.reward__at { flex: none; min-width: 36px; height: 24px; padding: 0 8px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 800; display: grid; place-items: center; }
.reward.is-done { opacity: .55; text-decoration: line-through; }

/* Bloki */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.box--accent { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.qr { background: #fff; border-radius: var(--radius); padding: 16px; display: grid; place-items: center; }
.qr svg { width: min(240px, 70vw); height: auto; }
.code { font-weight: 800; letter-spacing: .18em; font-size: 1.3rem; text-align: center; }

.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.link-tile { display: flex; align-items: center; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; font-size: .9rem; }
.link-tile svg { width: 20px; height: 20px; flex: none; }

/* Formularze i przyciski */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
label.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); min-height: 48px;
}
input[type=color] { width: 56px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; text-decoration: none; text-align: center; }
.btn--primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn--accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn--danger { color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--big { min-height: 60px; font-size: 1.1rem; }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: default; }

.err { color: var(--danger); font-size: .9rem; font-weight: 600; }
.ok { color: var(--ok); font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-size: .75rem; font-weight: 700; color: var(--text-2); }
.tag--accent { background: var(--accent); color: var(--on-accent); }

/* Dolne menu */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.nav__in { max-width: 520px; margin: 0 auto; display: flex; }
.nav button { flex: 1; background: none; border: none; padding: 10px 4px 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .75rem; font-weight: 700; color: var(--muted); }
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current=page] { color: var(--text); }

/* Lista klientów w panelu */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: none; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; }
.item:last-child { border-bottom: none; }
.item--link { padding: 0; border: none; flex: 1; min-width: 0; }
.item__av { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: .85rem; flex: none; }
.item__name { font-weight: 700; }
.item__sub { color: var(--muted); font-size: .85rem; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: .8rem; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 700; z-index: 50; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow); }
.toast--err { background: var(--danger); }

.scanner { position: fixed; inset: 0; background: #000; z-index: 40; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner__frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scanner__frame div { width: min(70vw, 300px); aspect-ratio: 1; border: 3px solid #fff; border-radius: 20px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scanner__bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; justify-content: center; }

.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; margin: 48px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.poster { background: #fff; color: #111; border-radius: var(--radius); padding: 28px 20px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; border: 1px solid var(--line); }
.poster__title { font-size: 1.6rem; font-weight: 800; }
.poster svg { width: 220px; height: 220px; }
.foot { text-align: center; color: var(--muted); font-size: .75rem; padding: 8px 0; }
.foot a { color: var(--muted); }

@media print {
  body * { visibility: hidden; }
  .poster, .poster * { visibility: visible; }
  .poster { position: absolute; inset: 0; border: none; justify-content: center; }
}
