:root {
  --bg: #f1f3f0; --card: #fff; --ink: #161a1d; --muted: #2f373d; --line: #aab2ac;
  --accent: #0b7285; --accent-ink: #fff; --danger: #c92a2a;
  --s-zaklad: #1f6b2e; --s-klient: #b63a08; --s-transport: #14528c; --s-zwrocony: #4d555c;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 125%; }
html.xl { font-size: 150%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 0.9375rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); } .center { text-align: center; } .small { font-size: 0.9375rem; }
.num { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .02em; }

#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px;
  background: var(--accent); color: #fff; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
}
#top[hidden], #nav[hidden], #offline[hidden], [hidden] { display: none !important; }
#top h1 { font-size: 1.125rem; font-weight: 650; padding-left: 4px; }
.icon-btn { background: none; border: 0; color: inherit; padding: 6px; margin: -6px 0; border-radius: 10px; }
#offline { background: #fff3bf; color: #5f3f00; padding: 8px 14px; font-size: 0.9375rem; text-align: center; }

main { max-width: 640px; margin: 0 auto; padding: 12px 12px calc(130px + env(safe-area-inset-bottom)); }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around; align-items: flex-end;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; font-size: 0.9375rem; color: var(--muted); text-decoration: none; }
#nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#nav a.on { color: var(--accent); font-weight: 650; }
#nav .nav-scan svg { width: 54px; height: 54px; padding: 13px; margin-top: -26px; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(11,114,133,.4); border: 3px solid var(--card); }
#nav .nav-scan { color: var(--accent); font-weight: 650; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 60px;
  border: 2px solid #4a545b; background: var(--card); color: var(--ink); border-radius: 12px;
  font: inherit; font-weight: 700; padding: 10px 14px; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 76px; font-size: 1.125rem; }
.btn:disabled { opacity: .55; }
.btn.sm { min-height: 48px; width: auto; font-size: 0.9375rem; padding: 6px 12px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; min-width: 0; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

label { display: block; color: var(--ink) !important; font-size: 0.9375rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: 58px; border: 2px solid #4a545b; border-radius: 10px; background: #fff; color: var(--ink);
  font: inherit; padding: 10px 12px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid rgba(11,114,133,.35); outline-offset: 1px; }
.field { margin-bottom: 12px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); }
.tile b { display: block; font-size: 1.875rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { font-size: 0.9375rem; color: var(--muted); }
.c-ZAKLAD { --c: var(--s-zaklad); } .c-KLIENT { --c: var(--s-klient); } .c-TRANSPORT { --c: var(--s-transport); } .c-ZWROCONY { --c: var(--s-zwrocony); } .c-OVERDUE { --c: var(--danger); }

.chip { display: inline-block; font-size: 0.9375rem; font-weight: 700; padding: 5px 11px; border-radius: 99px; color: #fff; background: var(--c); white-space: nowrap; }
.chip.late { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 14px; font: inherit; font-size: 0.9375rem; color: var(--ink); }
.filters button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.rack { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.rack .th { flex: none; width: 76px; height: 76px; border-radius: 10px; background: #e6eae5 center/cover; display: grid; place-items: center; color: #9aa39b; font-size: 1.375rem; }
.rack .info { flex: 1; min-width: 0; }
.rack .num { font-size: 1.125rem; display: block; }
.rack .sub { font-size: 0.9375rem; color: var(--muted); overflow-wrap: anywhere; }
.rack .side { text-align: right; flex: none; }
.rack .days { display: block; font-size: 0.9375rem; color: var(--muted); margin-top: 4px; }
.rack .days.late { color: var(--danger); font-weight: 700; }

.banner { background: #e3fafc; border: 1px solid #99e9f2; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.banner.warn { background: #fff5f5; border-color: #ffc9c9; }

.cam { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 52vh; width: 100%; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .frame { position: absolute; left: 8%; right: 8%; top: 32%; height: 36%; border: 3px solid rgba(255,255,255,.9); border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.cam .frame::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff6b6b; opacity: .8; }
.cam .cam-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px; color: #fff; font-size: 0.9375rem; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.cands { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cands button { border: 1px solid var(--accent); color: var(--accent); background: #fff; border-radius: 10px; padding: 8px 12px; font: inherit; }

.photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.photos img { flex: none; width: 130px; height: 130px; object-fit: cover; border-radius: 10px; background: #e6eae5; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--muted)); border: 2px solid var(--card); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline .when { font-size: 0.9375rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { font-size: 0.9375rem; color: var(--muted); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }

dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92vh; border-radius: 18px 18px 0 0; background: var(--card); color: var(--ink); }
dialog.sheet::backdrop { background: rgba(0,0,0,.5); }
.sheet-body { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet-body h3 { font-size: 1.1875rem; margin-bottom: 12px; }
dialog.viewer { border: 0; padding: 0; background: #000; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
dialog.viewer img { width: 100%; height: 100%; object-fit: contain; }

#toast { position: fixed; left: 12px; right: 12px; bottom: calc(120px + env(safe-area-inset-bottom)); z-index: 2147483647; display: grid; justify-items: center; pointer-events: none; }
#toast div { background: #212529; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 0.9375rem; max-width: 520px; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
#toast div.err { background: var(--danger); }
.login { max-width: 420px; margin: 8vh auto 0; }
.login .logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 14px; }

/* galeria stojaków bez numeru — duże zdjęcia do wskazania palcem */
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery button { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px; border: 2px solid #4a545b; border-radius: 12px; background: #fff; font: inherit; color: var(--ink); text-align: left; }
.gallery img, .gallery .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #e6eae5; display: grid; place-items: center; color: var(--muted); }
#nav a { color: var(--ink); }
.tile b { font-size: 2.1rem; }

/* ---------- komputer w biurze: menu z boku, szeroka tabela nadzoru ---------- */
table.wide th, table.wide td { text-align: left; padding: 10px 12px; vertical-align: middle; }
table.wide th { position: sticky; top: 0; background: #e6eae5; }
table.wide th button { background: none; border: 0; font: inherit; font-weight: 700; color: var(--ink); padding: 4px 0; cursor: pointer; white-space: nowrap; }
table.wide tr[data-id] { cursor: pointer; }
table.wide tr[data-id]:hover { background: #eef6f7; }
table.wide tr.late td { background: #fff1f1; }
table.wide img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; display: block; }
@media (min-width: 900px) {
  html { font-size: 112.5%; }
  html.xl { font-size: 135%; }
  #top { padding-left: 24px; }
  #nav { top: 0; bottom: 0; right: auto; width: 230px; flex-direction: column; justify-content: flex-start; align-items: stretch;
    gap: 6px; padding: 84px 12px 12px; border-top: 0; border-right: 2px solid var(--line); z-index: 4; }
  #nav a { flex: none; flex-direction: row; gap: 12px; padding: 14px 14px; font-size: 1.05rem; border-radius: 12px; }
  #nav a.on { background: #e3f1f3; }
  #nav .nav-scan svg { width: 24px; height: 24px; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; color: inherit; box-shadow: none; }
  main { max-width: 1280px; margin-left: 230px; padding: 20px 28px 60px; }
  main > .card, main > .stack, main > .tiles, main > .banner, main > h2, main > p, main > .field, main > .filters, main > .cam { max-width: 760px; }
  #list { max-width: none; }
  .tiles { grid-template-columns: repeat(4, 1fr); max-width: 1000px !important; }
  dialog.sheet { margin: auto; border-radius: 18px; max-width: 560px; }
  #toast { left: 230px; bottom: 30px; }
  .cam { max-width: 480px !important; }
}
table.wide .num, table.wide td:nth-child(7), table.wide td:nth-child(8) { white-space: nowrap; }

/* ---------- typy stojaków ---------- */
.kind-svg { width: 100%; max-width: 96px; height: auto; display: block; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.kind-svg .g { fill: #bfe8ee; stroke: #2a7f90; stroke-width: 1.5; }
.m-STAL { color: #37444f; } .m-DREWNO { color: #96541a; }
.picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 560px) { .picks { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.picks.two { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
.pick { margin: 0; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick > span { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; padding: 10px 6px; border: 2px solid #4a545b; border-radius: 12px; background: #fff; text-align: center; }
.pick b { font-size: 0.9375rem; color: var(--ink); line-height: 1.2; } .pick small { font-size: 0.8rem; color: var(--muted); font-weight: 400; line-height: 1.2; }
.pick input:checked + span { border: 4px solid var(--accent); background: #e3f1f3; padding: 8px 4px; }
.pick input:focus-visible + span { outline: 3px solid rgba(11,114,133,.45); outline-offset: 2px; }
.picks.two .pick > span { flex-direction: row; justify-content: center; gap: 10px; min-height: 60px; }
.swatch { width: 28px; height: 28px; border-radius: 6px; border: 2px solid #333; flex: none; }
.sw-STAL { background: linear-gradient(135deg, #cfd6dc, #7d8a95); } .sw-DREWNO { background: repeating-linear-gradient(90deg, #c98b4a 0 6px, #a86a2c 6px 9px); }
.rack .th .kind-svg { width: 80%; }
.kindline { display: flex; align-items: center; gap: 10px; margin-top: 6px; } .kindline .kind-svg { width: 64px; }

.kind-img { width: 100%; max-width: 120px; height: 84px; object-fit: contain; display: block; margin: 0 auto; }
.rack .th .kind-img { width: 90%; height: 90%; max-width: none; }
.kindline .kind-img { width: 96px; height: 72px; flex: none; }
.picks.three { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
.picks.three .pick > span { min-height: 64px; justify-content: flex-start; }
.picks.three .rng { display: flex; flex-direction: column; font-size: 0.72rem; line-height: 1.4; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.picks.three .rng span { white-space: nowrap; }
.picks.three .rng:empty { display: none; }
.picks.three b { font-size: 1.3rem; }
.dims small, .secs small { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 2px; }
.dims .row { gap: 8px; }

/* ---------- wzornik typów ---------- */
.pick > span { position: relative; }
.wzor { position: absolute; top: 6px; right: 6px; border: 2px solid var(--accent); background: #fff; color: var(--accent); border-radius: 99px;
  font: inherit; font-size: 0.8rem; font-weight: 700; padding: 2px 9px; min-height: 30px; }
.gal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 6px; }
@media (min-width: 640px) { .gal { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.gitem { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 2px solid #4a545b; border-radius: 12px; background: #fff; font: inherit; color: var(--ink); text-align: center; cursor: pointer; }
.gitem img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #f6f7f9; border-radius: 8px; }
.gitem.own img { object-fit: cover; }
.gitem span { font-size: 0.8rem; line-height: 1.2; font-weight: 600; }
.gitem.own { border-color: var(--accent); }
.thead { display: flex; gap: 12px; align-items: center; }
.tletter { width: 52px; height: 52px; flex: none; border-radius: 10px; background: #0a2a5e; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.7rem; }
.tcard { margin-bottom: 14px; }
table.sizes-t th, table.sizes-t td { text-align: left; }
dialog.viewer { background: #111; }
.vwrap { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; }
.vscroll { flex: 1; min-height: 0; overflow: auto; background: #fff; -webkit-overflow-scrolling: touch; }
.vscroll img { display: block; width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.vscroll img.zoomed { width: 250%; height: auto; max-width: none; cursor: zoom-out; }
.vscroll img.drawing:not(.zoomed) { padding: 8px; }
.vhint { margin: 0; padding: 6px 8px 0; background: #111; color: #fff; text-align: center; font-size: 0.9rem; }
.vbar { display: flex; align-items: center; gap: 8px; padding: 8px; background: #111; color: #fff; }
.vcap { flex: 1; text-align: center; font-size: 0.95rem; }
.vbtn { width: 56px; height: 56px; border-radius: 12px; border: 2px solid #fff; background: none; color: #fff; font-size: 2rem; line-height: 1; }
.vact { padding: 0 8px 10px; background: #111; } .vact:empty { display: none; }
.vclose { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.65); color: #fff; font-size: 1.5rem; }

table.sizes-t { font-size: 0.8rem; letter-spacing: -0.01em; } table.sizes-t th, table.sizes-t td { padding: 7px 3px; } table.sizes-t td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sizeboxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.sizebox { border: 2px solid #4a545b; border-radius: 12px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.sizebox b { font-size: 1.3rem; } .sizebox small { font-size: 0.8rem; color: var(--muted); }
.sizebox .rng { display: flex; flex-direction: column; font-size: 0.72rem; line-height: 1.4; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sizebox .rng span { white-space: nowrap; }

/* mała stopka z informacją o twórcy */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
@media (min-width: 900px) { body > main { width: auto; } }
.credit { text-align: center; color: var(--muted); font-size: 0.7rem; padding: 0 12px calc(118px + env(safe-area-inset-bottom)); margin-top: -110px; }
@media (min-width: 900px) { .credit { margin: -40px 0 0 230px; padding-bottom: 16px; } }

/* logo firmy */
.firm-logo { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 18px; }
.firm-logo.home { max-width: 240px; margin: 4px auto 16px; }
.login .logo { width: 64px; height: 64px; margin-bottom: 8px; }
.nav-logo { display: none; }
@media (min-width: 900px) {
  .nav-logo { display: block; width: 100%; height: auto; margin: -12px 0 14px; padding: 4px; background: #fff; border-radius: 8px; }
  .firm-logo.home { display: none; }
}
.credit a { color: inherit; }
