/* ===== Osnovno ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #e8eaed;
  --panel: #f4f5f7;
  --border: #c4c8cf;
  --yellow: #fff8c4;
  --yellow-border: #e6d97a;
  --blue: #2f6fed;
  --blue-row: #cfe0ff;
  --blue-row-2: #b9d2ff;
  --title: #1f2a44;
  --text: #1c1e21;
  --muted: #6b7280;
  --green: #2e9e44;
  --red: #d64545;
  --hover: #e2e8f2;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
.hidden { display: none !important; }

/* ===== Login ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, #24345c, #16213e);
  display: flex; align-items: center; justify-content: center;
}
.login-dialog {
  width: 340px; background: #fff; border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,.4); border-radius: 6px; overflow: hidden;
}
.login-title {
  background: var(--title); color: #fff; padding: 10px 14px;
  font-weight: 600; letter-spacing: .3px; font-size: 14px;
}
.login-body { padding: 18px; }
.login-body label { display: block; margin: 10px 0 4px; font-weight: 600; color: var(--title); }
.login-body input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 14px;
}
.login-body input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47,111,237,.15); }
.login-error { margin-top: 12px; color: var(--red); font-weight: 600; text-align: center; }
.login-actions { display: flex; gap: 10px; padding: 0 18px 18px; }
.login-actions .btn { flex: 1; }

/* ===== Glavni prozor ===== */
.app { display: flex; flex-direction: column; height: 100vh; }
.titlebar {
  background: var(--title); color: #fff; padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.app-title { font-weight: 700; letter-spacing: .5px; font-size: 15px; }
.user-badge {
  background: rgba(255,255,255,.15); padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}

/* Meni */
.menubar {
  display: flex; background: #fff; border-bottom: 1px solid var(--border);
  user-select: none;
}
.menu {
  padding: 7px 14px; cursor: pointer; border-right: 1px solid #eee; font-size: 13px;
}
.menu:hover, .menu.open { background: var(--hover); }
.menu-izlaz { margin-left: auto; border-right: none; border-left: 1px solid #eee; }

/* Toolbar */
.toolbar {
  display: flex; gap: 4px; padding: 6px 8px; background: var(--panel);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.tbtn {
  width: 42px; height: 38px; border: 1px solid transparent; background: transparent;
  border-radius: 5px; cursor: pointer; color: var(--title);
  display: flex; align-items: center; justify-content: center;
}
.tbtn:hover { background: var(--hover); border-color: var(--border); }
.tbtn:active { background: #d5dce8; }

/* Content */
.content { flex: 1; overflow: auto; padding: 14px; }

/* ===== View / prozorčić ===== */
.view {
  max-width: 1080px; margin: 0 auto; background: #fff;
  border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.08); overflow: hidden;
}
.view-title {
  background: var(--title); color: #fff; padding: 9px 14px; font-weight: 600; font-size: 14px;
}
.view-sub { background: #eef1f6; padding: 6px 14px; font-weight: 600; color: var(--title); border-bottom: 1px solid var(--border); }
.view-body { padding: 14px; }

/* ===== Forma unosa (žuta) ===== */
.form {
  background: var(--yellow); border: 1px solid var(--yellow-border);
  border-radius: 5px; padding: 14px; margin-bottom: 14px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px;
}
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 11px; font-weight: 700; color: #7a6d1a; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .3px; }
.field input, .field select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; background: #fff;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); }
.field input[readonly] { background: #f0f0f0; color: var(--muted); }
.field .with-btn { display: flex; gap: 4px; }
.field .with-btn input { flex: 1; }
.check-row { display: flex; align-items: center; gap: 8px; padding-top: 18px; }
.check-row label { font-weight: 600; color: var(--title); text-transform: none; font-size: 13px; }
.check-row input { width: 16px; height: 16px; }

/* ===== Dugmad ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border: 1px solid var(--border); background: #fff; border-radius: 4px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--title);
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn .ico { font-size: 14px; line-height: 1; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #278a3b; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #bd3a3a; }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: #265bd4; }
.btn-icon { padding: 6px 8px; }
.btn-mini { padding: 2px 8px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.table-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.table-actions .spacer { flex: 1; }

/* ===== Tabela ===== */
.tbl-wrap { border: 1px solid var(--border); border-radius: 5px; overflow: auto; max-height: 46vh; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th {
  position: sticky; top: 0; background: #eef1f6; color: var(--title);
  text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border);
  font-size: 12px; white-space: nowrap; z-index: 1;
}
table.tbl tbody td { padding: 7px 10px; border-bottom: 1px solid #eef0f3; }
table.tbl tbody tr { cursor: pointer; }
table.tbl tbody tr:hover { background: var(--hover); }
table.tbl tbody tr.selected { background: var(--blue-row); }
table.tbl tbody tr.selected:hover { background: var(--blue-row-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.ctr, table.tbl th.ctr { text-align: center; }
.empty-row td { text-align: center; color: var(--muted); padding: 20px; cursor: default; }

/* Ukupni red */
.totals-bar {
  display: flex; gap: 24px; padding: 10px 14px; background: #eef1f6;
  border-top: 2px solid var(--border); font-weight: 700; flex-wrap: wrap;
}
.totals-bar .t { display: flex; flex-direction: column; }
.totals-bar .t span { font-size: 11px; color: var(--muted); font-weight: 600; }
.totals-bar .t b { font-size: 15px; color: var(--title); font-variant-numeric: tabular-nums; }

/* ===== Dropdown ===== */
.dropdown {
  position: fixed; z-index: 200; background: #fff; border: 1px solid var(--border);
  border-radius: 5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 220px; padding: 4px;
}
.dropdown .dd-item { padding: 8px 12px; cursor: pointer; border-radius: 4px; }
.dropdown .dd-item:hover { background: var(--hover); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; background: rgba(20,25,40,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.4);
  width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column;
}
.modal .view-title { border-radius: 6px 6px 0 0; display: flex; justify-content: space-between; align-items: center; }
.modal .view-title .close { cursor: pointer; color: #fff; font-size: 18px; padding: 0 6px; }
.modal-body { padding: 16px; overflow: auto; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.kv .item { border-bottom: 1px dashed #e3e6ea; padding: 6px 0; }
.kv .item .k { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.kv .item .v { font-size: 14px; font-weight: 600; color: var(--title); margin-top: 2px; }
.kv .item.full { grid-column: 1 / -1; }

/* ===== Print ===== */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; left: 0; top: 0; width: 100%; }
  .print-doc { font-family: "Times New Roman", serif; padding: 30px; color: #000; }
  .print-doc h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
  .print-doc .sub { text-align: center; font-size: 13px; margin-bottom: 20px; }
  .print-doc table { width: 100%; border-collapse: collapse; margin-top: 10px; }
  .print-doc table th, .print-doc table td { border: 1px solid #000; padding: 6px 8px; font-size: 12px; text-align: left; }
  .print-doc table th { background: #eee; }
  .print-doc .totals { margin-top: 12px; text-align: right; font-weight: bold; }
}

/* Račun (invoice) – print */
@media print {
  .print-doc.inv { padding: 24px; }
  .print-doc.inv .inv-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 12px; margin-bottom: 14px; }
  .print-doc.inv .inv-left { display: flex; align-items: flex-start; gap: 12px; }
  .print-doc.inv .inv-logo { max-height: 64px; max-width: 160px; }
  .print-doc.inv .inv-provider { font-size: 12px; line-height: 1.55; }
  .print-doc.inv .inv-provider b { font-size: 15px; }
  .print-doc.inv .inv-title { text-align: right; }
  .print-doc.inv .inv-title h1 { font-size: 24px; letter-spacing: 3px; margin: 0; }
  .print-doc.inv .inv-title .inv-no { font-size: 13px; margin-top: 6px; }
  .print-doc.inv .inv-meta { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 12px; }
  .print-doc.inv .inv-client { border: 1px solid #000; padding: 10px 12px; margin-bottom: 12px; font-size: 12px; line-height: 1.5; }
  .print-doc.inv .inv-client .lbl { font-weight: bold; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; margin-bottom: 4px; }
  .print-doc.inv .inv-table { margin-top: 0; }
  .print-doc.inv .inv-table th.num, .print-doc.inv .inv-table td.num { text-align: right; }
  .print-doc.inv .inv-totals { width: 340px; margin: 12px 0 0 auto; }
  .print-doc.inv .inv-totals table { margin-top: 0; }
  .print-doc.inv .inv-totals td { padding: 4px 8px; font-size: 12px; }
  .print-doc.inv .inv-totals td.num { text-align: right; }
  .print-doc.inv .inv-totals .grand td { font-weight: bold; font-size: 14px; border-top: 2px solid #000; }
  .print-doc.inv .inv-note { margin-top: 18px; font-size: 11px; color: #222; border-top: 1px solid #999; padding-top: 8px; }
  .print-doc.inv .inv-footer { display: flex; justify-content: flex-end; margin-top: 22px; }
  .print-doc.inv .inv-qr { text-align: center; }
  .print-doc.inv .inv-qr-img { width: 110px; height: 110px; image-rendering: pixelated; }
  .print-doc.inv .inv-qr-label { font-size: 10px; font-weight: bold; margin-top: 4px; letter-spacing: 1px; }
}

/* Ugovor – print */
@media print {
  .print-doc.ugovor { font-family: "Times New Roman", serif; padding: 40px 50px; color: #000; font-size: 12pt; line-height: 1.6; }
  .print-doc.ugovor h1 { font-size: 16pt; text-align: center; letter-spacing: 4px; margin-bottom: 2px; }
  .print-doc.ugovor .ug-subtitle { text-align: center; font-size: 12pt; margin-bottom: 24px; }
  .print-doc.ugovor .ug-lead { margin-bottom: 16px; }
  .print-doc.ugovor .ug-tekst { text-align: justify; margin-bottom: 8px; text-indent: 1.5em; }
  .print-doc.ugovor .ug-chlan { font-weight: bold; margin-top: 14px; margin-bottom: 4px; text-indent: 1.5em; }
  .print-doc.ugovor .ug-signatures { display: flex; justify-content: space-between; margin-top: 60px; }
  .print-doc.ugovor .ug-sig { text-align: center; width: 45%; }
  .print-doc.ugovor .ug-sig p { margin: 4px 0; }
  .print-doc.ugovor .ug-sig-line { margin-top: 40px; letter-spacing: 2px; }
}

/* tip badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2a44; color: #fff; padding: 10px 20px; border-radius: 6px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.badge.GA { background: #e3f2e6; color: #2e7d32; }
.badge.GR { background: #e7efff; color: #1a56c4; }
.badge.GK { background: #fff0e0; color: #c05600; }
