/* vonalkodbolcikkszam — közös stílus (a jóváhagyott mockup token-rendszere).
   Ipari „scanner-terminál": nagy monospace cikkszám, zöld=megvan /
   borostyán=nincs, világos+sötét téma (rendszer-követő). */

:root {
  --bg: #EEF1F4;
  --surface: #FFFFFF;
  --surface-2: #F5F7F9;
  --border: #D8DEE4;
  --text: #171B21;
  --text-muted: #616B77;
  --accent: #0E639C;
  --accent-ink: #FFFFFF;
  --ok: #1E8E5A;
  --ok-bg: #E4F4EC;
  --ok-border: #B7E0C8;
  --warn: #B4530A;
  --warn-bg: #FBEEE0;
  --warn-border: #F0CFA6;
  --laser: #FF3B30;
  --viewfinder-bg: #0C0F13;
  /* 2. mód (cikkszám→vonalkód) saját accent-je — a body.mode-cikk váltja be */
  --accent2: #6E45B8;
  --accent2-ink: #FFFFFF;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20,30,40,.06), 0 10px 30px rgba(20,30,40,.10);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1216;
    --surface: #171B21;
    --surface-2: #1D222A;
    --border: #2A313B;
    --text: #E7EBF0;
    --text-muted: #9AA5B1;
    --accent: #3B9EDA;
    --accent-ink: #06121C;
    --ok: #35C285;
    --ok-bg: #122A20;
    --ok-border: #24493A;
    --warn: #E08A3C;
    --warn-bg: #2A1E12;
    --warn-border: #4A3620;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.5);
    --accent2: #A585E0;
    --accent2-ink: #160B2E;
  }
}

/* cikkszám-módban az EGÉSZ felület a 2. accent-re vált (gombok, fókusz,
   márka-jel) → ránézésre elválik, melyik irányban keresünk */
body.mode-cikk {
  --accent: var(--accent2);
  --accent-ink: var(--accent2-ink);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 14px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; flex: none;
  transition: background-color .25s, color .25s;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-title { font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: .72rem; color: var(--text-muted); margin-top: -2px; }
.user-box { display: flex; align-items: center; gap: 8px; flex: none; }
.user-name {
  font-size: .74rem; font-weight: 600; color: var(--text-muted);
  max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout-btn {
  font-family: inherit; font-size: .72rem; font-weight: 600;
  color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; cursor: pointer;
}
.logout-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---- Mód-váltó (vonalkód→cikkszám / cikkszám→vonalkód) ----
   Az aktív gomb a mód SAJÁT accent-színét kapja (kék ill. lila) → a váltó
   maga is mutatja, melyik világban vagyunk. */
.mode-switch {
  display: flex; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 5px;
}
.mode-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: .85rem; font-weight: 700;
  color: var(--text-muted); background: transparent;
  border: none; border-radius: 10px;
  padding: 10px 8px; cursor: pointer; min-height: 52px;
  transition: background-color .25s, color .25s, box-shadow .25s;
}
.mode-btn svg { width: 20px; height: 20px; flex: none; }
.mode-label { text-align: left; line-height: 1.25; }
.mode-btn.active {
  color: var(--accent-ink); background: var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ---- Reverse „hero" — a kamera helyét veszi át cikkszám-módban,
        hogy a mód saját arculatot kapjon, ne üres lapot ---- */
.rev-hero {
  display: flex; align-items: center; gap: 14px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}
.rev-hero-mark {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.rev-hero-mark svg { width: 24px; height: 24px; }
.rev-hero p { margin: 0; font-size: .88rem; line-height: 1.45; }
.rev-hero p strong { display: block; font-size: .95rem; margin-bottom: 2px; }

/* ---- Reverse: vonalkód-lista egy cikkszámhoz ---- */
.vk-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.vk-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 12px;
}
.vk-value {
  font-family: var(--font-mono); font-weight: 700; font-size: 1.15rem;
  font-variant-numeric: tabular-nums; word-break: break-all;
  color: var(--text); flex: 1; min-width: 0;
}
.vk-copy {
  font-family: inherit; font-size: .74rem; font-weight: 600;
  color: var(--accent); background: transparent;
  border: 1.5px solid var(--accent); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; flex: none; min-height: 36px;
}
.rev-cikk {
  font-family: var(--font-mono); font-weight: 700;
  font-size: clamp(1.4rem, 7vw, 2rem); line-height: 1.1;
  word-break: break-all;
}

/* ---- Scanner / viewfinder ---- */
.viewfinder {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  background: var(--viewfinder-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  isolation: isolate;
}
.viewfinder video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
.viewfinder.live video { display: block; }

.vf-idle {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 20px;
  color: #B9C2CC;
}
.viewfinder.live .vf-idle { display: none; }
.vf-idle svg { width: 46px; height: 46px; opacity: .8; }
.vf-idle p { margin: 0; font-size: .84rem; max-width: 22ch; }

.scan-cta {
  font-family: inherit; font-size: .95rem; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  border: none; border-radius: 11px;
  padding: 12px 20px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px;
}
.scan-cta svg { width: 18px; height: 18px; }

/* célkereszt-overlay */
.reticle { position: absolute; inset: 0; display: none; pointer-events: none; }
.viewfinder.live .reticle { display: block; }
.reticle .corner {
  position: absolute; width: 26px; height: 26px;
  border: 3px solid rgba(255,255,255,.92);
}
.reticle .corner.tl { top: 16%; left: 12%; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.reticle .corner.tr { top: 16%; right: 12%; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.reticle .corner.bl { bottom: 16%; left: 12%; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.reticle .corner.br { bottom: 16%; right: 12%; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.laser {
  position: absolute; left: 12%; right: 12%; height: 2px;
  background: var(--laser);
  box-shadow: 0 0 10px 1px var(--laser);
  top: 50%;
  animation: sweep 2.4s ease-in-out infinite;
}
@keyframes sweep {
  0%, 100% { top: 20%; opacity: .45; }
  50% { top: 80%; opacity: 1; }
}
.vf-stop {
  position: absolute; top: 10px; right: 10px;
  font-family: inherit; font-size: .74rem; font-weight: 600;
  color: #fff; background: rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
  display: none;
}
.viewfinder.live .vf-stop { display: block; }
.vf-hint {
  position: absolute; left: 0; right: 0; bottom: 10px;
  text-align: center; color: rgba(255,255,255,.85);
  font-size: .74rem; display: none;
}
.viewfinder.live .vf-hint { display: block; }

.flash {
  position: absolute; inset: 0; background: #fff;
  opacity: 0; pointer-events: none;
}
.flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: 0; } 20% { opacity: .55; } 100% { opacity: 0; } }

/* ---- Kézi bevitel ---- */
.manual { display: flex; flex-direction: column; gap: 10px; }
.field-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-muted);
}
.input-row { display: flex; gap: 8px; }
.code-input {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  padding: 13px 14px;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border); border-radius: 12px;
  min-height: 50px;
}
.code-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.code-input::placeholder { color: var(--text-muted); font-family: var(--font-ui); }
.go-btn {
  font-family: inherit; font-size: .92rem; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  border: none; border-radius: 12px; padding: 0 18px; cursor: pointer;
  min-height: 50px; white-space: nowrap;
  transition: background-color .25s, color .25s;
}
.manual-hint {
  font-size: .74rem; color: var(--text-muted); line-height: 1.5;
  padding: 0 2px;
}
.manual-hint code {
  font-family: var(--font-mono); font-size: .92em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 4px;
}

/* ---- Minta-/részleges találati lista ---- */
.state-chip.info {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.hit-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hit-item {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 12px; cursor: pointer;
}
.hit-item:hover { border-color: var(--accent); }
.hit-top {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.hit-code { font-weight: 700; font-size: 1rem; word-break: break-all; }
.hit-extra { margin-left: auto; color: var(--text-muted); font-size: .78rem; white-space: nowrap; }
.hit-sub { font-size: .8rem; color: var(--text-muted); }
.hit-sub .hit-cikk { font-family: var(--font-mono); font-weight: 700; color: var(--text); }

/* ---- Eredmény ---- */
.result { animation: rise .28s cubic-bezier(.2,.7,.3,1); display: flex; flex-direction: column; gap: 10px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.result-card.found { border-color: var(--ok-border); }
.result-card.missing { border-color: var(--warn-border); }
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.state-chip {
  font-size: .72rem; font-weight: 700; letter-spacing: .03em;
  padding: 5px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.state-chip.ok { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-border); }
.state-chip.miss { color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-border); }
.state-chip svg { width: 14px; height: 14px; }
.scanned-code {
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-body { padding: 16px 16px 18px; }
.cikk-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .11em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.forras-badge {
  font-family: var(--font-mono); font-size: .64rem; font-weight: 600;
  letter-spacing: 0; text-transform: none;
  color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 8px;
}
.cikk-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cikk-value {
  font-family: var(--font-mono); font-weight: 700;
  font-size: clamp(2.2rem, 11vw, 3.2rem);
  letter-spacing: .01em; line-height: 1.05;
  color: var(--text); font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.result-card.multi .cikk-value { font-size: clamp(1.6rem, 8vw, 2.3rem); }
.result-card.missing .cikk-value { color: var(--warn); font-size: clamp(1.3rem, 6vw, 1.8rem); }
.copy-btn {
  font-family: inherit; font-size: .82rem; font-weight: 600;
  color: var(--accent); background: transparent;
  border: 1.5px solid var(--accent); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; min-height: 42px;
  display: inline-flex; align-items: center; gap: 6px;
}
.copy-btn svg { width: 15px; height: 15px; }
.megnevezes { margin-top: 12px; font-size: 1rem; color: var(--text); }
.megnevezes .m-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-muted);
  display: block; margin-bottom: 2px;
}
.miss-help { margin-top: 6px; font-size: .86rem; color: var(--text-muted); }
.multi-note {
  font-size: .8rem; color: var(--warn);
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: 10px; padding: 8px 12px;
}

/* ---- Legutóbbiak ---- */
.recent h2 {
  font-size: .68rem; font-weight: 700; letter-spacing: .11em;
  text-transform: uppercase; color: var(--text-muted);
  margin: 0 0 8px 2px;
}
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 12px; cursor: pointer;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.recent-item:hover { border-color: var(--accent); }
.ri-bar { color: var(--text-muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-arrow { color: var(--text-muted); flex: none; }
.ri-cikk { margin-left: auto; font-weight: 700; color: var(--text); font-size: .92rem; white-space: nowrap; }
.ri-cikk.miss { color: var(--warn); }

/* ---- Lábléc: adat-állapot ---- */
.data-note {
  margin-top: auto;
  font-size: .74rem; color: var(--text-muted);
  text-align: center; padding: 8px 4px 0;
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  font-size: .84rem; font-weight: 600;
  padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Login ---- */
.login-wrap {
  max-width: 400px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  padding: 24px 16px;
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.login-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-card label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .68rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-muted);
}
.login-card input {
  font-family: var(--font-ui); font-size: 1rem;
  padding: 12px 13px;
  background: var(--surface-2); color: var(--text);
  border: 1.5px solid var(--border); border-radius: 11px;
  min-height: 48px;
}
.login-card input.mono { font-family: var(--font-mono); letter-spacing: .12em; }
.login-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.login-btn {
  font-family: inherit; font-size: 1rem; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  border: none; border-radius: 12px; padding: 13px; cursor: pointer;
  min-height: 50px; margin-top: 4px;
}
.login-error {
  font-size: .84rem; color: var(--warn);
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: 10px; padding: 10px 12px;
}
.login-note {
  font-size: .78rem; color: var(--text-muted);
  text-align: center; line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .laser { animation: none; top: 50%; }
  .result { animation: none; }
  .flash.go { animation: none; }
}
