/* ==========================================================================
   Flota – dizajn sistem
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #7b8798;

  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-soft: #e8efff;
  --primary-text: #ffffff;

  --moving: #16a34a;
  --idle: #f59e0b;
  --stopped: #64748b;
  --offline: #ef4444;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn-soft: #fff4d9;
  --ok-soft: #e3f6ea;

  --sidebar: #0f1b33;
  --sidebar-2: #16264a;
  --sidebar-text: #aab6cf;
  --sidebar-active: #ffffff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --shadow: 0 4px 12px rgba(15, 23, 42, .08), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .18), 0 4px 12px rgba(15, 23, 42, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 232px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  --bg: #0a0f1a;
  --surface: #111827;
  --surface-2: #151e2e;
  --surface-3: #1b2639;
  --border: #223049;
  --border-strong: #2e3f5c;
  --text: #e8edf5;
  --text-2: #b3bfd1;
  --muted: #7f8ca3;

  --primary: #4f8bff;
  --primary-600: #3b78f0;
  --primary-soft: #16294d;
  --primary-text: #07101f;

  --moving: #34d070;
  --idle: #fbbf24;
  --stopped: #8a97ad;
  --offline: #f87171;
  --danger: #f87171;
  --danger-soft: #3a1b1f;
  --warn-soft: #3a2f12;
  --ok-soft: #12301f;

  --sidebar: #070c17;
  --sidebar-2: #101a2e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 6px 18px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--primary-soft); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .92em; }
.hidden { display: none !important; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }

/* Ikone */
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i.sm { width: 15px; height: 15px; }
.i.lg { width: 22px; height: 22px; }

/* ==========================================================================
   Raspored aplikacije
   ========================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 140%);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; box-shadow: 0 6px 16px rgba(59, 130, 246, .45);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--sidebar-text); margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #6c7a98; padding: 14px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  color: var(--sidebar-text); font-weight: 520; text-decoration: none; position: relative; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(79, 139, 255, .18); color: var(--sidebar-active); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #5b9bff; }
.nav .badge-count { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #475569, #334155); color: #fff; font-weight: 650; font-size: 13px;
}
.user-chip .who { min-width: 0; }
.user-chip .who b { display: block; color: #fff; font-weight: 600; font-size: 13px; }
.user-chip .who span { font-size: 11.5px; color: #8391b0; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 22px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.icon-btn.menu-btn { display: none; }
.view { flex: 1; min-height: 0; overflow: auto; position: relative; }
.view.pad { padding: 22px; }
.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 18px; }
.page-head h2 { font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   Komponente
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 560; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
  box-shadow: var(--shadow-sm); text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 0;
  background: transparent; color: var(--text-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }

.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 9px 12px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.input.sm { height: 32px; font-size: 13px; }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8798' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); display: none; }
.field.invalid .err { display: block; }
.field.invalid .input { border-color: var(--danger); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--border-strong); border-radius: 22px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; left: 3px; top: 3px; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(16px); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; }
.card-body { padding: 18px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.badge.moving { background: var(--ok-soft); color: var(--moving); }
.badge.idle { background: var(--warn-soft); color: #b7791f; }
[data-theme="dark"] .badge.idle { color: var(--idle); }
.badge.stopped { background: var(--surface-3); color: var(--stopped); }
.badge.offline { background: var(--danger-soft); color: var(--offline); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--moving); }
.badge-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 560; user-select: none;
}
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 600; }

.segmented { display: inline-flex; background: var(--surface-3); padding: 3px; border-radius: 10px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 0 12px; height: 30px; border-radius: 8px; color: var(--text-2); font-weight: 560; cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .k-label { color: var(--muted); font-size: 12.5px; font-weight: 560; display: flex; align-items: center; gap: 7px; }
.kpi .k-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-value small { font-size: 14px; font-weight: 560; color: var(--muted); margin-left: 3px; }
.kpi .k-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Tabele */
.table-wrap { overflow: auto; border-radius: var(--radius); }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
table.t th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1;
}
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--text); }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tbody tr.clickable { cursor: pointer; }
table.t .r { text-align: right; }
table.t tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); }
table.t tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .i { width: 38px; height: 38px; opacity: .5; margin-bottom: 10px; }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(8, 14, 28, .55); backdrop-filter: blur(3px); z-index: 1000; display: grid; place-items: center; padding: 20px; animation: fade .12s; }
.modal { width: min(520px, 100%); max-height: 92vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .16s; }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; padding: 18px 22px 8px; }
.modal-head h3 { font-size: 17px; flex: 1; }
.modal-body { padding: 10px 22px 6px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Toast */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 2000; width: min(380px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); animation: slidein .22s; cursor: default;
}
.toast .t-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.toast.ok .t-ico { background: var(--ok-soft); color: var(--moving); }
.toast.error .t-ico { background: var(--danger-soft); color: var(--danger); }
.toast.warn .t-ico { background: var(--warn-soft); color: var(--idle); }
.toast b { display: block; font-weight: 620; }
.toast span { color: var(--text-2); font-size: 13px; }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } }

/* Dropdown (zvonce) */
.pop {
  position: absolute; top: calc(100% + 8px); right: 0; width: 380px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 900; overflow: hidden; animation: pop .14s;
}
.pop-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.pop-head b { flex: 1; }
.pop-list { max-height: 400px; overflow: auto; }
.alert-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.alert-item:hover { background: var(--surface-2); }
.alert-item.unread { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.alert-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.alert-ico.geofence_enter { background: var(--ok-soft); color: var(--moving); }
.alert-ico.geofence_exit { background: var(--primary-soft); color: var(--primary); }
.alert-ico.speeding { background: var(--danger-soft); color: var(--danger); }
.alert-ico.offline { background: var(--surface-3); color: var(--stopped); }
.alert-ico.online { background: var(--ok-soft); color: var(--moving); }
.alert-item .a-msg { font-weight: 560; }
.alert-item .a-time { color: var(--muted); font-size: 12px; }

/* ==========================================================================
   Karta i vozila
   ========================================================================== */
.split { display: grid; grid-template-columns: 360px 1fr; height: 100%; min-height: 0; }
.panel { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.panel-body { overflow: auto; flex: 1; min-height: 0; }
.map-wrap { position: relative; min-width: 0; min-height: 0; }
.map { position: absolute; inset: 0; background: var(--surface-3); z-index: 0; }
.search { position: relative; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 36px; }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-strip .s { padding: 8px 6px; text-align: center; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; transition: border-color .12s, background .12s; }
.stat-strip .s:hover { border-color: var(--border-strong); }
.stat-strip .s.on { background: var(--primary-soft); border-color: var(--primary); }
.stat-strip .s b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-strip .s span { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; }

.vitem { display: flex; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; position: relative; }
.vitem:hover { background: var(--surface-2); }
.vitem.sel { background: var(--primary-soft); }
.vitem.sel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.vico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; position: relative; }
.vico.moving { background: var(--moving); } .vico.idle { background: var(--idle); } .vico.stopped { background: var(--stopped); } .vico.offline { background: var(--offline); }
.vico.moving::after { content: ""; position: absolute; inset: -3px; border-radius: 14px; border: 2px solid var(--moving); opacity: .45; animation: ring 1.8s infinite; }
@keyframes ring { 0% { transform: scale(.92); opacity: .6; } 100% { transform: scale(1.12); opacity: 0; } }
.vitem .v-main { min-width: 0; flex: 1; }
.vitem .v-reg { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.vitem .v-sub { color: var(--muted); font-size: 12.5px; }
.vitem .v-right { text-align: right; flex: none; }
.vitem .v-speed { font-weight: 650; font-variant-numeric: tabular-nums; }

/* Markeri na karti */
.vmarker { position: relative; }
.vmarker .pin {
  position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; color: #fff;
  display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .35); transition: transform .15s;
}
.vmarker .pin svg { width: 16px; height: 16px; transition: transform .6s; }
.vmarker.moving .pin { background: var(--moving); } .vmarker.idle .pin { background: var(--idle); }
.vmarker.stopped .pin { background: var(--stopped); } .vmarker.offline .pin { background: var(--offline); }
.vmarker.sel .pin { transform: scale(1.18); box-shadow: 0 0 0 5px rgba(37, 99, 235, .35), 0 3px 10px rgba(0, 0, 0, .35); }
.vmarker .tag {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%); white-space: nowrap; font-size: 11px; font-weight: 650;
  padding: 1px 7px; border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); pointer-events: none;
}
.vmarker.moving .pin::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--moving); opacity: 0; animation: ring 1.8s infinite; }
.pt-dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .4); position: relative; left: -7px; top: -7px; }
.pt-label {
  position: relative; left: -13px; top: -13px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; color: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.pt-label.start { background: #16a34a; } .pt-label.end { background: #dc2626; } .pt-label.park { background: #475569; font-size: 11px; }
.replay-dot { width: 22px; height: 22px; left: -11px; top: -11px; position: relative; border-radius: 50%; background: var(--primary); border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(37, 99, 235, .3), 0 2px 8px rgba(0, 0, 0, .4); display: grid; place-items: center; color: #fff; }
.replay-dot svg { width: 11px; height: 11px; fill: #fff; stroke: none; }

/* Leaflet prilagodbe */
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9) saturate(.7); }
.leaflet-container { font-family: var(--font); background: var(--surface-3); }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-bottom-color: var(--border) !important; width: 34px !important; height: 34px !important; line-height: 34px !important; }
.leaflet-bar a:hover { background: var(--surface-3) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted) !important; font-size: 10px; border-radius: 8px 0 0 0; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-tooltip { background: var(--surface); color: var(--text); border: 0; border-radius: 8px; box-shadow: var(--shadow); font-weight: 600; }
.leaflet-tooltip::before { display: none; }

.map-float {
  position: absolute; z-index: 500; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.map-tools { top: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; background: transparent; border: 0; box-shadow: none; }
.map-tools .tool { width: 38px; height: 38px; border-radius: 10px; border: 0; background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); position: relative; }
.map-tools .tool:hover { color: var(--text); background: var(--surface-2); }
.map-tools .tool.on { background: var(--primary); color: #fff; }
.layer-menu { position: absolute; right: 46px; top: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 130px; z-index: 600; }
.layer-menu button { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 560; display: flex; gap: 8px; align-items: center; }
.layer-menu button:hover { background: var(--surface-3); }
.layer-menu button.on { color: var(--primary); background: var(--primary-soft); }

.detail-card { left: 12px; bottom: 12px; width: min(420px, calc(100% - 24px)); padding: 16px; animation: pop .16s; }
.detail-card h3 { font-size: 17px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.detail-grid .d { background: var(--surface-2); border-radius: 10px; padding: 9px 10px; }
.detail-grid .d span { display: block; font-size: 11px; color: var(--muted); font-weight: 560; }
.detail-grid .d b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* Historija */
.hist { display: grid; grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr; height: 100%; min-height: 0; }
.hist-bar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.hist-map { position: relative; min-height: 0; display: flex; flex-direction: column; }
.hist-map .map-wrap { flex: 1; }
.hist-side { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.date-nav { display: flex; align-items: center; gap: 4px; }
.date-nav .input { width: 150px; }
.replay { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 16px 12px; display: grid; gap: 8px; }
.replay-row { display: flex; align-items: center; gap: 12px; }
.replay-now { display: flex; gap: 18px; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }
.replay-now b { color: var(--text); }
.speed-chart { width: 100%; height: 74px; display: block; cursor: pointer; border-radius: 8px; }
.play-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: var(--primary-text); border: 0; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 12px rgba(37, 99, 235, .4); flex: none; }
.play-btn:hover { background: var(--primary-600); }
.tl-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.tl-item:hover { background: var(--surface-2); }
.tl-item.sel { background: var(--primary-soft); }
.tl-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 12px; }
.tl-mark.trip { background: var(--primary-soft); color: var(--primary); }
.tl-mark.stop { background: var(--surface-3); color: var(--stopped); }
.tl-item .tl-t { font-weight: 620; }
.tl-item .tl-s { color: var(--muted); font-size: 12.5px; }
.tl-metrics { display: flex; gap: 14px; margin-top: 5px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.tl-metrics span { display: inline-flex; gap: 5px; align-items: center; }
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 8px; }
.tabs button { border: 0; background: none; padding: 12px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--primary); border-color: var(--primary); }
.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.mini-kpis .m { background: var(--surface-2); border-radius: 10px; padding: 9px 11px; }
.mini-kpis .m span { font-size: 11px; color: var(--muted); font-weight: 560; display: block; }
.mini-kpis .m b { font-size: 16px; font-variant-numeric: tabular-nums; }

.legend { bottom: 12px; right: 12px; padding: 8px 12px; display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--text-2); }
.legend .grad { width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #22c55e, #eab308, #ef4444); }

/* Izvještaji */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 8px 4px 0; }
.bars .bar { flex: 1; min-width: 6px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.bars .bar i { display: block; width: 100%; max-width: 44px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #5b9bff, var(--primary)); min-height: 2px; transition: opacity .12s; }
.bars .bar:hover i { opacity: .8; }
.bars .bar small { font-size: 10.5px; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.bars .bar em { font-style: normal; font-size: 11px; font-weight: 650; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .input { width: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hbar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.hbar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }

/* Geozone */
.zone-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.zone-item:hover { background: var(--surface-2); }
.zone-item.sel { background: var(--primary-soft); }
.zone-sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.draw-banner { top: 12px; left: 50%; transform: translateX(-50%); padding: 10px 16px; display: flex; gap: 12px; align-items: center; z-index: 600; }

/* Prijava */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--bg); }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 10% -10%, #3b6cf0 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #7c3aed 0%, transparent 55%), #0b1430;
}
.auth-hero .grid-bg { position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(circle at 40% 40%, #000 0%, transparent 70%); }
.auth-hero > * { position: relative; }
.auth-hero h2 { font-size: 36px; line-height: 1.12; letter-spacing: -.03em; max-width: 440px; }
.auth-hero p { color: #c3cdea; max-width: 420px; font-size: 15px; }
.hero-feats { display: grid; gap: 12px; margin-top: 28px; }
.hero-feats div { display: flex; gap: 12px; align-items: center; color: #dbe4ff; }
.hero-feats .ic { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .12); display: grid; place-items: center; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 26px; }
.auth-card .btn.primary { width: 100%; height: 42px; font-size: 15px; }
.alert-box { padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 560; margin-bottom: 16px; }

/* ==========================================================================
   Responzivnost
   ========================================================================== */
@media (max-width: 1100px) {
  .hist { grid-template-columns: 1fr 330px; }
  .split { grid-template-columns: 320px 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 0 12px; }
  .view.pad { padding: 14px; }
  .split { grid-template-columns: 1fr; grid-template-rows: 46% 54%; }
  .split .map-wrap { order: -1; }
  .panel { border-right: 0; border-top: 1px solid var(--border); }
  .hist { grid-template-columns: 1fr; grid-template-rows: auto 56% auto; height: auto; min-height: 100%; }
  .hist-side { border-left: 0; border-top: 1px solid var(--border); }
  .grid-2 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Reoni: panel slojeva na karti */
.layers-panel { top: 12px; right: 60px; width: 270px; max-height: calc(100% - 24px); display: flex; flex-direction: column; z-index: 650; animation: pop .14s; }
.layers-panel .lp-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; border-bottom: 1px solid var(--border); }
.layers-panel .lp-head b { flex: 1; }
.layers-panel .lp-list { overflow: auto; padding: 4px 0; }
.layers-panel .lp-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; cursor: pointer; }
.layers-panel .lp-row:hover { background: var(--surface-2); }
.layers-panel .lp-row .dot { width: 11px; height: 11px; }
.layers-panel .lp-row small { color: var(--muted); font-variant-numeric: tabular-nums; }
.layers-panel .lp-empty { padding: 16px 14px; color: var(--muted); font-size: 13px; }
.dist-pt { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
.drop { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
