/* =========================================================
   IMG prijava kvarova — stilovi (svijetla + tamna tema)
   ========================================================= */
:root {
  --brand-1: #2c2c7d;
  --brand-2: #2367ab;
  --brand-3: #1c94ce;
  --brand-4: #1fb1e2;
  --brand-5: #29235c;
  --accent: #fdc40a;

  --bg: #eef2f9;
  --bg-grad-1: #e7eefb;
  --bg-grad-2: #f3f6fc;
  --surface: #ffffff;
  --surface-2: #f5f8fd;
  --surface-3: #eef3fb;
  --ink: #16203a;
  --muted: #5e6b86;
  --line: #dfe6f1;
  --line-strong: #c9d5e8;

  --primary: #2367ab;
  --primary-ink: #ffffff;
  --primary-soft: #e7f0fb;

  --ok: #1f9d57;
  --ok-soft: #e4f6ec;
  /* Fiksna (ne tema-zavisna) — --ok postane presvijetla za grafikone u tamnoj temi
     (ne prolazi dataviz lightness-band provjeru); ova vrijednost prolazi u oba moda. */
  --chart-resolved: #1f9d57;
  --warn: #d8731a;
  --warn-soft: #fdeedd;
  --danger: #d23b3b;
  --danger-soft: #fbe6e6;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow-sm: 0 4px 14px rgba(22, 45, 86, 0.08);
  --shadow: 0 14px 34px rgba(22, 45, 86, 0.12);
  --shadow-lg: 0 26px 60px rgba(16, 32, 70, 0.20);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #05070f;
  --bg-grad-1: #080c1c;
  --bg-grad-2: #04050c;
  --surface: #0d1124;
  --surface-2: #131830;
  --surface-3: #19203c;
  --ink: #e9eefb;
  --muted: #8e9ac0;
  --line: #20274a;
  --line-strong: #2c365f;

  --primary: #3d8fe0;
  --primary-ink: #04101f;
  --primary-soft: #16213f;

  --ok: #3fd089;
  --ok-soft: #15351f;
  --warn: #f0a44a;
  --warn-soft: #3a2a13;
  --danger: #ff6b6b;
  --danger-soft: #3a1a1f;

  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 26px 60px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 15% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s var(--ease), color 0.3s var(--ease);
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 14px;
  font-weight: 700; font-size: 1rem; letter-spacing: 0.01em;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s, opacity 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-block + .btn-block { margin-top: 12px; }
.btn-primary {
  color: var(--primary-ink);
  background: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  box-shadow: 0 12px 26px rgba(35, 103, 171, 0.35);
}
[data-theme="dark"] .btn-primary { background: linear-gradient(135deg, #2f7fd0, #1c94ce); }
.btn-primary:hover { box-shadow: 0 16px 30px rgba(35, 103, 171, 0.45); }
.btn-primary:disabled { opacity: 0.5; box-shadow: none; cursor: not-allowed; }
.btn-ghost {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--surface-3); }
.btn-ok { color: #fff; background: linear-gradient(135deg, var(--ok), #18935a); box-shadow: 0 10px 22px rgba(31, 157, 87, 0.3); }
[data-theme="dark"] .btn-ok { color: #06210f; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-grid; place-items: center; color: var(--ink);
  transition: background-color 0.2s, transform 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 46px; height: 46px; border-radius: 50%;
  display: inline-grid; place-items: center; position: relative;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background-color 0.25s, transform 0.3s var(--ease);
}
.theme-toggle:active { transform: rotate(40deg) scale(0.9); }
.theme-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; position: absolute; transition: opacity 0.3s, transform 0.4s var(--ease); }
.theme-toggle .ic-moon { color: var(--brand-3); }
.theme-toggle .ic-sun { color: var(--accent); }
[data-theme="light"] .theme-toggle .ic-moon { opacity: 0; transform: rotate(-90deg) scale(0.4); }
[data-theme="light"] .theme-toggle .ic-sun { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .theme-toggle .ic-sun { opacity: 0; transform: rotate(90deg) scale(0.4); }
[data-theme="dark"] .theme-toggle .ic-moon { opacity: 1; transform: rotate(0) scale(1); }
.theme-toggle.floating { position: fixed; top: calc(env(safe-area-inset-top, 0) + 16px); right: 16px; z-index: 6; }

/* =========================================================
   LOGIN
   ========================================================= */
.login-view {
  min-height: 100dvh; display: grid; place-items: center;
  padding: 24px; position: relative; overflow: hidden;
}
/* Globalna animirana pozadina — vidljiva kroz cijelu aplikaciju */
.app-backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.app-backdrop .blob { position: fixed; border-radius: 50%; filter: blur(70px); opacity: 0.5; animation: float 16s var(--ease) infinite; }
.app-backdrop .b1 { width: 380px; height: 380px; left: -90px; top: -70px; background: var(--brand-3); }
.app-backdrop .b2 { width: 320px; height: 320px; right: -80px; top: 16%; background: var(--brand-1); animation-delay: -4s; }
.app-backdrop .b3 { width: 340px; height: 340px; left: 20%; bottom: -140px; background: var(--accent); opacity: 0.32; animation-delay: -8s; }
[data-theme="dark"] .app-backdrop .blob { opacity: 0.42; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(24px, -22px) scale(1.08); }
  66% { transform: translate(-18px, 18px) scale(0.96); }
}

.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 400px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 34px 28px 26px;
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.6s var(--ease) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }

.login-logo { display: block; height: 58px; margin: 0 auto 18px; }
.login-title { text-align: center; margin: 0; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.login-sub { text-align: center; margin: 6px 0 24px; color: var(--muted); }
.login-foot { text-align: center; color: var(--muted); font-size: 0.78rem; margin: 22px 0 0; letter-spacing: 0.04em; }

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span, .field-label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.field em { color: var(--danger); font-style: normal; }

input[type="text"], input[type="search"], input[type="password"], textarea, select {
  width: 100%; min-height: 52px; padding: 13px 15px;
  background: var(--surface-2); border: 1.5px solid var(--line);
  border-radius: 14px; color: var(--ink); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
  background: var(--surface);
}
select { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%235e6b86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }

.email-group, .pass-group { position: relative; display: flex; align-items: stretch; }
.email-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }
.email-suffix {
  display: inline-flex; align-items: center; padding: 0 15px;
  background: var(--surface-3); border: 1.5px solid var(--line); border-left: 0;
  border-radius: 0 14px 14px 0; color: var(--muted); font-weight: 700; white-space: nowrap;
}
.email-group input:focus + .email-suffix { border-color: var(--primary); }
.pass-group input { padding-right: 50px; }
.pass-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); border-radius: 10px; }
.pass-eye svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pass-eye.active { color: var(--primary); }

.form-error { color: var(--danger); font-size: 0.86rem; font-weight: 600; margin: 0 0 12px; min-height: 1.1em; }
.form-error.shake { animation: shake 0.4s; }
@keyframes shake { 0%,100%{transform:translateX(0);} 20%,60%{transform:translateX(-7px);} 40%,80%{transform:translateX(7px);} }

/* =========================================================
   APP SHELL
   ========================================================= */
.app-view { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0) + 10px) 14px 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-logo { height: 30px; }
.topbar-spacer { flex: 1; }
.back-btn[hidden] { display: none; }

/* ---------- Menu sheet ---------- */
.menu-scrim { position: fixed; inset: 0; z-index: 8; background: rgba(8, 14, 34, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fade 0.25s var(--ease); }
.menu-sheet {
  position: fixed; z-index: 9; top: 0; right: 0; height: 100dvh; width: min(86vw, 330px);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg); padding: calc(env(safe-area-inset-top, 0) + 22px) 18px 22px;
  display: flex; flex-direction: column; gap: 6px;
  animation: slideIn 0.3s var(--ease);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.menu-sheet.closing { animation: slideOut 0.25s var(--ease) forwards; }
@keyframes slideOut { to { transform: translateX(100%); } }

.menu-user { display: flex; align-items: center; gap: 12px; padding: 8px 8px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.menu-user strong { display: block; font-size: 0.95rem; word-break: break-all; }
.avatar { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand-1)); text-transform: uppercase; }
.role-pill { display: inline-block; margin-top: 4px; font-size: 0.72rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; }

.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 14px; border-radius: 14px; font-weight: 600; color: var(--ink);
  transition: background-color 0.18s, transform 0.12s var(--ease);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item:active { transform: scale(0.98); }
.menu-item svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-item.danger { color: var(--danger); margin-top: auto; }

/* =========================================================
   VIEWS / WIZARD
   ========================================================= */
.screen { flex: 1; position: relative; }
.view { display: none; }
.view.active { display: block; animation: viewIn 0.42s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.view.back.active { animation: viewInBack 0.42s var(--ease); }
@keyframes viewInBack { from { opacity: 0; transform: translateX(-22px); } to { opacity: 1; transform: none; } }

.view-inner { width: 100%; max-width: 720px; margin: 0 auto; padding: 22px 18px calc(env(safe-area-inset-bottom, 0) + 40px); }
.step-eyebrow { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); margin: 6px 0 6px; }
.view-title { margin: 0; font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; }
.view-lead { color: var(--muted); margin: 8px 0 22px; }
.hint { background: var(--primary-soft); color: var(--primary); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.88rem; font-weight: 600; margin: 0 0 16px; }
.hint b { font-weight: 800; }
.subhead { margin: 26px 0 12px; font-size: 1.05rem; }

/* ---------- Choice cards (step 1) ---------- */
/* Step 1: naslov pri vrhu (centriran), dugmad u sredini ekrana */
.step1-inner { min-height: calc(100dvh - 84px); display: flex; flex-direction: column; padding-top: 18px; }
.step1-title { text-align: center; margin: 6px 0 0; }
.step1-inner .choice-grid { margin: auto 0; }

.choice-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 8px; }
.choice-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 32px 20px; border-radius: var(--radius); text-align: center;
  background: var(--surface); border: 1.5px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s;
}
.choice-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--primary); }
.choice-card:active { transform: translateY(-1px) scale(0.99); }
.choice-card strong {
  font-size: clamp(2rem, 8vw, 2.6rem); font-weight: 900; letter-spacing: 0.06em;
  line-height: 1; text-transform: uppercase;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--brand-2);
}
.choice-card small { color: var(--muted); line-height: 1.45; font-size: 0.92rem; max-width: 34ch; }

/* ---------- City tabs ---------- */
.city-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }
.city-tab {
  padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 0.92rem;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink);
  transition: all 0.2s var(--ease);
}
.city-tab.active { background: linear-gradient(135deg, var(--brand-2), var(--brand-3)); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(35, 103, 171, 0.32); }
.city-tab:active { transform: scale(0.96); }

/* ---------- Search ---------- */
.search-wrap { position: relative; margin: 6px 0 10px; }
.search-wrap .search-ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.search-wrap input { padding-left: 44px; padding-right: 42px; }
.clear-search { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; font-size: 1.4rem; line-height: 1; color: var(--muted); display: grid; place-items: center; }
.clear-search:hover { background: var(--surface-3); }
.result-meta { font-size: 0.82rem; color: var(--muted); margin: 2px 2px 12px; font-weight: 600; }

/* ---------- Plate list ---------- */
.plate-list { display: grid; gap: 10px; }
.plate-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 15px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1.5px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform 0.16s var(--ease), border-color 0.2s, box-shadow 0.2s;
  animation: rowIn 0.3s var(--ease) both;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.plate-row:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.plate-row:active { transform: scale(0.99); }
.plate-row .pl-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.plate-row .pl-plate { font-weight: 800; font-size: 1.04rem; letter-spacing: 0.01em; }
.plate-row .pl-campaign { font-size: 0.78rem; font-weight: 600; color: var(--muted); overflow-wrap: break-word; }
.plate-row .pl-arrow { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.type-badge { font-size: 0.72rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.type-Solo { background: var(--primary-soft); color: var(--primary); }
.type-Zglobni { background: var(--warn-soft); color: var(--warn); }
.type-Tramvaj { background: var(--ok-soft); color: var(--ok); }
.type-Trolejbus { background: color-mix(in srgb, var(--accent) 22%, transparent); color: #9a7400; }
[data-theme="dark"] .type-Trolejbus { color: var(--accent); }
.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }

/* ---------- Vehicle head (step 3) ---------- */
.vehicle-head { margin-bottom: 18px; }
.vehicle-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.tag { font-size: 0.76rem; font-weight: 800; padding: 5px 11px; border-radius: 999px; background: linear-gradient(135deg, var(--brand-2), var(--brand-3)); color: #fff; overflow-wrap: break-word; max-width: 100%; }
.tag.soft { background: var(--surface-3); color: var(--muted); }

/* ---------- Device cards ---------- */
.device-list { display: grid; gap: 12px; }
.device-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); overflow: hidden; transition: border-color 0.25s, box-shadow 0.25s; }
.device-card.faulty { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.device-card.reported { border-color: var(--warn); }
.device-reported { padding: 0 16px 16px; display: grid; gap: 10px; }
.rep-note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-weight: 700; }
.rep-meta { color: var(--muted); font-size: 0.82rem; }
.resolve-btn { min-height: 44px; margin-top: 2px; }
.device-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px; cursor: pointer; user-select: none; }
.device-name { font-weight: 800; font-size: 1.02rem; }
.device-state { font-size: 0.74rem; font-weight: 800; padding: 5px 11px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; transition: all 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.device-state.ok { background: var(--ok-soft); color: var(--ok); }
.device-state.bad { background: var(--warn-soft); color: var(--warn); }
.device-body { padding: 0 16px 16px; animation: bodyIn 0.3s var(--ease); }
@keyframes bodyIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 9px 14px; border-radius: 999px; font-size: 0.86rem; font-weight: 700; background: var(--surface-2); border: 1.5px solid var(--line); color: var(--ink); transition: all 0.16s var(--ease); }
.chip:active { transform: scale(0.95); }
.chip.active { background: linear-gradient(135deg, var(--warn), #e8893a); color: #fff; border-color: transparent; box-shadow: 0 6px 14px rgba(216, 115, 26, 0.32); }
.device-comment { min-height: 64px; }

/* Razmak iznad dugmeta za predaju prijave (indoor + outdoor) */
#submitBtn { margin-top: 28px; }

/* ---------- Upload ---------- */
.upload-drop {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 26px 16px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface-2); border: 1.6px dashed var(--line-strong); color: var(--muted);
  font-weight: 600; transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
.upload-drop:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.upload-drop svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1.5px solid var(--line); animation: rowIn 0.3s var(--ease); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .rm { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; font-size: 1.1rem; line-height: 1; display: grid; place-items: center; }

/* ---------- Success ---------- */
.success-inner { text-align: center; max-width: 520px; padding-top: 40px; }
.success-check { width: 96px; height: 96px; margin: 0 auto 22px; }
.success-check svg { width: 100%; height: 100%; fill: none; stroke: var(--ok); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.success-check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.5s var(--ease) forwards; }
.success-check path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw 0.4s var(--ease) 0.4s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.success-summary { text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 18px 0 22px; box-shadow: var(--shadow-sm); }
.success-summary .sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.success-summary .sum-row:last-child { border-bottom: 0; }
.success-summary .sum-row span:first-child { color: var(--muted); font-weight: 600; }
.success-summary .sum-row span:last-child { font-weight: 700; text-align: right; }
.success-summary .fault-line { color: var(--warn); font-weight: 700; }

/* ---------- Segmented ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; margin: 4px 0 16px; }
.seg-btn { padding: 8px 16px; border-radius: 9px; font-weight: 700; font-size: 0.88rem; color: var(--muted); transition: all 0.2s var(--ease); }
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Reklama / RSD slajder (puna širina, 2 opcije) */
.kind-slider { display: flex; width: 100%; margin: 0 0 16px; }
.kind-slider .seg-btn { flex: 1; min-height: 42px; font-size: 0.96rem; }
.kind-slider .seg-btn.active { background: linear-gradient(135deg, var(--brand-2), var(--brand-3)); color: #fff; box-shadow: 0 8px 18px rgba(35, 103, 171, 0.3); }

/* ---------- History ---------- */
.history-list { display: grid; gap: 12px; }
.history-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); overflow: hidden; animation: rowIn 0.3s var(--ease) both; }
.history-card .hc-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 13px 16px; cursor: pointer; background: none; text-align: left; }
.history-card .hc-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.history-card .hc-plate { font-weight: 800; font-size: 1.04rem; }
.history-card .hc-dev { font-weight: 700; color: var(--muted); font-size: 0.85rem; }
.st-badge { font-size: 0.66rem; font-weight: 800; padding: 4px 9px; border-radius: 999px; letter-spacing: 0.04em; flex: none; text-transform: uppercase; }
.st-badge.open { background: var(--warn-soft); color: var(--warn); }
.st-badge.resolved { background: var(--ok-soft); color: var(--ok); }
.history-card .hc-status { font-size: 0.84rem; font-weight: 700; color: var(--warn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-card .hc-status.outdoor { color: var(--primary); }
.history-card .hc-chev { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.25s var(--ease); }
.history-card .hc-top.open .hc-chev { transform: rotate(180deg); }
.hc-info { display: grid; margin-bottom: 8px; }
.hc-irow { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.hc-irow span { color: var(--muted); font-weight: 600; }
.hc-irow b { font-weight: 700; text-align: right; word-break: break-word; }
.env-badge { font-size: 0.7rem; font-weight: 800; padding: 4px 9px; border-radius: 999px; text-transform: uppercase; }
.env-indoor { background: var(--primary-soft); color: var(--primary); }
.env-outdoor { background: var(--warn-soft); color: var(--warn); }
.hc-detail { padding: 0 16px 16px; border-top: 1px solid var(--line); margin-top: 2px; }
.hc-detail .d-fault { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.9rem; }
.hc-detail .d-fault:last-child { border-bottom: 0; }
.hc-detail .d-name { font-weight: 700; }
.hc-detail .d-note { color: var(--warn); text-align: right; }
.hc-detail .d-ok { color: var(--ok); font-weight: 700; }
.hc-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; margin-top: 10px; }
.hc-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- Roles ---------- */
.add-user-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.role-list { display: grid; gap: 10px; }
.role-row { display: flex; align-items: center; gap: 12px; padding: 13px 15px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.role-row .rr-email { flex: 1; font-weight: 700; word-break: break-all; font-size: 0.92rem; }
.role-row select { width: auto; min-height: 42px; padding: 8px 36px 8px 12px; font-size: 0.86rem; }
.role-row .rr-you { font-size: 0.7rem; color: var(--muted); font-weight: 700; }

.row-menu { position: relative; flex: none; }
.row-menu-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
  color: var(--muted); font-size: 1.2rem; line-height: 1; letter-spacing: -1px;
  transition: background-color 0.15s;
}
.row-menu-btn:hover, .row-menu-btn:active { background: var(--surface-3); color: var(--ink); }
.row-menu-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; gap: 2px;
  animation: cardIn 0.15s var(--ease) both;
}
.row-menu-item {
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  font-size: 0.86rem; font-weight: 700; color: var(--ink); transition: background-color 0.15s;
}
.row-menu-item:hover { background: var(--surface-3); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: var(--danger-soft); }
.pl-gar { color: var(--muted); font-weight: 700; font-size: 0.9em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .field { margin-bottom: 0; }
.veh-row { gap: 10px; align-items: center; }
.veh-info { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.status-pill { flex: none; font-size: 0.72rem; font-weight: 800; padding: 5px 11px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.status-pill.status-ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.status-pill.status-bad { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.status-pill.status-off { background: var(--surface-3); color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.stat-num { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.76rem; font-weight: 600; color: var(--muted); text-align: center; }

/* ---- Statistika: grafikoni ---- */
.chart-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 16px; }
.chart-title { margin: 0 0 10px; font-size: 0.94rem; color: var(--ink); }
.chart-legend { display: flex; gap: 16px; margin-bottom: 8px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

#chartsArea { transition: opacity 0.15s var(--ease); }
#chartsArea.loading-dim { opacity: 0.5; pointer-events: none; }
.chart-wrap { position: relative; }
.line-chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; cursor: crosshair; }
.chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis-label { fill: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.chart-dot { stroke: var(--surface); stroke-width: 2; pointer-events: none; }

.chart-tooltip {
  position: absolute; top: 0; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; box-shadow: var(--shadow); white-space: nowrap; font-size: 0.78rem;
}
.chart-tooltip-title { font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.chart-tooltip-row + .chart-tooltip-row { margin-top: 2px; }
.chart-tooltip-key { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; }
.chart-tooltip-key::before { content: ""; display: inline-block; width: 10px; height: 2px; background: var(--k-color); }
.chart-tooltip-row b { font-variant-numeric: tabular-nums; color: var(--ink); }

.chart-table-details { margin-top: 8px; }
.chart-table-details summary { cursor: pointer; font-size: 0.8rem; font-weight: 700; color: var(--primary); }
.chart-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.8rem; }
.chart-table th, .chart-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.chart-table th { color: var(--muted); font-weight: 700; }
.backup-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.backup-row input[type="date"] { flex: 1; min-width: 160px; }
.backup-row .btn { min-height: 48px; }
.backup-note { color: var(--muted); font-size: 0.84rem; margin: 8px 2px 0; }
.backup-preview { margin-top: 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow-sm); animation: viewIn 0.3s var(--ease); }
.backup-preview .bp-title { font-weight: 800; color: var(--navy, var(--ink)); margin-bottom: 8px; }
.backup-preview .bp-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.backup-preview .bp-row span { color: var(--muted); font-weight: 600; }
.backup-preview .bp-row b { font-size: 1.05rem; }
.backup-preview .bp-sub { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.backup-preview .bp-cities { color: var(--muted); font-size: 0.85rem; margin: 6px 0 4px; line-height: 1.6; }
.backup-preview .bp-cities b { color: var(--ink); }
.backup-preview .bp-hint { margin-top: 10px; font-size: 0.84rem; color: var(--muted); }
.backup-preview .bp-load, .backup-preview .bp-empty { color: var(--muted); }

/* ---------- History toolbar / Export ---------- */
.history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.history-toolbar .seg { margin: 0; }
.export-btn { min-height: 44px; padding: 0 16px; gap: 7px; }
.export-btn svg { flex: none; }

/* ---------- Modal (savjet) ---------- */
.modal-scrim { position: fixed; inset: 0; z-index: 62; display: grid; place-items: center; padding: 20px;
  background: rgba(8, 14, 34, 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade 0.2s var(--ease); }
.modal-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px 22px; box-shadow: var(--shadow-lg); animation: cardIn 0.35s var(--ease) both; }
.modal-ic { font-size: 2.2rem; text-align: center; margin-bottom: 6px; }
.modal-card h3 { margin: 0 0 8px; text-align: center; font-size: 1.2rem; color: var(--ink); }
.modal-card p { color: var(--muted); margin: 0 0 12px; }
.modal-steps { margin: 0 0 18px; padding-left: 20px; color: var(--ink); }
.modal-steps li { margin: 6px 0; }
.modal-steps b { color: var(--primary); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
.check-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; max-height: 50vh; overflow-y: auto; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; font-weight: 600; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }

.veh-row-editable { width: 100%; text-align: left; transition: transform 0.16s var(--ease), border-color 0.2s; }
.veh-row-editable:hover { border-color: var(--primary); }
.veh-row-editable:active { transform: scale(0.99); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0, 0, 0, 0.93); animation: fade 0.2s var(--ease); }
.lightbox img { max-width: 94vw; max-height: 82vh; object-fit: contain; border-radius: 8px; user-select: none; -webkit-user-drag: none; }
.lb-close { position: fixed; top: calc(env(safe-area-inset-top, 0) + 12px); right: 14px; width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 1.9rem; line-height: 1; display: grid; place-items: center; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 2rem; line-height: 1; display: grid; place-items: center; }
.lb-nav:active { background: rgba(255, 255, 255, 0.3); }
.lb-prev { left: 10px; } .lb-next { right: 10px; }
.lb-count { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0) + 16px); left: 50%; transform: translateX(-50%); color: #fff; font-weight: 700; background: rgba(0, 0, 0, 0.45); padding: 6px 14px; border-radius: 999px; }
.hc-photos img { cursor: zoom-in; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0) + 24px);
  transform: translate(-50%, 20px); z-index: 20; opacity: 0; pointer-events: none;
  background: var(--brand-5); color: #fff; padding: 13px 20px; border-radius: 14px;
  font-weight: 600; box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ---------- Loading overlay ---------- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  color: var(--muted); font-weight: 700; animation: fade 0.2s var(--ease);
}
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Menu connection mode ---------- */
.menu-mode { display: flex; align-items: center; gap: 8px; padding: 12px 8px 2px; margin-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.menu-mode .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.menu-mode .dot.live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 30%, transparent); }

[hidden] { display: none !important; }

/* =========================================================
   Mobilna optimizacija
   ========================================================= */
* { -webkit-tap-highlight-color: transparent; }
button, a, label, select, .plate-row, .choice-card, .chip, .city-tab,
.menu-item, .seg-btn, .device-top, .hc-top, .theme-toggle, .icon-btn {
  touch-action: manipulation;
}
/* iOS: spriječi auto-zoom na fokus polja (font >= 16px) */
input[type="text"], input[type="search"], input[type="password"], textarea, select { font-size: 16px; }
/* prirodno momentum skrolovanje + bez horizontalnog prelivanja */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
.view-inner, .menu-sheet { -webkit-overflow-scrolling: touch; }
img { -webkit-user-drag: none; user-select: none; }

/* ---------- Responsive ---------- */
@media (max-width: 460px) {
  .choice-grid { grid-template-columns: 1fr; }
  .view-title { font-size: 1.4rem; }
}
@media (min-width: 760px) {
  .topbar { padding-left: 28px; padding-right: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.05ms !important; }
}
