@font-face {
  font-family: 'Inter';
  font-weight: 400;
  src: url('fonts/inter-latin-ext-400-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  font-weight: 600;
  src: url('fonts/inter-latin-ext-600-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  font-weight: 700;
  src: url('fonts/inter-latin-ext-700-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  font-weight: 800;
  src: url('fonts/inter-latin-ext-800-normal.woff2') format('woff2');
  font-display: swap;
}

:root {
  --primary: #003CA6;
  --primary-dark: #002D80;
  --secondary: #0079CA;
  --bg: #F0F3F9;
  --surface: #FFFFFF;
  --border: #E4E8F1;
  --text: #171E2E;
  --text-muted: #6E7891;
  --danger: #D64545;
  --success: #1E9E5A;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15,25,55,.04), 0 10px 28px rgba(15,25,55,.07);
  --shadow-lg: 0 6px 16px rgba(15,25,55,.06), 0 20px 48px rgba(15,25,55,.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* Suptilan dijamant vodeni žig (motiv iz loga) u pozadini sadržaja */
.content { position: relative; }
.content::before {
  content: '';
  position: fixed;
  top: -60px; right: -60px;
  width: 420px; height: 420px;
  background: radial-gradient(circle at 70% 20%, rgba(0,60,166,.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.content > * { position: relative; z-index: 1; }

#app {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidenav (desktop) ---------- */
.sidenav {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--primary), var(--primary-dark) 70%);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 26px 16px;
  gap: 4px;
  box-shadow: var(--shadow-lg);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 30px;
}
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 50%; background: white; padding: 2px; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.78);
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: rgba(255,255,255,.16); color: white; }

/* ---------- Sidebar stats footer ---------- */
.sidebar-stats {
  margin-top: auto;
  padding: 16px 14px 6px;
  border-top: 1px solid rgba(255,255,255,.14);
}
.sidebar-stats .stat-line {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: rgba(255,255,255,.65);
  padding: 5px 4px;
}
.sidebar-stats .stat-line b {
  color: white;
  font-weight: 700;
}
.sidebar-stats .stat-line.paid b { color: #8FE3B0; }
.sidebar-stats .stat-line.unpaid b { color: #FFD48A; }

.sidebar-user {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 2px; gap: 8px;
}
.sidebar-user .who { font-size: 12.5px; color: rgba(255,255,255,.75); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who b { color: white; display: block; font-size: 13.5px; }
.sidebar-user .logout-btn {
  background: rgba(255,255,255,.12); border: none; color: white; border-radius: 8px;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.sidebar-user .logout-btn:hover { background: rgba(255,255,255,.22); }
.sidebar-user .logout-btn svg { width: 15px; height: 15px; stroke: white; fill: none; stroke-width: 2; }

/* ---------- Stats summary kartice (Dokumenti view) ---------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat-card .stat-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 21px; font-weight: 800; color: var(--text); }
.stat-card.paid .stat-value { color: var(--success); }
.stat-card.unpaid .stat-value { color: #C77700; }

/* ---------- Plaćeno checkbox u popisu dokumenata ---------- */
.paid-toggle {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.paid-toggle input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--success); }
.doc-row.is-paid { background: #F5FBF7; }
.doc-row.is-paid:hover { background: #EEF9F1; }

/* ---------- Content ---------- */
.content {
  flex: 1;
  padding: 34px 40px 100px;
  max-width: 1080px;
}

.page-title {
  font-size: 27px;
  font-weight: 800;
  margin: 0 0 5px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 0 0 28px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 24px;
  margin-bottom: 20px;
  transition: box-shadow .2s;
}
.card h3 {
  margin: 0 0 18px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text);
  background: #FCFDFE;
  transition: border-color .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--secondary);
  background: white;
}
textarea { resize: vertical; }

.field { margin-bottom: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 11px;
  border: none;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s, transform .05s, box-shadow .12s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
  box-shadow: 0 4px 14px rgba(0,60,166,.28);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 6px 18px rgba(0,60,166,.34); }
.btn-secondary { background: #EEF2FA; color: var(--primary); }
.btn-secondary:hover { filter: brightness(0.97); }
.btn-danger { background: #FCEBEB; color: var(--danger); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Tip dokumenta tabs ---------- */
.type-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.type-tab {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: white;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.type-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ---------- Stavke table ---------- */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.items-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  padding: 0 8px 8px;
  font-weight: 700;
}
.items-table td { padding: 4px 8px; vertical-align: middle; }
.items-table input { padding: 8px 10px; font-size: 14px; }
.col-opis { width: 46%; }
.col-kol { width: 12%; }
.col-cij { width: 16%; }
.col-iznos { width: 16%; text-align: right; font-weight: 600; padding-right: 4px; }
.col-del { width: 30px; }

.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #FBECEC; color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.totals-box {
  margin-left: auto;
  width: 260px;
  margin-top: 10px;
}
.totals-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; color: var(--text-muted); }
.totals-row.grand { font-size: 18px; font-weight: 700; color: var(--primary); border-top: 1.5px solid var(--border); margin-top: 6px; padding-top: 12px; }

/* ---------- Autocomplete klijenata ---------- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 20;
}
.autocomplete-item { padding: 10px 14px; cursor: pointer; font-size: 14px; }
.autocomplete-item:hover { background: #F3F6FC; }
.autocomplete-item .oib { color: var(--text-muted); font-size: 12px; }

/* ---------- Popis dokumenata ---------- */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: white;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.doc-row:hover { background: #FAFBFD; }
.doc-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #EAF1FE;
  color: var(--primary);
  white-space: nowrap;
}
.doc-badge.ponuda { background: #FFF3E0; color: #B36B00; }
.doc-badge.predracun { background: #EEF7EE; color: var(--success); }
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-weight: 700; font-size: 14.5px; }
.doc-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.doc-amount { font-weight: 700; font-size: 15px; white-space: nowrap; }
.doc-actions { display: flex; gap: 6px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; stroke: var(--border); margin-bottom: 14px; }

/* ---------- Klijenti ---------- */
.client-card {
  background: white; border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; margin-bottom: 10px;
}
.client-avatar {
  width: 40px; height: 40px; border-radius: 10px; background: var(--secondary);
  color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.client-info { flex: 1; min-width: 0; }
.client-name { font-weight: 700; font-size: 14.5px; }
.client-meta { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Logo upload ---------- */
.logo-upload {
  display: flex; align-items: center; gap: 16px;
}
.logo-preview {
  width: 84px; height: 84px; border-radius: 12px; border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden; background: #FAFBFD;
}
.logo-preview img { max-width: 100%; max-height: 100%; }

.color-swatch-row { display: flex; align-items: center; gap: 10px; }
.color-swatch-row input[type=color] { width: 46px; height: 40px; padding: 3px; cursor: pointer; }

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--text); color: white; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .sidenav { display: none; }
  .content { padding: 20px 16px 90px; max-width: 100%; }
  .grid-2, .grid-3, .grid-4, .stats-row { grid-template-columns: 1fr; }
  .bottomnav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white; border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 100;
  }
  .bnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    border: none; background: none; padding: 8px 2px; color: var(--text-muted); font-size: 10.5px; font-weight: 600;
    cursor: pointer;
  }
  .bnav-item svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
  .bnav-item.active { color: var(--primary); }
  .items-table { display: block; }
  .items-table thead { display: none; }
  .items-table tbody, .items-table tr { display: block; width: 100%; }
  .items-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 8px;
    background: #FAFBFD;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .items-table td { padding: 0; }
  .col-opis { grid-column: 1 / -1; width: auto; }
  .col-del { grid-column: 1 / -1; width: auto; display: flex; justify-content: flex-end; }
  .totals-box { width: 100%; }
  .doc-row { flex-wrap: wrap; }
}
