/* Boje su iz proverene palete: jedna serija (plava), status boje odvojene,
   svaka uz ikonu i tekst da znacenje nikad ne nosi samo boja. */

:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series: #2a78d6;
  --series-soft: #cde2fb;
  --good: #0ca30c;
  --critical: #d03b3b;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series: #3987e5;
    --series-soft: #184f95;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series: #3987e5;
  --series-soft: #184f95;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: inherit; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px 64px; }

/* -- zaglavlje -- */

header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 28px;
}

.bar {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
}

.brand { font-weight: 600; letter-spacing: -0.01em; }

nav { display: flex; gap: 22px; margin-right: auto; }

nav a {
  text-decoration: none;
  color: var(--ink-2);
  padding: 18px 0;
  border-bottom: 2px solid transparent;
  font-size: 14px;
}

nav a:hover { color: var(--ink); }
nav a.on { color: var(--ink); border-bottom-color: var(--series); }

.toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--ink-2);
  cursor: pointer;
  padding: 5px 9px;
  font-size: 14px;
}

.toggle:hover { color: var(--ink); }

/* -- naslovi i kartice -- */

h1 { font-size: 23px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 16px; }

.head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head .sub { color: var(--muted); font-size: 14px; }
.spacer { margin-left: auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

/* -- brojevi -- */

.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.tile .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.tile .value .of { color: var(--muted); font-size: 17px; font-weight: 400; }
.tile.hero .value { font-size: 48px; line-height: 1.05; letter-spacing: -0.03em; }

/* -- tabele -- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
  padding: 0 12px 10px 0;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }
td.name { font-weight: 500; }
td.dim { color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.on { background: var(--good); }
.dot.off { background: var(--baseline); }
.warn { color: var(--critical); font-size: 12.5px; }

/* -- dnevna traka -- */

.timeline { margin-top: 4px; }
.tl-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 14px; height: 34px; }
.tl-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tl-track {
  position: relative;
  height: 100%;
  border-left: 1px solid var(--grid);
  border-right: 1px solid var(--grid);
}

.tl-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }

.tl-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 14px;
  border-radius: 7px;
  background: var(--series);
}

.tl-pass {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--series);
}

.tl-empty { position: absolute; top: 50%; transform: translateY(-50%); left: 10px; color: var(--muted); font-size: 12.5px; }
.tl-label { position: absolute; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-axis { display: grid; grid-template-columns: 150px 1fr; gap: 14px; margin-top: 6px; }
.tl-axis .marks { position: relative; height: 16px; }
.tl-axis .marks span { position: absolute; transform: translateX(-50%); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* -- vodoravni stubovi -- */

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 62px; align-items: center; gap: 14px; }
.bar-row .lab { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 18px; background: var(--grid); border-radius: 0 3px 3px 0; }
.bar-row .fill { height: 100%; background: var(--series); border-radius: 0 4px 4px 0; }
.bar-row .val { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* -- kamere -- */

.cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.cam { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--plane); }
.cam img { width: 100%; display: block; aspect-ratio: 16 / 9; object-fit: cover; background: var(--grid); }
.cam .cap { padding: 7px 9px 7px 12px; display: flex; align-items: center; gap: 8px; }
.cam.off { opacity: 0.72; }
.cam-off {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grid);
  color: var(--muted);
  font-size: 13px;
}

/* naziv kamere - izgleda kao tekst dok se ne klikne */
.cam .cap form { flex: 1; min-width: 0; display: flex; }
.cam .cap form.sw { flex: none; }

input.ime {
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 7px;
  width: 100%;
  min-width: 0;
  cursor: text;
}

input.ime:hover { border-color: var(--border); }
input.ime:focus { outline: none; border-color: var(--series); background: var(--surface); color: var(--ink); }

/* prekidac */
.sw input { position: absolute; opacity: 0; pointer-events: none; }

.sw label {
  display: block;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: var(--baseline);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}

.sw label::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}

.sw input:checked + label { background: var(--good); }
.sw input:checked + label::after { transform: translateX(14px); }
.sw input:focus-visible + label { outline: 2px solid var(--series); outline-offset: 2px; }

/* -- galerija detekcija -- */

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; }
.shot { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--plane); }
.shot img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--grid); }
/* snimci prolazaka su ceo kadar, ne isecak lica */
.shots.siroko { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.shots.siroko .shot img { aspect-ratio: 16 / 9; }
.shot .meta { padding: 7px 9px; font-size: 11.5px; color: var(--ink-2); }
.shot .meta b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot .meta span { color: var(--muted); font-variant-numeric: tabular-nums; }

/* -- crtanje zone -- */

.crtanje { display: grid; grid-template-columns: 1fr 240px; gap: 20px; align-items: start; }

.platno { position: relative; cursor: crosshair; border-radius: 8px; overflow: hidden; }
.platno img { width: 100%; display: block; }
.platno svg { position: absolute; inset: 0; width: 100%; height: 100%; }

#nova { fill: rgba(42, 120, 214, 0.28); stroke: var(--series); stroke-width: 0.4; }
#linija { fill: none; stroke: var(--series); stroke-width: 0.4; stroke-dasharray: 1.2 1.2; }
#temena circle { fill: var(--surface); stroke: var(--series); stroke-width: 0.5; }
.zona-stara { fill: rgba(137, 135, 129, 0.22); stroke: var(--muted); stroke-width: 0.35; }

.crtanje form { display: flex; flex-direction: column; gap: 12px; }
.brojac { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* -- prolazaka po satu -- */

.satnica { display: flex; gap: 3px; align-items: flex-end; height: 120px; }
.sat { flex: 1; display: flex; flex-direction: column; height: 100%; }
.sat .stub { flex: 1; display: flex; align-items: flex-end; background: var(--grid); border-radius: 3px 3px 0 0; }
.sat .pun { width: 100%; background: var(--series); border-radius: 3px 3px 0 0; min-height: 0; }
.sat .oznaka { text-align: center; font-size: 10.5px; color: var(--muted); padding-top: 5px; font-variant-numeric: tabular-nums; }

/* -- kontrole -- */

.controls { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--muted); }

input[type="date"], input[type="text"], input[type="email"],
input[type="password"], input[type="file"], select {
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 15px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: var(--series);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn.ghost { background: none; border-color: var(--border); color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); }
.btn.link { background: none; border: none; color: var(--muted); padding: 4px 0; font-size: 13px; text-decoration: underline; }

.note { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 18px; border: 1px solid var(--border); }
.note.ok { border-left: 3px solid var(--good); }
.note.bad { border-left: 3px solid var(--critical); }

.empty { color: var(--muted); font-size: 14px; padding: 22px 0; text-align: center; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 10px; }

@media (max-width: 720px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tl-row, .tl-axis, .bar-row { grid-template-columns: 104px 1fr; }
  .bar-row .val { grid-column: 2; text-align: left; }
}

.zona-link { font-size: 12px; color: var(--muted); text-decoration: none; flex: none; padding: 4px 6px; border-radius: 6px; }
.zona-link:hover { color: var(--ink); background: var(--plane); }

/* kvadratic za stikliranje */
.kvadratic { display: inline-flex; cursor: pointer; }
.kvadratic input { position: absolute; opacity: 0; }
.kvadratic span {
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--baseline); display: block; position: relative;
}
.kvadratic input:checked + span { background: var(--series); border-color: var(--series); }
.kvadratic input:checked + span::after {
  content: ""; position: absolute; left: 5px; top: 1px;
  width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.kvadratic input:focus-visible + span { outline: 2px solid var(--series); outline-offset: 2px; }

.oznaka-nova {
  font-size: 10.5px; font-weight: 500; color: var(--surface); background: var(--series);
  padding: 1px 6px; border-radius: 20px; margin-left: 7px; vertical-align: 1px;
}

/* polja u jednom redu da budu iste sirine */
.controls .field input[type="text"],
.controls .field input[type="password"] { min-width: 180px; }

/* prijava i registracija */
.usko { max-width: 380px; margin: 8vh auto 0; }
.usko h1 { text-align: center; }
.sub-linija { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.uspravno { display: flex; flex-direction: column; gap: 14px; }
.uspravno .btn { margin-top: 4px; }
.uspravno input { width: 100%; }
header.prazno { background: none; border: none; margin-bottom: 0; }
.korisnik { font-size: 13px; color: var(--muted); }
.bar form { display: flex; }

/* -- super admin -- */

/* Traka mora da se primeti: super admin u tudjem nalogu lako zaboravi gde je. */
.pregled-traka {
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--critical);
  background: var(--plane);
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 24px;
}
.pregled-traka b { color: var(--ink); font-weight: 600; }
.pregled-traka form { margin-left: auto; }

.moduli { display: flex; flex-wrap: wrap; gap: 6px; }
.modul {
  font-size: 11.5px; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--border); color: var(--ink-2); background: var(--plane);
}
.modul.off { color: var(--muted); border-style: dashed; opacity: 0.7; }

/* stikliranje modula: kvadratic i naziv u istom redu, u koloni po modulu */
.izbor-modula { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.izbor-modula label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
