:root {
  --bg: #0b1220;
  --surface: #121c2d;
  --surface-2: #16233a;
  --border: #22334d;
  --text: #e7eefb;
  --muted: #8ba1c0;
  --accent: #4d9cff;
  --accent-dark: #2f7fe0;
  --ok: #3fb27f;
  --no: #d9646b;
  --danger: #e0575f;
}

* { box-sizing: border-box; }

/* Mora ici pre pravila koja postavljaju display (.login, .modal-backdrop),
   inace ona nadjacaju UA stil za [hidden] i ekrani se prikazuju svi odjednom. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Dugmad i polja ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary { background: var(--accent); color: #04101f; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.55; cursor: default; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; }

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.optional { color: #5f7691; }

.error {
  margin: 12px 0 0;
  padding: 9px 12px;
  background: rgba(224, 87, 95, 0.12);
  border: 1px solid rgba(224, 87, 95, 0.35);
  border-radius: 8px;
  color: #f2a3a7;
  font-size: 13px;
}

/* ---------- Prijava ---------- */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.login-card h1 { font-size: 22px; }
.login-sub { margin: 6px 0 20px; color: var(--muted); font-size: 14px; }

/* ---------- Zaglavlje ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 18px; }
.topbar-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 28px 60px;
}

/* ---------- Statistika ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-left: 3px solid var(--border);
}

.stat-ok { border-left-color: var(--ok); }
.stat-no { border-left-color: var(--no); }
.stat-accent { border-left-color: var(--accent); }

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stat-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Alatke ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search { max-width: 280px; }
.toolbar-actions { display: flex; gap: 10px; }

/* ---------- Tabela ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

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

.table th {
  padding: 12px 16px;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(34, 51, 77, 0.6);
  vertical-align: top;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

.num, td.num { text-align: right; }
.actions-col { width: 1%; }

.cell-name { font-weight: 500; }
.cell-message { color: var(--muted); max-width: 280px; }
.cell-date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-da { background: rgba(63, 178, 127, 0.15); color: var(--ok); }
.badge-ne { background: rgba(217, 100, 107, 0.15); color: var(--no); }
.badge-manual { background: rgba(77, 156, 255, 0.13); color: var(--accent); }
.badge-form { background: rgba(139, 161, 192, 0.13); color: var(--muted); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.icon-btn {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--accent); color: var(--text); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.empty {
  margin: 0;
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 10, 20, 0.7);
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h2 { font-size: 18px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 11px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  z-index: 60;
}

@media (max-width: 640px) {
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 14px 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .toolbar-actions { justify-content: flex-end; }
  .cell-message { max-width: 160px; }
}
