/* ============ INVENTAR - stilovi (mobile first) ============ */

:root {
  --bg: #0f1216;
  --bg-elev: #171b21;
  --bg-elev-2: #1f242c;
  --line: #2a313b;
  --text: #e8ecf1;
  --text-dim: #98a2b1;
  --accent: #ffb020;
  --accent-ink: #241a03;
  --green: #38c172;
  --red: #f2555a;
  --blue: #4a9dff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --bg-elev: #ffffff;
    --bg-elev-2: #eef1f6;
    --line: #dde3ea;
    --text: #16202b;
    --text-dim: #5d6b7c;
    --accent: #e07b00;
    --accent-ink: #ffffff;
    --shadow: 0 6px 20px rgba(20,30,45,.10);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(72px + var(--safe-b));
  overscroll-behavior-y: contain;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; }
input, select, textarea, button { font: inherit; color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; letter-spacing: -.2px; }
.topbar p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }
.topbar-titles { flex: 1; min-width: 0; }
.topbar-titles h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-back {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; font-size: 18px;
}
.topbar-actions { display: flex; gap: 8px; flex: none; }

/* ---------- Sadrzaj ---------- */
.wrap { padding: 14px 16px 24px; max-width: 900px; margin: 0 auto; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 2px 10px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-dim);
}

/* ---------- Statistika ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.stat {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 10px; text-align: center;
}
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Traka za pretragu ---------- */
.searchbar { position: relative; margin: 4px 0 12px; }
.searchbar input {
  width: 100%; padding: 13px 40px 13px 42px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; outline: none; font-size: 16px;
}
.searchbar input:focus { border-color: var(--accent); }
.searchbar .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }
.searchbar .clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--text-dim); font-size: 20px; padding: 6px 8px; display: none;
}

/* ---------- Lista kutija ---------- */
.box-list { display: grid; gap: 10px; }
.box-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; position: relative;
}
.box-card .thumb {
  width: 62px; height: 62px; flex: none; border-radius: 10px; object-fit: cover;
  background: var(--bg-elev-2); display: grid; place-items: center;
  font-size: 22px; color: var(--text-dim); overflow: hidden;
}
.box-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.box-card .info { flex: 1; min-width: 0; }
.box-card .info h3 { font-size: 16.5px; display: flex; align-items: center; gap: 7px; }
.box-card .info .meta { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.box-card .count {
  flex: none; background: var(--bg-elev-2); border-radius: 20px;
  padding: 5px 11px; font-size: 12.5px; color: var(--text-dim); font-weight: 600;
}

/* ---------- Grid stvari ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.item-card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.item-card .ph {
  aspect-ratio: 1 / 1; background: var(--bg-elev-2);
  display: grid; place-items: center; color: var(--text-dim); font-size: 30px; position: relative;
}
.item-card .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-card .qty {
  position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.65); color: #fff;
  border-radius: 8px; padding: 2px 7px; font-size: 11.5px; font-weight: 700;
}
.item-card .body { padding: 9px 10px 11px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.item-card .name { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.item-card .where { font-size: 12px; color: var(--accent); font-weight: 600; }
.item-card .where.none { color: var(--text-dim); }
.item-card .note { font-size: 12px; color: var(--text-dim); }

/* ---------- Lista stvari u kutiji ---------- */
.item-rows { display: grid; gap: 8px; }
.item-row {
  display: flex; gap: 11px; align-items: center;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 10px;
}
.item-row .ph {
  width: 46px; height: 46px; flex: none; border-radius: 9px; overflow: hidden;
  background: var(--bg-elev-2); display: grid; place-items: center; color: var(--text-dim);
}
.item-row .ph img { width: 100%; height: 100%; object-fit: cover; }
.item-row .info { flex: 1; min-width: 0; }
.item-row .info b { font-weight: 600; font-size: 15px; }
.item-row .info small { display: block; color: var(--text-dim); font-size: 12px; }

/* ---------- Oznake (tagovi) ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 11px; padding: 3px 8px; border-radius: 20px;
  background: var(--bg-elev-2); color: var(--text-dim); border: 1px solid var(--line);
}
.tag.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ---------- Znacke ---------- */
.badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 3px 7px; border-radius: 6px; background: var(--bg-elev-2); color: var(--text-dim);
}
.badge.sealed { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green); }
.badge.open { background: color-mix(in srgb, var(--blue) 20%, transparent); color: var(--blue); }

/* ---------- Dugmad ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); font-weight: 600; cursor: pointer; font-size: 15px;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; }

.fab {
  position: fixed; right: 16px; bottom: calc(80px + var(--safe-b)); z-index: 45;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font-size: 28px; font-weight: 400; box-shadow: var(--shadow); cursor: pointer;
  display: grid; place-items: center; line-height: 1;
}

/* ---------- Donja navigacija ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  display: grid; place-items: center; gap: 3px; padding: 9px 0 8px;
  font-size: 10.5px; color: var(--text-dim);
}
.tab svg { width: 22px; height: 22px; }
.tab.is-active { color: var(--accent); }

/* ---------- Modalni prozor / forme ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-bg.is-open { display: flex; }
.sheet {
  background: var(--bg-elev); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(18px + var(--safe-b));
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow);
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(22px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { font-size: 18px; }
.sheet-close { background: none; border: 0; font-size: 26px; color: var(--text-dim); padding: 0 4px; cursor: pointer; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; font-size: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 74px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.seg { display: flex; gap: 8px; }
.seg label {
  flex: 1; text-align: center; padding: 11px 8px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 14px; font-weight: 600;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--accent); }
.seg label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* ---------- Fotografije ---------- */
.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-thumb {
  width: 76px; height: 76px; border-radius: 11px; overflow: hidden; position: relative;
  background: var(--bg-elev-2); border: 1px solid var(--line);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .del {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.7); color: #fff; border: 0; font-size: 14px; line-height: 1; cursor: pointer;
}
.photo-add {
  width: 76px; height: 76px; border-radius: 11px; border: 1px dashed var(--line);
  background: var(--bg); display: grid; place-items: center; gap: 2px;
  color: var(--text-dim); font-size: 11px; cursor: pointer; text-align: center;
}
.photo-add svg { width: 22px; height: 22px; }
.photo-add.busy { opacity: .5; pointer-events: none; }

.gallery { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.gallery img {
  height: 128px; border-radius: 12px; object-fit: cover; flex: none;
  border: 1px solid var(--line); cursor: zoom-in;
}

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 90;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.lightbox.is-open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ---------- Brzo dodavanje ---------- */
.quick-add {
  display: flex; gap: 8px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 13px; padding: 8px; margin-bottom: 14px;
}
.quick-add input {
  flex: 1; min-width: 0; padding: 11px 12px; font-size: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.quick-add input:focus { border-color: var(--accent); }

/* ---------- Prazno stanje ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--text-dim); }
.empty .big { font-size: 42px; margin-bottom: 10px; }
.empty p { margin: 6px 0 16px; font-size: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translate(-50%, 20px);
  bottom: calc(88px + var(--safe-b)); z-index: 100;
  background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--line);
  padding: 11px 17px; border-radius: 11px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .2s; max-width: 86vw; text-align: center;
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--red); color: var(--red); }

/* ---------- PIN ekran ---------- */
.pin-screen {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; gap: 6px;
}
.pin-logo { font-size: 44px; }
.pin-screen h1 { font-size: 21px; margin-top: 6px; }
.pin-screen .hint { color: var(--text-dim); font-size: 13.5px; margin-bottom: 18px; }
.pin-dots { display: flex; gap: 11px; margin-bottom: 22px; height: 14px; }
.pin-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--bg-elev-2); border: 1px solid var(--line); }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 74px); gap: 12px; }
.pin-pad button {
  height: 68px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-elev); font-size: 24px; font-weight: 500; cursor: pointer;
}
.pin-pad button:active { background: var(--bg-elev-2); }
.pin-pad button.blank { background: none; border: 0; cursor: default; }
.pin-err { color: var(--red); font-size: 13.5px; height: 20px; margin-top: 14px; }
.pin-remember { margin-top: 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dim); }
.pin-remember input { width: 18px; height: 18px; accent-color: var(--accent); }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- Postavke ---------- */
.list-group { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-group a, .list-group button {
  display: flex; width: 100%; text-align: left; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 15px; background: none; border: 0; border-bottom: 1px solid var(--line);
  cursor: pointer; font-size: 15px;
}
.list-group > *:last-child { border-bottom: 0; }
.list-group small { display: block; color: var(--text-dim); font-size: 12.5px; font-weight: 400; margin-top: 2px; }

/* ---------- Stampa naljepnice ---------- */
@media print {
  body { background: #fff; color: #000; padding: 0; }
  .topbar, .tabbar, .fab, .no-print { display: none !important; }
  .label-sheet { page-break-after: always; border: 2px solid #000; }
}
.label-sheet {
  background: #fff; color: #000; border: 2px solid #222; border-radius: 8px;
  padding: 18px; margin-bottom: 16px;
}
.label-sheet h2 { font-size: 38px; line-height: 1.1; margin-bottom: 6px; }
.label-sheet .room { font-size: 19px; font-weight: 700; margin-bottom: 12px; }
.label-sheet ul { margin: 0; padding-left: 20px; font-size: 15px; columns: 2; }
.label-sheet ul li { margin-bottom: 3px; break-inside: avoid; }
