:root {
  --blue: #0b63b0;
  --blue-dark: #084a85;
  --blue-light: #e8f1fb;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #17212b;
  --muted: #67747f;
  --border: #e3e7ec;
  --danger: #c0392b;
  --danger-bg: #fbeceb;
  --shadow: 0 1px 2px rgba(20, 30, 40, 0.06), 0 1px 8px rgba(20, 30, 40, 0.04);
  --shadow-lg: 0 8px 30px rgba(20, 30, 40, 0.16);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #3d95e8;
    --blue-dark: #2c78c4;
    --blue-light: #132436;
    --bg: #0f1418;
    --card: #1a2129;
    --text: #eef2f5;
    --muted: #8b98a3;
    --border: #2a333c;
    --danger: #e05f52;
    --danger-bg: #3a1e1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

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

.topbar {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  padding: 16px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0 0 12px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.15);
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn.active {
  background: white;
  color: var(--blue-dark);
  box-shadow: var(--shadow);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form.inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.form.inline input {
  flex: 1;
  min-width: 90px;
}

.form h2 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  font-weight: 700;
}

input, select, textarea, button {
  font-size: 1rem;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}

textarea { resize: vertical; min-height: 60px; }

button {
  background: var(--blue);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover { background: var(--blue-dark); }
button:active { transform: scale(0.98); }

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 4px 2px 10px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.list li:active { transform: scale(0.99); }

.list li .row-title {
  display: block;
  font-weight: 600;
  font-size: 0.98rem;
}

.list li .row-sub {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.list.compact li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: default;
  font-size: 0.92rem;
  box-shadow: none;
}

.list.compact .compact-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  gap: 8px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
  font-size: 0.92rem;
}

.status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-light);
  color: var(--blue-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 18, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  animation: fadeIn 0.15s ease;
}

.overlay.hidden { display: none; }

.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 22px 20px 28px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.detalji-klijent {
  color: var(--muted);
  margin: 2px 0 0;
  font-size: 0.92rem;
}

.cost-box {
  display: flex;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  margin: 14px 0 6px;
  box-shadow: var(--shadow);
}

.cost-box div { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.82rem; color: var(--muted); flex: 1; }
.cost-box div strong { color: var(--text); font-size: 1.1rem; font-weight: 700; }
.cost-box .total { border-left: 1px solid var(--border); }
.cost-box .total strong { color: var(--blue); }

h3 { margin: 20px 0 8px; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.gallery-item {
  position: relative;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.gallery-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 1rem;
  line-height: 1;
}

.status {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 30;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.15s ease;
}

.status.error { background: var(--danger); color: white; }
.status.hidden { display: none; }

.table-wrap { overflow-x: auto; }

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.report-table th, .report-table td {
  padding: 9px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.report-table th:first-child, .report-table td:first-child {
  text-align: left;
  white-space: normal;
}

.report-table thead th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-table tfoot td {
  font-weight: 700;
  border-bottom: none;
  border-top: 2px solid var(--border);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

#btn-odjava {
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
}

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.pdf-link {
  display: inline-block;
  background: var(--blue);
  color: white;
  text-decoration: none;
  padding: 11px 16px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.92rem;
  text-align: center;
  transition: background 0.15s ease;
}

.pdf-link:hover { background: var(--blue-dark); }

.pdf-link-secondary {
  background: transparent;
  border: 1px solid var(--blue);
  color: var(--blue);
}

.pdf-link-secondary:hover { background: var(--blue-light); }

#link-predracun-pdf,
#link-racun-pdf,
#link-pdf-radnici {
  display: block;
  width: 100%;
  margin: 4px 0 8px;
}

#link-racun-pdf { margin-bottom: 16px; }

.hidden { display: none !important; }

.btn-danger {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  margin: 4px 0 16px;
}

.btn-danger:hover { background: var(--danger-bg); }

.status-badge[data-status="arhiviran"] {
  background: var(--border);
  color: var(--muted);
}

.delete-btn {
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 2px 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

#lista-klijenata li {
  position: relative;
  padding-right: 44px;
  cursor: default;
}

#lista-klijenata .delete-btn {
  position: absolute;
  top: 8px;
  right: 6px;
  font-size: 1.2rem;
}
