:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #126c5f;
  --primary-dark: #0c5047;
  --warn: #9a5b00;
  --danger: #a83434;
  --ok: #276749;
  --review: #5b4aa0;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.nav { display: flex; gap: 16px; flex: 1; }
.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px 56px; }
.wide-container { max-width: 1720px; padding-left: 18px; padding-right: 18px; }
h1 { margin: 0; font-size: 28px; }
h2 { margin: 0 0 16px; font-size: 18px; }
.muted { color: var(--muted); margin: 4px 0 0; }
.small { font-size: 13px; }
.page-head, .section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.panel, .auth-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.auth-box { max-width: 420px; margin: 56px auto; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metrics div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.metrics strong { display: block; font-size: 26px; }
.metrics span { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters a, .button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.filters a.active, .primary, button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.primary:hover { background: var(--primary-dark); text-decoration: none; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  min-height: auto;
}
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  background: #edf2f7;
}
.badge.sve-ok { color: var(--ok); background: #e7f5ee; }
.badge.fali-dokumentacija, .badge.nema-ništa-poslano { color: var(--warn); background: #fff3db; }
.badge.treba-pregled { color: var(--review); background: #efebff; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.small-gap { gap: 8px; }
.inline { display: flex; gap: 8px; align-items: center; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.checkbox { flex-direction: row; align-items: center; font-weight: 400; }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #c8d0dc;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }
.two-col, .upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
}
.copy-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  gap: 8px;
  align-items: center;
}
.details { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 12px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.alert { border-radius: 6px; padding: 10px 12px; }
.alert.error { background: #fdecec; color: var(--danger); }
.alert.success { background: #e7f5ee; color: var(--ok); }
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #111827;
  color: #f9fafb;
  padding: 16px;
  border-radius: 6px;
}
.preview-frame {
  width: 100%;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.preview-image {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.thumb {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}
.thumb-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}
.drop-zone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 18px;
  border: 2px dashed #a7b3c5;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
}
.drop-zone.is-dragging {
  border-color: var(--primary);
  background: #e7f5ee;
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-zone button {
  position: relative;
  z-index: 1;
}
.selected-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.selected-files span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
}
.upload-list {
  display: grid;
  gap: 8px;
}
.upload-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.upload-item:last-child { border-bottom: 0; }
.upload-item span, .upload-item small {
  display: block;
  color: var(--muted);
}
.review-workspace {
  display: grid;
  grid-template-columns: minmax(520px, 4fr) minmax(320px, 2.5fr) minmax(460px, 3.5fr);
  gap: 14px;
  align-items: start;
}
.review-left, .review-middle, .review-preview { min-width: 0; }
.compact-panel { padding: 14px; }
.review-list, .document-cards {
  display: grid;
  gap: 10px;
}
.review-row, .document-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}
.review-row p { margin: 4px 0; }
.review-row span, .document-card small {
  display: block;
  color: var(--muted);
}
.bank-doc-button {
  width: 100%;
  text-align: left;
  display: block;
  cursor: pointer;
}
.state-ok { border-left-color: var(--ok); background: #f3fbf7; }
.state-warn { border-left-color: #c47b00; background: #fffaf0; }
.state-bad { border-left-color: var(--danger); background: #fff7f7; }
.state-muted { border-left-color: #98a2b3; background: #f8fafc; }
.document-card.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.transaction-card.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.bank-table-wrap {
  max-height: calc(100vh - 250px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.bank-transactions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bank-transactions-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
}
.bank-transactions-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: middle;
}
.bank-transactions-table tr:last-child td { border-bottom: 0; }
.transaction-row.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.tx-status {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
}
.tx-status-ok { color: var(--ok); background: #e7f5ee; }
.tx-status-warn { color: var(--warn); background: #fff3db; }
.tx-status-bad { color: var(--danger); background: #fdecec; }
.tx-status-muted { color: #475467; background: #eef2f6; }
.transaction-description {
  max-width: 100%;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.linked-doc {
  max-width: 140px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.amount-cell {
  font-weight: 700;
}
.nowrap {
  white-space: nowrap;
}
.tx-row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.tx-row-actions button {
  min-height: 28px;
  padding: 4px 7px;
  font-size: 12px;
}
.missing-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.missing-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}
.missing-summary strong {
  display: block;
  font-size: 22px;
}
.missing-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.transaction-select {
  width: 100%;
  border: 0;
  padding: 0;
  text-align: left;
  background: transparent;
  cursor: pointer;
}
.transaction-documents.is-hidden {
  display: none;
}
.transaction-documents h3 {
  margin: 16px 0 8px;
  font-size: 15px;
}
.match-reason {
  color: var(--primary);
  font-weight: 700;
}
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.tx-actions {
  flex-wrap: wrap;
}
.document-select {
  width: 100%;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  justify-content: start;
  text-align: left;
  border: 0;
  padding: 0;
  background: transparent;
}
.document-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 10px;
}
.document-actions textarea { grid-column: 1 / -1; }
.sticky-preview {
  position: sticky;
  top: 76px;
}
.inline-preview {
  min-height: 680px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}
.review-preview-frame {
  width: 100%;
  height: 820px;
  border: 0;
  background: #fff;
}
.review-preview-image {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.12s ease;
}
.missing-list { padding-left: 18px; }
.status-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}
.status-ok { color: var(--ok); background: #e7f5ee; }
.status-warn { color: var(--warn); background: #fff3db; }
.status-bad { color: var(--danger); background: #fdecec; }
.status-muted { color: #475467; background: #eef2f6; }
.email-modal {
  width: min(860px, calc(100vw - 32px));
  margin: 30px auto;
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
}
.compact-check {
  grid-template-columns: minmax(0, 1fr);
}
.preview-overlay[hidden] { display: none; }
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(17, 24, 39, 0.92);
  display: flex;
  flex-direction: column;
}
.preview-overlay-bar {
  height: 54px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
}
.preview-overlay-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}
.preview-overlay-body iframe {
  width: 100%;
  min-height: calc(100vh - 90px);
  border: 0;
  background: #fff;
}
.preview-overlay-body img {
  display: block;
  max-width: 100%;
  margin: 0 auto;
}

@media (max-width: 760px) {
  .topbar { height: auto; padding: 14px 16px; flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .metrics, .form-grid, .two-col, .upload-layout { grid-template-columns: 1fr; }
  .page-head, .section-head, .copy-line, .check-row { grid-template-columns: 1fr; display: grid; }
  .inline { align-items: stretch; }
}

@media (max-width: 1180px) {
  .review-workspace { grid-template-columns: 1fr; }
  .sticky-preview { position: static; }
  .inline-preview { max-height: none; }
}
