/* Raspored: zaglavlje sa statusom sinhronizacije, traka sa brojevima, filter po lokaciji, pretraga, pa mreža kartica sa fotografijama. */
:root {
  --bg: #edf0f5;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --ink: #151a23;
  --muted: #566074;
  --line: #d6dbe4;
  --accent: #2646d6;
  --accent-ink: #ffffff;
  --ok: #1c7745;
  --warn: #9a5700;
  --warn-bg: #fbecd3;
  --crit: #b82d2d;
  --shadow: 0 1px 2px rgba(20, 28, 44, .07);
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --surface: #19202a; --surface-2: #202835; --ink: #e9edf3; --muted: #9ba5b5;
    --line: #2d3644; --accent: #8ea2ff; --accent-ink: #0f1530;
    --ok: #62d08c; --warn: #f0b358; --warn-bg: #3a2c14; --crit: #ff857d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151c; --surface: #19202a; --surface-2: #202835; --ink: #e9edf3; --muted: #9ba5b5;
  --line: #2d3644; --accent: #8ea2ff; --accent-ink: #0f1530;
  --ok: #62d08c; --warn: #f0b358; --warn-bg: #3a2c14; --crit: #ff857d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 1120px; margin: 0 auto;
  padding-top: max(20px, env(safe-area-inset-top, 0px));
  padding-bottom: max(48px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 16px;
}

/* zaglavlje */
.top { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; justify-content: space-between; }
.top h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.top p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--muted); padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync[data-s="ok"] i { background: var(--ok); }
.sync[data-s="wait"] i { background: var(--warn); }
.sync[data-s="off"] i { background: var(--crit); }
.btn { min-height: 40px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.danger.armed { background: var(--crit); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* brojevi */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.stat { padding: 12px 16px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { display: block; font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* lokacije */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { flex: none; display: inline-flex; gap: 8px; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap; }
.chip small { font-family: var(--f-mono); font-size: .75rem; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .85; }

/* filteri */
.tools { display: grid; grid-template-columns: minmax(0, 1fr) repeat(2, minmax(0, 12rem)); gap: 8px; }
.tools input, .tools select { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }

/* kartice */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.card { all: unset; box-sizing: border-box; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; box-shadow: var(--shadow); min-width: 0; }
.card:hover { border-color: var(--accent); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.media { position: relative; aspect-ratio: 4 / 3; max-width: 100%; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media .ph { font-size: 2.2rem; font-weight: 700; color: var(--muted); opacity: .45; }
.qty { position: absolute; top: 8px; right: 8px; min-width: 28px; padding: 2px 8px; border-radius: 999px; background: rgba(15, 20, 30, .78); color: #fff; font-size: .78rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.pend { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-size: .72rem; font-weight: 600; }
.info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.info b { font-weight: 650; overflow-wrap: anywhere; }
.info .meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.info .det { font-size: .8rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.empty { grid-column: 1 / -1; padding: 40px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.empty strong { color: var(--ink); font-size: 1.1rem; }
.empty p { margin: 0; max-width: 48ch; }

.foot { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; }
.foot p { margin: 0; font-size: .8rem; color: var(--muted); max-width: 60ch; }
.foot-actions { display: flex; gap: 16px; }

/* prijava */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 1.4rem; }
.lead { margin: -6px 0 0; color: var(--muted); }

/* obrazac */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 22, .55); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.sheet { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-block: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { margin: 0; font-size: 1.25rem; }
.sheet .meta { font-family: var(--f-mono); font-size: .78rem; color: var(--muted); margin-top: -8px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld label { font-size: .8rem; font-weight: 600; }
.fld input, .fld select, .fld textarea { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.fld textarea { min-height: 84px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { color: var(--crit); font-size: .85rem; margin: 0; min-height: 1.2em; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.btns .spacer { margin-right: auto; }
.photo-box { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.photo-prev { width: 132px; aspect-ratio: 4 / 3; border-radius: 10px; border: 1px dashed var(--line); background: var(--surface-2); padding: 0; overflow: hidden; cursor: pointer; display: grid; place-items: center; color: var(--muted); font-size: .78rem; text-align: center; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-actions { display: flex; flex-direction: column; gap: 8px; justify-content: center; }

.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(5, 8, 14, .92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 8px; }
.lightbox p { margin: 0; color: #cfd6e4; font-size: .9rem; min-height: 1.2em; text-align: center; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 50; max-width: calc(100% - 32px); }

@media (max-width: 720px) {
  .tools { grid-template-columns: 1fr 1fr; }
  .tools input { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .two { grid-template-columns: 1fr; }
  .top h1 { font-size: 1.4rem; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
