* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  max-width: 1900px;
  margin: 0 auto;
  padding: 1.5rem;
  color: #1a1a1a;
  background: #fafafa;
}
h1, h2 { margin-top: 0; }
a { color: #0b5fff; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { margin-bottom: 1rem; }
.topbar-row { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.nav-tabs { display: block; margin-top: 0.4rem; }
.nav-admin a { color: #9a1d1d; }
.nav-cjenik-kupci a { color: #146c2e; font-weight: 600; }
.ident-link { color: inherit; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 0.5rem 0.6rem; border-bottom: 1px solid #e5e5e5; font-size: 0.9rem; vertical-align: top; }
th { text-align: left; background: #f0f0f0; position: sticky; top: 0; }
tr.skipped { opacity: 0.5; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-exact { background: #d7f5dd; color: #146c2e; }
.badge-alias { background: #d7f5dd; color: #146c2e; }
.badge-prefix { background: #ffe9c7; color: #8a5300; }
.badge-fuzzy { background: #fde3d0; color: #9a3b12; }
.badge-group { background: #dce6ff; color: #23408f; }
.badge-none { background: #f4d3d3; color: #8f1d1d; }
.badge-skip { background: #eee; color: #666; }
.badge-lg { font-size: 0.95rem; padding: 0.3rem 0.8rem; }

.pill-ok { color: #146c2e; font-weight: 600; }
.pill-warn { color: #9a3b12; font-weight: 600; }
.ident-suggest { font-size: 0.9rem; font-weight: 600; color: #1a1a1a; margin-top: 0.2rem; }
.ident-suggest .note { font-weight: 400; }

button, input[type=submit] {
  cursor: pointer;
  border: 1px solid #ccc;
  background: #fff;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-size: 0.85rem;
}
button.primary { background: #0b5fff; color: #fff; border-color: #0b5fff; }
button.danger { background: #fff; color: #9a1d1d; border-color: #cc8a8a; }
button.excel { background: #1a7f37; color: #fff; border-color: #1a7f37; }
button:hover { background: #f0f4ff; }
button.primary:hover { background: #094ecf; }
button.excel:hover { background: #166b2e; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.8rem 1rem;
}
.filter-row + .filter-row { margin-top: 0.9rem; }
.filter-row.filter-actions { align-items: center; }
.filter-field { flex: 1 1 160px; min-width: 140px; }
.filter-spacer { flex: 1 1 auto; }

input[type=text], input[type=number] {
  padding: 0.3rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
  width: 100%;
}

.search-box { position: relative; }
.search-results {
  position: absolute;
  z-index: 10;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
/* Rezultati "kopiraj od sličnog artikla" (_clone_search_results.html) su dvoredni (ime +
   sitan redak nabavna/troškovi/marža) - veći max-height nego obični jednoredni
   _search_results.html, da stanu barem 4 retka, skalirano samo za ovaj partial da ne
   dira ostale search-box-ove (dobavljač/ident pretraga i dalje 220px).
   position:static (ne absolute kao .search-results) - inače ovaj viši dropdown
   prekriva gumbe/polja ispod njega (npr. "Odustani" na /cijene je bio neklikabilan dok
   je dropdown otvoren, vidi razgovor) - ovako razmakne sadržaj umjesto da ga prekrije. */
.search-results-clone { position: static; max-height: 320px; margin-top: 0.2rem; }
/* Ident-pretraga na /cjenik-kupci je zadnje polje u retku filtera, odmah iznad retka s
   gumbima "Prikaži cjenik"/"Izvoz u Excel" - apsolutno pozicioniran .search-results bi
   prekrio te gumbe dok je dropdown otvoren (isti problem kao .search-results-clone
   gore), zato i ovdje position:static da gura sadržaj ispod umjesto da ga prekriva. */
#ck_ident_results .search-results { position: static; margin-top: 0.2rem; }
.search-results div {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid #eee;
}
.search-results div:hover { background: #f0f4ff; }
.search-results div.katalog-rezultat { background: #fff8ec; border-left: 3px solid #e0a030; }
.search-results div.katalog-rezultat:hover { background: #ffefd4; }
.search-results .score { color: #888; font-size: 0.75rem; }

.note { font-size: 0.78rem; color: #777; margin-top: 0.2rem; }
.upload-box, .card {
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 1.2rem; margin-bottom: 1.2rem;
}
.totals { display: flex; gap: 2rem; margin-top: 1rem; font-size: 0.95rem; }
.totals b { font-size: 1.05rem; }
.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-error { background: #fde3d0; color: #9a3b12; }
.flash-ok { background: #d7f5dd; color: #146c2e; }
.actions button { margin-right: 0.3rem; }

.sql-step { margin-bottom: 1rem; }
.sql-step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 0.45rem 0.8rem;
  border-radius: 6px 6px 0 0;
  font-size: 0.85rem;
  font-weight: 600;
}
.sql-block {
  background: #11111b;
  color: #cdd6f4;
  margin: 0;
  padding: 0.8rem;
  border-radius: 0 0 6px 6px;
  overflow-x: auto;
  font-size: 0.82rem;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  line-height: 1.5;
}
.sql-block code { white-space: pre; }
.sql-keyword { color: #cba6f7; font-weight: 600; }
.sql-string { color: #a6e3a1; }
.sql-number { color: #fab387; }
.sql-comment { color: #6c7086; font-style: italic; }
.sql-copy-btn {
  background: #313244;
  color: #cdd6f4;
  border: 1px solid #45475a;
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.sql-copy-btn:hover { background: #45475a; }
.sql-copy-btn.copied { background: #a6e3a1; color: #11111b; border-color: #a6e3a1; }
