:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card2: #263449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --border: #334155;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }

.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted);
}
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.step {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.counter, .flag {
  font-weight: 600;
  font-size: 12px;
}
.counter { color: var(--primary); }

.hint { color: var(--muted); font-size: 14px; margin: 4px 0 14px; line-height: 1.4; }
.hint code { background: var(--card2); padding: 2px 6px; border-radius: 6px; color: var(--text); }

/* Przyciski */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  background: var(--card2);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.99); }
.btn.primary { background: var(--primary); }
.btn.primary:active { background: var(--primary-d); }
.btn.secondary { background: #0ea5e9; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.big { padding: 18px; font-size: 18px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btnrow { display: flex; gap: 10px; margin-bottom: 10px; }

.filebtn { position: relative; margin-top: 4px; }

/* Skaner na żywo */
.scanner {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanline {
  position: absolute;
  left: 8%; right: 8%; top: 50%;
  height: 2px;
  background: #22d3ee;
  box-shadow: 0 0 12px #22d3ee;
  animation: scan 1.8s ease-in-out infinite;
}
@keyframes scan {
  0%, 100% { top: 20%; }
  50% { top: 80%; }
}

/* Statusy odczytanych kodów nad kamerą */
.scanstatus { display: flex; gap: 8px; margin: 0 0 12px; }
.chip {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: var(--card2);
  border: 1px solid var(--border);
}
.chip.done { color: #fff; background: var(--ok); border-color: var(--ok); }
.chip.done::before { content: "✓ "; }

.feedback { font-size: 14px; margin-top: 8px; min-height: 20px; }
.feedback .ok { color: var(--ok); }
.feedback .warn { color: var(--warn); }

/* Pola formularza */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input {
  width: 100%;
  padding: 13px 14px;
  font-size: 17px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
}
.field input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.flag.scanned { color: var(--ok); }
.flag.scanned::before { content: "✓ zeskanowano"; }

.more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 6px 0;
}

/* Miniatury */
.thumbrow { margin-top: 12px; }
.thumbrow img { width: 100%; border-radius: 10px; border: 1px solid var(--border); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .num {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 12px; padding: 1px 7px; border-radius: 6px;
}
.thumb .del {
  position: absolute; top: 4px; right: 4px;
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.65); color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer;
}

.result { margin-top: 12px; font-size: 15px; line-height: 1.5; }
.result.ok { color: var(--ok); }
.result.err { color: var(--err); }
.result ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

.hidden { display: none !important; }
