/* styles.css */
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f3f5fb;
  margin: 0;
  padding: 0 0 1.5rem 0;
  color: #0f1c3f;
  position: relative;
  min-height: 100vh;
}

.centered-container {
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: calc(100vh - 150px);
  padding: 2rem 1.25rem;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  max-width: 1200px;
  width: 100%;
  padding: 1.75rem;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.06);
  gap: 1.5rem;
  box-sizing: border-box;
}

/* Stranica grafova koristi puno vise prostora (org./mjerna mjesta lijevo
   i desno, graf u sredini), pa joj ne odgovara uska centrirana kartica. */
.card.card-wide {
  max-width: none;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
  color: #e5e7eb;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #5b6bff, #22d3ee);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(34, 211, 238, 0.25);
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
}

.brand-name {
  display: block;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #f8fafc;
}

.brand-subtitle {
  display: block;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.top-links {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-width: 0;
}

.top-links a {
  color: #e0e7ff;
  text-decoration: none;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.15s ease;
}

.top-links a:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Hamburger za sazimanje .top-links na uskim zaslonima - vidljiv samo ispod
   720px (vidi media query nize); injektira ga shared.js na svaku stranicu. */
.nav-toggle-btn {
  display: none;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #e0e7ff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.nav-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #5b6bff;
  margin: 0 0 0.4rem 0;
  font-size: 0.8rem;
}

h1 {
  margin: 0 0 0.25rem 0;
  font-size: 2.1rem;
  color: #0b1324;
}

h2 {
  margin: 0 0 0.35rem 0;
  font-size: 1.3rem;
  color: #0f1c3f;
}

.subtitle {
  margin: 0;
  color: #4b5563;
  max-width: 720px;
  line-height: 1.5;
}

.nav-menu {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.45rem;
  background: linear-gradient(135deg, rgba(91, 107, 255, 0.1), rgba(34, 211, 238, 0.08));
  border-radius: 16px;
  border: 1px solid #e5e7eb;
}

.nav-link {
  padding: 0.7rem 1.05rem;
  border-radius: 12px;
  color: #0f172a;
  text-decoration: none;
  font-weight: 600;
  background: #fff;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease, transform 0.2s ease;
}

.nav-link:hover {
  border-color: #5b6bff;
  color: #5b6bff;
  box-shadow: 0 10px 30px rgba(91, 107, 255, 0.12);
  transform: translateY(-1px);
}

.panel {
  border: 1px solid #e7e9f3;
  border-radius: 14px;
  padding: 1.25rem;
  background: #fbfcfe;
}

.panel + .panel {
  margin-top: 0.25rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.muted {
  color: #6b7280;
  font-size: 0.95rem;
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.1rem;
  border-radius: 12px;
  background: #eef2ff;
  border: 1px solid #dfe3ff;
}

.status-label {
  display: block;
  font-size: 0.85rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-value {
  font-weight: 700;
  color: #1f2937;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #22c55e, #16a34a);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.2);
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.compact-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
  color: #4b5563;
}

.compact-field select {
  min-width: 180px;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  font-weight: 600;
  color: #0f172a;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 600;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-weight: 600;
  color: #0f172a;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: relative;
  width: 46px;
  height: 26px;
  background: #e5e7eb;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.switch input:checked + .slider {
  background: linear-gradient(135deg, #5b6bff, #7c3aed);
}

.switch input:checked + .slider::after {
  transform: translateX(20px);
}

.switch-label {
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.compare-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.compare-toggle .switch.compact {
  transform: scale(0.9);
}

.compare-hint {
  font-weight: 500;
  color: #475569;
  font-size: 0.95rem;
}

.compare-field input[disabled],
.compare-field select[disabled] {
  background: #f5f5f5;
  color: #9ca3af;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  color: #0f172a;
}

/* ── Chart page: organizacije lijevo, mjerna mjesta+parametri desno, graf u sredini ── */
.chart-workspace {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: start;
}

.org-panel    { order: 1; }
.chart-main   { order: 2; }
.points-panel { order: 3; }

.org-panel,
.points-panel {
  min-width: 0;
}

.points-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chart-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.org-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 480px;
  overflow-y: auto;
}

.org-item {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.org-item:hover {
  background: #f1f5f9;
}

.org-item.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.param-block {
  border-top: 1px solid #e5e7eb;
  padding-top: 0.85rem;
}

.param-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.param-block-title {
  font-weight: 700;
  color: #0f172a;
}

.param-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fbfcfe;
}

.chart-hint {
  font-size: 0.82rem;
  margin: -0.25rem 0 0.75rem 0;
}

@media (max-width: 1180px) {
  .chart-workspace {
    grid-template-columns: 1fr 1fr;
  }

  .org-panel    { order: 1; }
  .points-panel { order: 2; }
  .chart-main   { order: 3; grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .chart-workspace {
    display: flex;
    flex-direction: column;
  }

  .chart-workspace > * {
    margin-bottom: 1rem;
  }

  .org-panel    { order: 1; }
  .points-panel { order: 2; }
  .chart-main   { order: 3; }

  .org-list {
    max-height: none;
  }
}

.dropdown-option {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
}

.dropdown-option:hover {
  background: #f8fafc;
}

.dropdown-option input {
  width: 16px;
  height: 16px;
}

.dropdown-label {
  font-weight: 600;
  color: #0f172a;
}

.param-selection-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.empty-state-inline {
  color: #64748b;
  font-weight: 500;
}

input,
select,
button,
.btn {
  font-family: inherit;
}

input[type="text"],
input[type="password"],
input[type="datetime-local"],
select {
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-family: inherit;
  color: #0f172a;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="datetime-local"]:focus,
select:focus {
  outline: none;
  border-color: #5b6bff;
  box-shadow: 0 8px 24px rgba(91, 107, 255, 0.2);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.65rem 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-lg {
  padding: 0.75rem 1.6rem;
  font-size: 1.05rem;
}

.btn.primary {
  background: linear-gradient(135deg, #5b6bff, #7c3aed);
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(91, 107, 255, 0.2);
}

.btn.secondary {
  background: #f8fafc;
  color: #1f2937;
  border-color: #e5e7eb;
}

.btn.ghost {
  background: transparent;
  color: #4b5563;
  border-color: #e5e7eb;
}

.top-nav .btn.ghost {
  color: #e0e7ff;
  border-color: rgba(255, 255, 255, 0.2);
}

.top-nav .btn.primary {
  box-shadow: 0 14px 32px rgba(34, 211, 238, 0.25);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.table-responsive {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow-x: auto;
}

.range-presets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.range-presets select {
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.device-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 1rem;
  background: #ffffff;
}

.device-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.device-badges {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.device-id {
  display: inline-flex;
  padding: 0.25rem 0.55rem;
  border-radius: 10px;
  background: #eef2ff;
  color: #312e81;
  font-weight: 700;
  font-size: 0.85rem;
}

.device-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0.15rem 0 0 0;
  color: #0f172a;
}

.device-subtitle {
  margin: 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.device-card__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}

.point-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.point-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

.point-row .device-title {
  margin: 0;
}

.meta-block {
  display: flex;
  flex-direction: column;
  padding: 0.65rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

.meta-label {
  color: #6b7280;
  font-size: 0.85rem;
}

.meta-value {
  font-weight: 700;
  color: #0f172a;
}

.device-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.footer-note {
  color: #475569;
  font-size: 0.9rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid #e5e7eb;
}

.status-chip.online {
  color: #15803d;
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.status-chip.offline {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.tag.subtle {
  background: #f0f9ff;
  color: #0ea5e9;
  border: 1px solid #bae6fd;
}

.btn.btn-sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed #d1d5db;
  background: #f9fafb;
  border-radius: 12px;
  color: #6b7280;
}

.chart-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 360px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  padding: 1rem;
}

.reset-zoom {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: none;
  box-shadow: 0 0.15rem 0.4rem rgba(0, 0, 0, 0.15);
}

.reset-zoom:hover {
  background: rgba(240, 240, 240, 0.95);
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
  background: #ffffff;
}

.chart-container:fullscreen {
  padding: 1.5rem;
  display: flex;
}

/* Kruzni graf ne treba sirinu vremenske serije - suzi i centriraj container
   umjesto da se krug rastegne preko cijele (siroke) chart-container povrsine.
   min-height:0 pusta aspect-ratio da u potpunosti odredi visinu. */
.chart-container.chart-container--pie {
  max-width: 460px;
  min-height: 0;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.chart-container:fullscreen canvas {
  flex: 1 1 auto;
}

/* ── Alatna traka iznad grafa (izvoz, ispis, slika, cijeli zaslon, opcije) ── */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chart-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #1f2937;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chart-icon-btn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.chart-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chart-options-wrap {
  position: relative;
}

/* position:fixed + JS-racunati top/left/width (vidi setChartOptionsMenuOpen
   u charts.html) umjesto CSS "right:0" sidrenja - na uskim (mobilnim)
   zaslonima "right:0" bi gurnuo izbornik preko lijevog ruba i odsjekao tekst,
   jer gumb "Opcije grafa" nije uvijek pri desnom rubu retka koji se prelama. */
.chart-options-menu {
  position: fixed;
  z-index: 30;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
  padding: 0.6rem;
  min-width: 260px;
  max-width: calc(100vw - 1.5rem);
  flex-direction: column;
  gap: 0.15rem;
}

.chart-stats {
  margin-top: 1rem;
}

.chart-stats-table {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
}

/* ── Storage page table ──────────────────────────────── */
.storage-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
  font-size: 0.92rem;
}

.storage-table th,
.storage-table td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.storage-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.storage-table tbody tr:last-child td {
  border-bottom: none;
}

:root[data-theme="dark"] .storage-table {
  background: #101a30;
  border-color: #23304e;
  color: #e5e9f5;
}

:root[data-theme="dark"] .storage-table th,
:root[data-theme="dark"] .storage-table td {
  border-color: #23304e;
}

:root[data-theme="dark"] .storage-table th {
  background: #0c1424;
  color: #94a3b8;
}

.chart-stats-header,
.chart-stat-row {
  display: grid;
  grid-template-columns: 2.2fr repeat(4, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
}

.chart-stats-header {
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  color: #475569;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.chart-stats-header > div:not(:first-child) {
  text-align: right;
}

.chart-stat-row {
  color: #0f172a;
  font-weight: 700;
}

.chart-stat-row:nth-child(odd) {
  background: #fbfdff;
}

.chart-stat-row + .chart-stat-row {
  border-top: 1px solid #e5e7eb;
}

.stat-meter {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.meter-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

.meter-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.meter-label {
  font-weight: 800;
  color: #0f172a;
}

.meter-range {
  font-size: 0.9rem;
  color: #475569;
}

.stat-value {
  text-align: right;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

/* Traka pri dnu STRANICE (normalan tok dokumenta - iza sadrzaja, ne
   pricvrscena za viewport). Vizualno izgleda isto kao fiksna varijanta
   (puna sirina, border-top, isti razmaci), samo se ponasa kao obican
   podnozje-element koji se scrolla zajedno sa stranicom. */
.site-footer {
  position: relative;
  margin: 1.5rem 0 0 0;
  max-width: none;
  padding: 0.75rem 1.75rem;
  background: #ffffff;
  border-radius: 0;
  border: none;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
}

.site-footer.footer-wide {
  max-width: none;
  width: 100%;
}

.powered-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: #6b7280;
  font-size: 0.88rem;
}

.powered-by-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

.powered-by-link:hover {
  opacity: 0.75;
}

.powered-by-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.powered-by strong {
  color: #0f172a;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* ── Status tag variants ──────────────────────────── */
.tag.success { background: #e6ffed; color: #14532d; }
.tag.danger  { background: #ffeaea; color: #7f1d1d; }

/* ── Active nav link ──────────────────────────────── */
.top-links a.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  font-weight: 700;
}

/* ── Dashboard navigation cards ──────────────────── */
/* Jedan redak po bloku (puna sirina, nisko) umjesto grida vise kvadraticnih
   kartica u redu - vidi se u cijelosti kao uska traka, ne kao "kockica". */
.dash-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.dash-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.dash-card:hover {
  border-color: #b8c0ff;
}

.dash-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.dash-card-body { flex: 1 1 auto; min-width: 0; }

.dash-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.2rem;
}

.dash-card-desc {
  font-size: 0.88rem;
  color: #6b7280;
  line-height: 1.45;
}

.dash-card-arrow {
  font-size: 1.25rem;
  color: #94a3b8;
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.dash-card:hover .dash-card-arrow {
  transform: translateX(4px);
  color: #5b6bff;
}

/* ── Extra spacing helper ─────────────────────────── */
.mb-3 { margin-bottom: 1.25rem; }

@media (max-width: 720px) {
  .card {
    padding: 1.25rem;
    border-radius: 12px;
  }

  .panel {
    padding: 1rem;
  }

  .top-nav {
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1rem;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
  }

  .nav-toggle-btn {
    display: inline-flex;
    order: 2;
  }

  .nav-actions {
    order: 3;
    width: auto;
  }

  /* Puni popis stranica se sakrije iza hamburgera (vidi .nav-toggle-btn) -
     otvara se kao puna traka ispod, ne kao jos jedan red sitnih pilula. */
  .top-links {
    display: none;
    order: 4;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin-top: 0.75rem;
  }

  .top-nav.nav-open .top-links {
    display: flex;
  }

  .top-links a {
    text-align: center;
    padding: 0.85rem 1rem;
  }

  .centered-container {
    padding: 1.25rem 0.75rem;
  }

  .site-footer {
    padding: 0.6rem 1rem;
  }

  .powered-by {
    font-size: 0.8rem;
  }

  h1 {
    font-size: 1.6rem;
  }
}

/* ── KPI row ──────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #5b6bff;
}

.kpi-card.kpi-success {
  border-left-color: #22c55e;
}

.kpi-card.kpi-warn {
  border-left-color: #f59e0b;
}

.kpi-card-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi-card-label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Live monitoring section ──────────────────────── */
.compact-select {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  font-size: 0.9rem;
  font-weight: 600;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  min-width: 200px;
  font-family: inherit;
}

.live-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.live-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.live-category {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid currentColor;
}

.live-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.65rem;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-top: 3px solid var(--cat-color, #e5e7eb);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.metric-card:hover {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.09);
  transform: translateY(-2px);
}

.metric-card-label {
  font-size: 0.78rem;
  color: #6b7280;
  font-weight: 600;
  line-height: 1.3;
}

.metric-card-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.metric-card-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-card-unit {
  font-size: 0.82rem;
  color: #6b7280;
  font-weight: 600;
}

.metric-card-code {
  font-size: 0.7rem;
  color: #94a3b8;
  font-family: 'Courier New', monospace;
}

.metric-card-ts {
  font-size: 0.7rem;
  color: #cbd5e1;
}

/* ── Releji / digitalni ulazi (relays.html) ─────────── */
.relay-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.relay-card.is-pending {
  opacity: 0.65;
  pointer-events: none;
}

.relay-status-text {
  font-size: 0.78rem;
  font-weight: 700;
}

.relay-status-pending { color: #d97706; }
.relay-status-ok      { color: #16a34a; }
.relay-status-fail    { color: #dc2626; }

/* ── Theme toggle ─────────────────────────────────── */
.theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #e0e7ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ── Alert rules (Alarmi) ────────────────────────── */
.alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}

.alert-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  background: #ffffff;
}

.alert-card.alert-triggered {
  border-color: #fecaca;
  background: #fff7f7;
}

.alert-card.alert-inactive {
  opacity: 0.6;
}

.alert-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert-card__title {
  font-weight: 700;
  color: #0f172a;
}

.alert-card__subtitle {
  font-size: 0.85rem;
  color: #6b7280;
}

.alert-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #334155;
}

.alert-card__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ── Dark theme ───────────────────────────────────── */
:root[data-theme="dark"] body {
  background: #05070f;
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .device-card,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .meta-block,
:root[data-theme="dark"] .point-row,
:root[data-theme="dark"] .dash-card,
:root[data-theme="dark"] .kpi-card,
:root[data-theme="dark"] .alert-card,
:root[data-theme="dark"] .site-footer,
:root[data-theme="dark"] .chart-stats-table,
:root[data-theme="dark"] .chart-container,
:root[data-theme="dark"] .param-checklist {
  background: #101a30;
  border-color: #23304e;
  color: #e5e9f5;
}

:root[data-theme="dark"] .dropdown-option:hover {
  background: #16213a;
}

:root[data-theme="dark"] .panel {
  background: #0a1120;
  border-color: #1d2942;
}

:root[data-theme="dark"] .param-block {
  border-color: #23304e;
}

:root[data-theme="dark"] .param-block-title {
  color: #f1f5f9;
}

:root[data-theme="dark"] .org-item {
  color: #cbd5e1;
}

:root[data-theme="dark"] .org-item:hover {
  background: #16213a;
}

:root[data-theme="dark"] .org-item.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: #3730a3;
  color: #c7d2fe;
}

:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] .device-title,
:root[data-theme="dark"] .status-value,
:root[data-theme="dark"] .kpi-card-value,
:root[data-theme="dark"] .metric-card-value,
:root[data-theme="dark"] .dash-card-title,
:root[data-theme="dark"] .alert-card__title,
:root[data-theme="dark"] .form-field,
:root[data-theme="dark"] .switch,
:root[data-theme="dark"] .dropdown-label,
:root[data-theme="dark"] .meta-value,
:root[data-theme="dark"] .stat-value,
:root[data-theme="dark"] .meter-label {
  color: #f1f5f9;
}

:root[data-theme="dark"] .subtitle,
:root[data-theme="dark"] .muted,
:root[data-theme="dark"] .device-subtitle,
:root[data-theme="dark"] .footer-note,
:root[data-theme="dark"] .powered-by,
:root[data-theme="dark"] .kpi-card-label,
:root[data-theme="dark"] .metric-card-label,
:root[data-theme="dark"] .metric-card-unit,
:root[data-theme="dark"] .dash-card-desc,
:root[data-theme="dark"] .alert-card__subtitle,
:root[data-theme="dark"] .compact-field,
:root[data-theme="dark"] .compare-hint,
:root[data-theme="dark"] small {
  color: #94a3b8;
}

:root[data-theme="dark"] .kpi-card {
  background: #101a30;
  border-color: #23304e;
}

:root[data-theme="dark"] .device-card,
:root[data-theme="dark"] .dash-card {
  background: #101a30;
}

:root[data-theme="dark"] .point-row,
:root[data-theme="dark"] .meta-block,
:root[data-theme="dark"] .empty-state {
  background: #0c1424;
  border-color: #23304e;
  color: #94a3b8;
}

:root[data-theme="dark"] .nav-menu {
  background: linear-gradient(135deg, rgba(91, 107, 255, 0.16), rgba(34, 211, 238, 0.12));
  border-color: #23304e;
}

:root[data-theme="dark"] .nav-link {
  background: #101a30;
  border-color: #23304e;
  color: #e2e8f0;
}

:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] input[type="datetime-local"],
:root[data-theme="dark"] select,
:root[data-theme="dark"] .compact-select {
  background: #0c1424;
  border-color: #2a3855;
  color: #e5e9f5;
}

/* Chrome/Edge iscrtavaju kalendar/sat ikonicu datetime-local polja crnom
   bojom po defaultu - u tamnoj temi bi bila nevidljiva na tamnoj pozadini. */
:root[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

:root[data-theme="dark"] .btn.secondary {
  background: #101a30;
  color: #e5e9f5;
  border-color: #2a3855;
}

:root[data-theme="dark"] .btn.ghost {
  color: #94a3b8;
  border-color: #2a3855;
}

:root[data-theme="dark"] .chart-icon-btn {
  background: #101a30;
  border-color: #2a3855;
  color: #e5e9f5;
}

:root[data-theme="dark"] .chart-icon-btn:hover {
  background: #16213a;
}

:root[data-theme="dark"] .chart-options-menu {
  background: #101a30;
  border-color: #2a3855;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .tag {
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
}

:root[data-theme="dark"] .tag.subtle {
  background: rgba(14, 165, 233, 0.14);
  color: #7dd3fc;
}

:root[data-theme="dark"] .status-pill {
  background: linear-gradient(135deg, rgba(91, 107, 255, 0.14), rgba(14, 165, 233, 0.1));
  border-color: #23304e;
}

:root[data-theme="dark"] .status-chip.online {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

:root[data-theme="dark"] .status-chip.offline {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

:root[data-theme="dark"] .alert-card.alert-triggered {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.12) 0%, #101a30 100%);
  border-color: rgba(239, 68, 68, 0.4);
}

:root[data-theme="dark"] .chart-stats-header {
  background: #0c1424;
  border-color: #23304e;
  color: #94a3b8;
}

:root[data-theme="dark"] .chart-stat-row:nth-child(odd) {
  background: #0d1728;
}

:root[data-theme="dark"] .chart-stat-row + .chart-stat-row {
  border-color: #23304e;
}

:root[data-theme="dark"] .chart-container canvas {
  background: #101a30;
}

@media (max-width: 480px) {
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .brand-subtitle {
    display: none;
  }

  .chart-stats-header,
  .chart-stat-row {
    grid-template-columns: 1.6fr repeat(4, 1fr);
    font-size: 0.78rem;
    padding: 0.6rem 0.5rem;
  }

  .device-grid,
  .dash-grid,
  .alert-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    padding: 0.7rem 1rem;
  }

  .device-card__header {
    flex-direction: column;
  }

  .device-badges {
    width: 100%;
  }
}

/* ── Comfortable tap targets on touch devices ─────── */
@media (pointer: coarse) {
  .btn,
  .top-links a,
  input[type="text"],
  input[type="password"],
  input[type="datetime-local"],
  select {
    min-height: 44px;
  }

  .chart-icon-btn,
  .nav-toggle-btn {
    width: 44px;
    height: 44px;
  }
}

/* ── Naslovna stranica (index.html) - ITASEL zlatni naglasak ───────────
   Sve u ovom bloku je skopirano na ".home-page" (samo body naslovne
   stranice) da ne utjece na kpi-card/dash-card koje koriste i devices.html/
   export.html - dijele iste bazne klase, ali s drugacijim (plavim) stilom. */
.home-page .hero-banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.85rem 2rem;
  border-radius: 18px;
  background: linear-gradient(120deg, #121a30 0%, #1c2b4a 60%, #2c2312 140%);
  overflow: hidden;
  color: #f8fafc;
}

.home-page .hero-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 88% 12%, rgba(201, 165, 91, 0.35), transparent 60%);
  pointer-events: none;
}

.home-page .hero-text {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.home-page .hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 0.8rem;
  color: #e3c98a;
  margin: 0 0 0.4rem 0;
}

.home-page .hero-banner h1 {
  color: #ffffff;
  margin: 0 0 0.4rem 0;
}

.home-page .hero-subtitle {
  color: #cbd5e1;
  margin: 0;
  max-width: 480px;
  line-height: 1.5;
}

.home-page .hero-status {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.home-page .hero-status-label {
  display: block;
  font-size: 0.78rem;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.home-page .hero-status-value {
  font-weight: 800;
  color: #ffffff;
  font-size: 1.05rem;
}

.home-page .hero-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #22c55e, #16a34a);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.22);
  flex-shrink: 0;
  animation: heroPulse 2.2s ease-in-out infinite;
}

@keyframes heroPulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.22); }
  50% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0.1); }
}

.home-page .kpi-row {
  margin-top: 1.5rem;
}

.home-page .kpi-card {
  border-left-color: #c9a55b;
  background: linear-gradient(180deg, #ffffff, #fbf8f1);
}

.home-page .kpi-card.kpi-success {
  border-left-color: #22c55e;
}

.home-page .kpi-card.kpi-warn {
  border-left-color: #f59e0b;
}

.home-page .dash-card:hover {
  border-color: #d9be82;
  box-shadow: 0 10px 28px rgba(201, 165, 91, 0.18);
  transform: translateY(-2px);
}

.home-page .dash-card:hover .dash-card-arrow {
  color: #b08d45;
}

@media (max-width: 720px) {
  .home-page .hero-banner {
    padding: 1.5rem;
  }

  .home-page .hero-status {
    width: 100%;
    justify-content: center;
  }
}

/* Dark tema: hero traka je namjerno uvijek tamna (kao top-nav), ne treba
   poseban override. KPI/dash-card naslijede opcenita tamna pravila (vidi
   gore ":root[data-theme=dark] .kpi-card/.dash-card") koja imaju vecu
   specificnost od ".home-page .kpi-card" pozadine/ruba - ovdje ih samo
   eksplicitno vracamo na zlatni naglasak umjesto zadanog plavog. */
:root[data-theme="dark"] .home-page .kpi-card {
  border-left-color: #c9a55b;
}

:root[data-theme="dark"] .home-page .kpi-card.kpi-success {
  border-left-color: #22c55e;
}

:root[data-theme="dark"] .home-page .kpi-card.kpi-warn {
  border-left-color: #f59e0b;
}

:root[data-theme="dark"] .home-page .dash-card:hover {
  border-color: #b08d45;
  box-shadow: 0 10px 28px rgba(201, 165, 91, 0.12);
}

/* ── Login stranica ───────────────────────────────── */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 2rem 1.25rem;
  box-sizing: border-box;
}

.login-card {
  max-width: 380px;
  width: 100%;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
}

.login-brand .brand-name {
  color: #0f172a;
}

.login-brand .brand-subtitle {
  color: #64748b;
}

:root[data-theme="dark"] .login-brand .brand-name {
  color: #e5e9f5;
}

:root[data-theme="dark"] .login-brand .brand-subtitle {
  color: #94a3b8;
}

.login-form {
  grid-template-columns: 1fr;
}

.login-error {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: #ffeaea;
  color: #7f1d1d;
  font-weight: 600;
  font-size: 0.9rem;
}

:root[data-theme="dark"] .login-error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.login-card .form-actions {
  justify-content: stretch;
}

.login-card .form-actions .btn {
  width: 100%;
}

/* ── Ispis grafa (gumb "Ispis" u alatnoj traci grafa) ────────────────── */
@media print {
  body * {
    visibility: hidden;
  }
  #chartSection,
  #chartSection * {
    visibility: visible;
  }
  #chartSection {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .chart-toolbar,
  .reset-zoom,
  .chart-hint {
    display: none !important;
  }
}
