/* BYSEC eSklad — navy + sunshine yellow. Mobil (skladník) aj tablet (podpis). */
:root {
  --navy:        #14202E;
  --navy-2:      #1B2A3A;
  --navy-3:      #0E1826;
  --accent:      #F2C24A;
  --accent-deep: #E0A72C;
  --accent-ink:  #14202E;

  --paper:   #FFFFFF;
  --paper-2: #F3F5F7;
  --ink:     #14202E;
  --ink-2:   #5A6B7B;
  --muted:   #8C99A6;
  --line:    rgba(20,32,46,.08);
  --line-2:  rgba(20,32,46,.14);

  --ok-bg:   #DCEFE3; --ok-ink:   #2E7D5B;
  --wait-bg: #F6E6AE; --wait-ink: #8A6A12;
  --err-bg:  #F7DAD9; --err-ink:  #B23A34;
  --in-bg:   #DDE9F7; --in-ink:   #2B5C96;

  --radius: 16px; --radius-s: 12px;
  --shadow: 0 1px 2px rgba(20,32,46,.05), 0 8px 24px rgba(20,32,46,.06);
  --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar-h: 64px;
  --shell: 480px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; font-family: var(--font);
  background: var(--navy); color: var(--ink);
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: 16px; }
button { cursor: pointer; }

main {
  max-width: var(--shell); margin: 0 auto; min-height: 100dvh;
  position: relative; background: var(--paper-2); overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
section[data-screen] { display: none; }
section[data-screen].active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

.pad { padding: 16px 16px calc(var(--tabbar-h) + 24px); }
.muted { color: var(--muted); }
.error { color: var(--err-ink); margin-top: 8px; font-size: 14px; }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }

/* ── tlačidlá ───────────────────────────────────────────────────────── */
.btn {
  width: 100%; border: 0; border-radius: var(--radius-s); padding: 15px 16px;
  font-size: 15.5px; font-weight: 700; display: inline-flex; gap: 9px;
  align-items: center; justify-content: center; transition: transform .08s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-dark    { background: var(--navy); color: #fff; }
.btn-ghost   { background: transparent; color: var(--ink-2); border: 1px solid var(--line-2); }
.btn-danger  { background: var(--err-bg); color: var(--err-ink); }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 10px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  background: rgba(255,255,255,.10); border: 0; color: #fff;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.on { background: var(--accent); color: var(--accent-ink); }

/* ── tmavé obrazovky ────────────────────────────────────────────────── */
.dark { background: var(--navy); min-height: 100dvh; color: #fff;
        padding-bottom: calc(var(--tabbar-h) + 16px); }
.dark .muted { color: rgba(255,255,255,.55); }
/* `viewport-fit=cover` + `black-translucent` znamená, že obsah ide POD
   stavový riadok a notch. Bez tohto odsadenia sedia tlačidlá Späť a Blesk
   pod hodinami a nedá sa na ne ťuknúť. */
.topbar { display: flex; align-items: center; gap: 10px; z-index: 5;
          padding: calc(14px + env(safe-area-inset-top)) 14px 8px;
          background: var(--navy); position: sticky; top: 0; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; color: #fff;
             flex: 1; text-align: center; }
.topbar .spacer { width: 44px; flex: 0 0 auto; }
.topbar.light { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar.light h1 { color: var(--ink); }
.topbar.light .icon-btn { background: var(--paper-2); color: var(--ink); }

/* ── login ──────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: calc(52px + env(safe-area-inset-top)) 20px 10px; }
.hero .logo { display: inline-block; padding: 7px 14px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
  letter-spacing: .5px; font-size: 13px; }
.hero h1 { margin: 18px 0 6px; font-size: 34px; letter-spacing: -.5px; color: #fff; }
.hero p { margin: 0; color: rgba(255,255,255,.6); }
.card-dark { margin: 24px 18px 0; background: var(--navy-2); border-radius: var(--radius);
             padding: 20px 18px; }
.card-dark label { display: block; margin-bottom: 14px; font-size: 12.5px;
                   color: rgba(255,255,255,.6); }
.card-dark input { width: 100%; margin-top: 6px; padding: 13px 14px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14); background: var(--navy-3); color: #fff; }
.card-dark input::placeholder { color: rgba(255,255,255,.35); }
.card-dark input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.install-hint { margin: 20px 18px 0; color: rgba(255,255,255,.6); }
.install-hint summary { font-size: 13.5px; }
.install-hint p { font-size: 12.5px; margin: 8px 0 0; }

/* ── domov: dlaždice ────────────────────────────────────────────────── */
.home-head { position: relative; background: var(--navy); color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 18px 26px;
  border-radius: 0 0 22px 22px; overflow: hidden; }
.home-head .stripes { position: absolute; right: -14px; top: -26px; width: 150px;
  height: 150px; opacity: .9; }
.home-head .kicker { font-size: 11.5px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--accent); font-weight: 700; }
.home-head h2 { margin: 6px 0 2px; font-size: 25px; letter-spacing: -.4px; }
.home-head p { margin: 0; font-size: 13px; color: rgba(255,255,255,.6); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
         padding: 16px 16px calc(var(--tabbar-h) + 24px); }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 14px; text-align: left; display: flex; flex-direction: column;
  gap: 10px; box-shadow: var(--shadow); transition: transform .08s; min-height: 116px; }
.tile:active { transform: scale(.975); }
.tile .ic { width: 44px; height: 44px; border-radius: 13px; background: var(--accent);
  color: var(--accent-ink); display: grid; place-items: center; }
.tile .ic svg { width: 23px; height: 23px; }
.tile.alt .ic { background: var(--navy); color: var(--accent); }
.tile b { font-size: 15.5px; display: block; }
.tile span { font-size: 12px; color: var(--muted); line-height: 1.35; display: block; }
.tile .badge { position: absolute; }

.section-label { display: flex; justify-content: space-between; align-items: center;
  padding: 4px 18px 8px; font-size: 11.5px; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--muted); font-weight: 700; }
.section-label a { color: var(--ink-2); font-weight: 600; letter-spacing: 0;
  text-transform: none; font-size: 13px; text-decoration: none; }

/* ── skener ─────────────────────────────────────────────────────────── */
#scanner { position: relative; width: 100%; aspect-ratio: 3/4; max-height: 44dvh;
  background: #000; overflow: hidden; }
#scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 0; pointer-events: none; }
.corner { position: absolute; width: 42px; height: 42px; border: 3px solid var(--accent); }
.corner.tl { top: 18px; left: 18px; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.corner.tr { top: 18px; right: 18px; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.corner.bl { bottom: 18px; left: 18px; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.corner.br { bottom: 18px; right: 18px; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.scanline { position: absolute; left: 18px; right: 18px; height: 2px;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
  animation: sweep 2.1s ease-in-out infinite; }
@keyframes sweep { 0%,100%{ top:20% } 50%{ top:78% } }
.scan-hint { text-align: center; color: rgba(255,255,255,.6); font-size: 13px;
             margin: 12px 18px 0; }
/* Riadok pre diagnostiku — pri hlásení „kamera nejde" povie, čo apka vidí. */
.scan-diag { text-align: center; color: rgba(255,255,255,.3); font-size: 10.5px;
             margin: 4px 18px 0; font-family: ui-monospace, monospace; }

#sw-banner { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 14px); z-index: 95; width: calc(100% - 24px);
  max-width: 440px; display: flex; align-items: center; gap: 8px;
  background: var(--navy); color: #fff; border-radius: 12px;
  padding: 11px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(8,16,26,.35); }
#sw-banner span { flex: 1; line-height: 1.35; }
#sw-banner button { border: 0; border-radius: 8px; font-weight: 700; font-size: 12.5px;
  padding: 7px 11px; background: var(--accent); color: var(--accent-ink); }
#sw-banner #sw-later { background: transparent; color: rgba(255,255,255,.55);
  font-size: 17px; padding: 4px 8px; }
.scan-beep { position: absolute; inset: 0; background: rgba(242,194,74,.35);
  opacity: 0; pointer-events: none; }
.scan-beep.flash { animation: beep .3s ease; }
@keyframes beep { from{opacity:1} to{opacity:0} }

.manual-row { display: flex; gap: 8px; margin: 14px 16px 0; }
.manual-row input { flex: 1; padding: 13px 14px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14); background: var(--navy-3); color: #fff; }
.manual-row .btn { width: auto; padding: 13px 18px; }

/* ── riadky dokladu ─────────────────────────────────────────────────── */
.doc-head { background: var(--paper); border-bottom: 1px solid var(--line);
            padding: 12px 16px; }
.doc-head .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.doc-head .who { font-weight: 700; font-size: 15px; }
.doc-head .sub { font-size: 12.5px; color: var(--muted); }

.lines { padding: 8px 12px calc(var(--tabbar-h) + 96px); }
.line {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 11px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 10px; margin-bottom: 9px;
}
.line.short { border-color: var(--wait-ink); background: #FFFCF2; }
.line.ok    { border-color: var(--ok-ink); }
.line .thumb { width: 48px; height: 48px; border-radius: 9px; background: var(--paper-2);
  object-fit: contain; display: block; border: 1px solid var(--line); }
.line .nm { font-size: 13.5px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line .cd { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--paper); font-size: 18px; line-height: 1; color: var(--ink); }
.stepper input { width: 52px; text-align: center; border: 1px solid var(--line-2);
  border-radius: 8px; padding: 7px 2px; font-weight: 700; font-size: 14px; }
.line .uom { font-size: 11px; color: var(--muted); text-align: center; margin-top: 2px; }
.serials { grid-column: 1 / -1; border-top: 1px dashed var(--line-2); padding-top: 8px; }
.serials .sn { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.serials .sn input { flex: 1; padding: 8px 10px; border: 1px solid var(--line-2);
  border-radius: 8px; font-size: 13px; }
.serials .sn button { border: 0; background: var(--err-bg); color: var(--err-ink);
  border-radius: 8px; width: 32px; height: 32px; }
.serials .add { font-size: 12.5px; color: var(--ink-2); background: none; border: 0;
  padding: 4px 0; font-weight: 600; }

.docbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--tabbar-h);
  width: 100%; max-width: var(--shell); background: var(--paper);
  border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; align-items: center; z-index: 20; }
.docbar .sum { flex: 1; font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.docbar .sum b { display: block; color: var(--ink); font-size: 15px; }
.docbar .btn { width: auto; flex: 0 0 auto; padding: 13px 18px; }

/* ── zoznamy ────────────────────────────────────────────────────────── */
.filters { display: flex; gap: 7px; padding: 10px 16px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; }
.chip { border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  white-space: nowrap; flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px; }
/* Bez pevného rozmeru sa inline SVG roztiahne na výšku riadku a rozhodí tlačidlo. */
.chip svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn svg, .opt svg, .more-item svg { flex: 0 0 auto; }
.opt > span > svg, .opt > svg { width: 20px; height: 20px; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 13px 14px; margin-bottom: 9px; display: block; width: 100%; text-align: left; }
.card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .nm { font-weight: 700; font-size: 14.5px; }
.card .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.pill { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  white-space: nowrap; background: var(--paper-2); color: var(--muted); }
.pill.done { background: var(--ok-bg); color: var(--ok-ink); }
.pill.wait { background: var(--wait-bg); color: var(--wait-ink); }
.pill.err  { background: var(--err-bg); color: var(--err-ink); }
.pill.info { background: var(--in-bg); color: var(--in-ink); }

.searchbar { padding: 10px 16px 4px; }
.searchbar input { width: 100%; padding: 13px 14px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--paper); }

.empty { text-align: center; color: var(--muted); padding: 42px 24px; font-size: 14px; }
.empty svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 10px; }

/* ── detail produktu ────────────────────────────────────────────────── */
.prod-hero { background: var(--paper); padding: 18px 18px 16px; text-align: center;
             border-bottom: 1px solid var(--line); }
.prod-hero img { width: 190px; height: 190px; object-fit: contain; border-radius: var(--radius);
                 background: var(--paper-2); }
.prod-hero h2 { margin: 14px 0 4px; font-size: 19px; line-height: 1.3; }
.prod-hero .code { font-size: 12.5px; color: var(--muted); font-family: ui-monospace, monospace; }
.kv { display: flex; justify-content: space-between; padding: 11px 0;
      border-bottom: 1px solid var(--line); font-size: 14px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 700; }
.stock-big { display: flex; align-items: baseline; gap: 8px; justify-content: center;
             margin: 14px 0 4px; }
.stock-big .n { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.stock-big .u { font-size: 15px; color: var(--muted); }
.loc-row { display: flex; justify-content: space-between; align-items: center;
  padding: 11px 12px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-s); margin-bottom: 8px; }
.loc-row .l { font-size: 13.5px; font-weight: 600; }
.loc-row .r { font-size: 15px; font-weight: 800; }
.loc-row small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }

/* ── podpis ─────────────────────────────────────────────────────────── */
.sign-wrap { padding: 14px 16px calc(var(--tabbar-h) + 20px); }
.sign-pad { position: relative; width: 100%; height: 210px; background: var(--paper);
  border: 2px dashed var(--line-2); border-radius: var(--radius); touch-action: none; }
.sign-pad canvas { width: 100%; height: 100%; display: block; border-radius: var(--radius); }
.sign-pad .ph { position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 14px; pointer-events: none; }
.sign-pad.has-ink .ph { display: none; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px;
  font-weight: 600; }
.field input { width: 100%; padding: 13px 14px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--paper); }
.field input:disabled { background: var(--paper-2); color: var(--muted); }

/* „Ukázať heslo" — bez toho sa preklep v hviezdičkách nedá odhaliť. */
.reveal { display: flex; align-items: center; gap: 9px; margin: -4px 0 14px;
  font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.reveal input { width: 20px; height: 20px; accent-color: var(--accent-deep);
  margin: 0; flex: 0 0 auto; }
.card-dark .reveal { color: rgba(255,255,255,.65); margin: 2px 0 16px; }
/* Náhľad dodacieho listu je HTML, nie vložené PDF — Safari na iPade
   vložené PDF často nezobrazí vôbec a klient by podpisoval naslepo. */
.note-preview { background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 16px; max-height: 46vh; overflow-y: auto; }
.note-preview .nh { display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; border-bottom: 3px solid var(--accent); padding-bottom: 10px; margin-bottom: 12px; }
.note-preview .nh b { font-size: 17px; display: block; }
.note-preview .nh small { color: var(--muted); font-size: 12px; }
.note-preview table { width: 100%; border-collapse: collapse; }
.note-preview th { background: var(--navy); color: #fff; font-size: 10.5px; text-align: left;
  padding: 6px 7px; font-weight: 700; letter-spacing: .4px; }
.note-preview th:last-child, .note-preview td:last-child { text-align: right; }
.note-preview td { font-size: 12.5px; padding: 7px; border-bottom: 1px solid var(--line);
  vertical-align: top; }
.note-preview td .sn { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.note-preview .tot { margin-top: 10px; font-size: 12.5px; font-weight: 700; }

/* ── modal ──────────────────────────────────────────────────────────── */
.sheet-bg { position: fixed; inset: 0; background: rgba(10,18,28,.55); z-index: 60;
  display: grid; place-items: end center; }
.sheet { width: 100%; max-width: var(--shell); background: var(--paper);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 84dvh; overflow-y: auto; animation: rise .22s ease; }
@keyframes rise { from{transform:translateY(24px);opacity:.5} to{transform:none;opacity:1} }
.sheet h3 { margin: 2px 0 12px; font-size: 17px; }
.sheet .opt { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 13px; margin-bottom: 8px; }
.sheet .opt b { font-size: 14px; }
.sheet .opt small { display: block; color: var(--muted); font-size: 12px; }

/* ── toast ──────────────────────────────────────────────────────────── */
#toast { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 18px); z-index: 90; max-width: 92vw; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px;
  font-size: 14px; margin-top: 8px; box-shadow: 0 10px 30px rgba(8,16,26,.35);
  animation: fadeIn .18s ease; }
.toast.ok  { background: var(--ok-ink); }
.toast.err { background: var(--err-ink); }

/* ── spodná navigácia ───────────────────────────────────────────────── */
#tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: var(--shell); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--paper);
  border-top: 1px solid var(--line); display: flex; z-index: 40; }
#tabbar.hidden { display: none; }
.tab { flex: 1; border: 0; background: none; color: var(--muted); font-size: 10.5px;
  font-weight: 600; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--navy); }
.tab.active svg { color: var(--accent-deep); }

/* ── TABLET ─────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  :root { --shell: 900px; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 22px; }
  .tile { min-height: 140px; padding: 20px 18px; }
  .tile .ic { width: 50px; height: 50px; }
  .tile b { font-size: 17px; }
  .home-head { padding: 26px 26px 32px; }
  .home-head h2 { font-size: 30px; }
  .lines { padding: 14px 22px calc(var(--tabbar-h) + 110px);
           display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
  .line { margin-bottom: 0; }
  .line .serials { grid-column: 1 / -1; }
  #scanner { aspect-ratio: 16/10; max-height: 50dvh; }
  .sign-pad { height: 300px; }
  .pdf-frame { height: 64vh; }
  .sheet { border-radius: 20px; margin-bottom: 6vh; }
  .sheet-bg { place-items: center; }
}
@media (min-width: 1100px) {
  :root { --shell: 1040px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
