/* =====================================================================
   Vezuv RS · Terenska aplikacija — vizuelni sistem iz mokapa (odjeljak 18.3)
   Fontovi IBM Plex su u /fonts/ (zajednički za aplikaciju i panel).
   ===================================================================== */

:root {
  --bg: #171310;
  --card: #221D17;
  --raised: #2C251D;
  --line: #3C3327;
  --ember: #FF6A2B;
  --ember-dark: #B84E20;
  --amber: #FFB238;
  --ok: #5FA97C;
  --err: #CC4B34;
  --text: #F3ECE0;
  --muted: #C7BCA9;
  --dim: #A69C8C;
  --radius: 14px;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --cond: 'IBM Plex Sans Condensed', 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/IBMPlexSans-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/IBMPlexSans-Medium.ttf') format('truetype'); font-weight: 500 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans Condensed'; src: url('/fonts/IBMPlexSansCondensed-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/IBMPlexMono-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.4; }
body { overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--mono); }

#app { min-height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* ---------- Zaglavlje ---------- */
.top { padding: calc(16px + var(--safe-t)) 20px 14px; border-bottom: 1px solid var(--line); }
.top .row { display: flex; align-items: center; gap: 14px; }
.top h1 { font-family: var(--cond); font-weight: 600; font-size: 24px; margin: 0; line-height: 1.15; }
.top .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.back { background: none; border: 0; padding: 6px; margin-left: -6px; display: flex; color: var(--text); }
.back svg { width: 24px; height: 24px; }

/* ---------- Koraci ---------- */
.steps { display: flex; align-items: center; gap: 5px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--dim); overflow-x: auto; white-space: nowrap; }
.step { display: flex; align-items: center; gap: 6px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--dim); display: grid; place-items: center; font-size: 12px; flex: none; }
.step.active { color: var(--text); }
.step.active .n { background: var(--ember); border-color: var(--ember); color: #fff; }
.step.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done .n svg { width: 13px; height: 13px; }
.step-sep { width: 8px; height: 1.5px; background: var(--line); flex: none; }
.step.done + .step-sep { background: var(--text); }

/* ---------- Sadržaj ---------- */
.content { flex: 1; padding: 16px 20px calc(110px + var(--safe-b)); }
.section-label { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin: 6px 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card { margin-top: 12px; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.err-text { color: var(--err); }
.ok-text { color: var(--ok); }

/* ---------- Dugmad ---------- */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(14px + var(--safe-b)); background: linear-gradient(to top, var(--bg) 70%, transparent); max-width: 560px; margin: 0 auto; }
.btn { width: 100%; border: 0; border-radius: 12px; padding: 15px 18px; font-weight: 600; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--ember); color: #1a0e06; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { background: var(--raised); color: var(--dim); cursor: default; }
.btn.secondary { background: var(--raised); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: none; color: var(--muted); font-weight: 500; padding: 10px; }
.btn + .btn { margin-top: 10px; }
.link { background: none; border: 0; color: var(--amber); padding: 0; text-decoration: underline; font-size: 14px; }

/* ---------- Donja navigacija ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; border-top: 1px solid var(--line); background: var(--bg); padding: 8px 0 calc(8px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.nav button { background: none; border: 0; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; padding: 4px 18px; }
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--ember); }

/* ---------- Značke ---------- */
.badge { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; border: 1.5px solid; }
.badge.grey { color: var(--dim); border-color: var(--line); }
.badge.yellow { color: var(--amber); border-color: var(--amber); }
.badge.green { color: var(--ok); border-color: var(--ok); }
.badge.red { color: var(--err); border-color: var(--err); }

/* ---------- Prijava ---------- */
.login { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 40px 24px calc(28px + var(--safe-b)); }
.logo { display: flex; justify-content: center; margin-bottom: 28px; }
.logo svg { width: 84px; height: 84px; filter: drop-shadow(0 0 22px rgba(255,106,43,.35)); }
.brand { text-align: center; letter-spacing: .28em; font-size: 12px; color: var(--muted); }
.login h1 { font-family: var(--cond); font-weight: 600; font-size: 28px; text-align: center; margin: 10px 0 28px; }
.field-label { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.input { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 17px; outline: none; }
.input:focus { border-color: var(--ember); }
.pin { position: relative; display: grid; grid-template-columns: repeat(var(--pin-n, 4), 1fr); gap: 10px; margin-bottom: 22px; }
.pin .box { height: 56px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; }
.pin .box.filled::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--ember); }
.pin .box.cursor { border-color: var(--ember); }
.pin input { position: absolute; inset: 0; opacity: 0; font-size: 16px; caret-color: transparent; }
.who { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 22px; }
.form-msg { min-height: 22px; font-size: 14px; color: var(--err); text-align: center; margin: 4px 0 12px; }
.hint { text-align: center; color: var(--dim); font-size: 13px; margin-top: 14px; }

/* ---------- Ruta ---------- */
.hello { padding: calc(20px + var(--safe-t)) 20px 16px; border-bottom: 1px solid var(--line); }
.hello .greet { color: var(--muted); font-size: 15px; }
.hello h1 { font-family: var(--cond); font-weight: 600; font-size: 26px; margin: 2px 0 12px; }
.hello .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.hello .meta svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.progress { height: 6px; background: var(--raised); border-radius: 6px; margin-top: 10px; overflow: hidden; }
.progress div { height: 100%; background: var(--ember); border-radius: 6px; transition: width .3s; }
.loc { display: block; width: 100%; text-align: left; padding: 0; color: inherit; }
.loc .main { display: flex; gap: 14px; align-items: center; padding: 16px; }
.loc .ico { width: 42px; height: 42px; border-radius: 10px; background: var(--raised); display: grid; place-items: center; flex: none; color: var(--muted); }
.loc .ico svg { width: 20px; height: 20px; }
.loc .txt { flex: 1; min-width: 0; }
.loc .name { font-weight: 600; font-size: 16px; }
.loc .addr { color: var(--dim); font-size: 13px; margin: 2px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc .chev { color: var(--dim); }
.loc .chev svg { width: 20px; height: 20px; }
.card > .foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 12px 16px; font-size: 14px; color: var(--muted); }

/* ---------- Dolazak ---------- */
.arrive { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-height: 52vh; text-align: center; }
.shield { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--ok); background: rgba(95,169,124,.08); color: var(--ok); margin-bottom: 16px; }
.shield.warn { border-color: var(--amber); background: rgba(255,178,56,.08); color: var(--amber); }
.shield.idle { border-color: var(--line); background: var(--card); color: var(--muted); }
.shield svg { width: 30px; height: 30px; }
.arrive h2 { font-weight: 500; font-size: 19px; margin: 0 0 6px; }
.kv { width: 100%; margin-top: 18px; padding: 14px 18px; font-family: var(--mono); font-size: 14px; }
.kv .r { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.kv .k { color: var(--dim); }
.kv .v { text-align: right; }

/* ---------- Kontrolna lista ---------- */
.counter { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.cat { color: var(--amber); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin: 20px 0 10px; }
.cat:first-child { margin-top: 4px; }
.item { padding: 14px; }
.item + .item { margin-top: 10px; }
.item .q { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.item .q span { flex: 1; }
.item .cam { background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 7px; display: flex; color: var(--muted); position: relative; }
.item .cam svg { width: 20px; height: 20px; }
.item .cam.req { border-color: var(--amber); color: var(--amber); }
.item .cam .cnt { position: absolute; top: -7px; right: -7px; background: var(--ok); color: #fff; font-size: 11px; border-radius: 9px; min-width: 18px; height: 18px; display: grid; place-items: center; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice { background: var(--raised); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--dim); }
.choice svg { width: 18px; height: 18px; }
.choice.on.ok { border-color: var(--ok); color: var(--ok); background: rgba(95,169,124,.1); }
.choice.on.flag { border-color: var(--err); color: var(--err); background: rgba(204,75,52,.1); }
.choice.on.na { border-color: var(--muted); color: var(--text); }
.note { width: 100%; margin-top: 10px; background: var(--bg); border: 1px solid var(--err); border-radius: 10px; padding: 10px 12px; min-height: 64px; resize: vertical; font-size: 15px; outline: none; }
.note.okline { border-color: var(--line); }
.item.missing { border-color: var(--amber); }

/* ---------- Fotografije ---------- */
.ph-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ph-grid.three { grid-template-columns: repeat(3, 1fr); }
.ph-title { font-weight: 500; }
.ph-sub { color: var(--dim); font-size: 13px; margin: 2px 0 10px; }
.ph-grid:not(.three) .ph-sub { min-height: 2.8em; }
.tile { position: relative; aspect-ratio: 3/4; border-radius: 12px; border: 1px solid var(--line); background: var(--card) center/cover no-repeat; overflow: hidden; display: block; width: 100%; padding: 0; color: var(--muted); }
.tile.empty { border-style: dashed; display: grid; place-items: center; }
.tile.empty .plus { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; }
.tile.required { border-color: var(--amber); color: var(--amber); }
.tile svg { width: 24px; height: 24px; }
.tile .cap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; font-family: var(--mono); font-size: 11px; color: var(--text); background: linear-gradient(transparent, rgba(0,0,0,.75)); text-align: left; }
.tile .state { position: absolute; top: 8px; right: 8px; font-size: 11px; padding: 3px 7px; border-radius: 8px; background: rgba(0,0,0,.6); }
.tile .state.pending { color: var(--amber); }
.tile .state.failed { color: var(--err); }
.reports-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 26px; }

/* ---------- Pregled ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin: 10px 0 4px; }
.stats b { display: block; font-size: 26px; font-weight: 600; }
.stats span { font-size: 12px; color: var(--dim); }
.issue { display: flex; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.issue svg { width: 18px; height: 18px; color: var(--err); flex: none; margin-top: 2px; }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.thumbs div { aspect-ratio: 1; border-radius: 8px; background: var(--raised) center/cover; border: 1px solid var(--line); }
.iline { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 15px; }
.iline + .iline { margin-top: 6px; }
.iline svg { width: 16px; height: 16px; }
textarea.input { min-height: 80px; resize: vertical; font-size: 15px; }

/* ---------- Potvrda ---------- */
.stamp { width: 200px; height: 200px; border-radius: 50%; border: 2.5px dashed var(--ok); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ok); text-align: center; font-family: var(--mono); letter-spacing: .14em; font-size: 13px; transform: rotate(-8deg); margin: 40px auto 30px; }
.stamp.wait { border-color: var(--amber); color: var(--amber); }
.stamp svg { width: 28px; height: 28px; margin-bottom: 8px; }
.confirm h2 { font-family: var(--cond); font-weight: 600; font-size: 24px; text-align: center; margin: 0 0 6px; }

/* ---------- Istorija ---------- */
.hist .xtra { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 12px 16px; font-family: var(--mono); font-size: 13px; }

/* ---------- Trake i obavještenja ---------- */
.banner { padding: 10px 20px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.banner svg { width: 16px; height: 16px; flex: none; }
.banner.offline { background: rgba(255,178,56,.12); color: var(--amber); border-bottom: 1px solid rgba(255,178,56,.3); }
.banner.queue { background: rgba(95,169,124,.1); color: var(--ok); border-bottom: 1px solid rgba(95,169,124,.25); }
.banner.error { background: rgba(204,75,52,.12); color: var(--err); border-bottom: 1px solid rgba(204,75,52,.3); }
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--raised); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 40px); z-index: 60; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty-state { text-align: center; color: var(--muted); padding: 50px 10px; }
.empty-state svg { width: 40px; height: 40px; color: var(--dim); margin-bottom: 10px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ember); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Kamera i modalni prozori ---------- */
#overlay:empty { display: none; }
.camera { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.camera .cam-top { padding: calc(14px + var(--safe-t)) 16px 12px; display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,.6); }
.camera .cam-top .t { flex: 1; }
.camera .cam-top .t b { display: block; }
.camera .cam-top .t span { font-size: 13px; color: var(--muted); }
.camera .view { flex: 1; position: relative; overflow: hidden; }
.camera video, .camera img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.camera .cam-bottom { padding: 18px 20px calc(22px + var(--safe-b)); display: flex; justify-content: center; align-items: center; gap: 14px; background: rgba(0,0,0,.6); }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.15); }
.shutter:active { background: rgba(255,255,255,.5); }
.camera .cam-bottom .btn { width: auto; flex: 1; white-space: nowrap; }
.cam-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--text); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--card); border-radius: 18px 18px 0 0; padding: 20px 20px calc(20px + var(--safe-b)); border-top: 1px solid var(--line); }
.sheet h3 { margin: 0 0 6px; font-family: var(--cond); font-weight: 600; font-size: 20px; }
.sheet p { color: var(--muted); margin: 0 0 16px; }
.sheet .opt { display: block; width: 100%; text-align: left; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 8px; }
