:root {
  --navy: #003b7e;
  --navy-deep: #002858;
  --navy-mid: #0a4a94;
  --navy-soft: #e8eef6;
  --red: #d31219;
  --red-deep: #a50e14;
  --red-soft: #fde8e9;
  --bg: #f4f7fb;
  --ink: #0f1b2d;
  --muted: #5a6b82;
  --card: #ffffff;
  --line: #d7e0ec;
  --ok: #1f8f55;
  --ok-soft: #e6f6ee;
  --warn: #c48a00;
  --warn-soft: #fff6db;
  --danger: #d31219;
  --shadow: 0 14px 40px rgba(0, 59, 126, 0.09);
  --shadow-sm: 0 4px 16px rgba(0, 59, 126, 0.07);
  --radius: 18px;
  --font: "Source Sans 3", "Segoe UI", Candara, sans-serif;
  --display: "Libre Baskerville", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(980px 480px at -5% -15%, rgba(211, 18, 25, 0.08), transparent 55%),
    radial-gradient(900px 460px at 105% -5%, rgba(0, 59, 126, 0.12), transparent 52%),
    linear-gradient(180deg, #eef3fa 0%, var(--bg) 38%, #f8fafc 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--red); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.5rem;
  min-height: 64px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(215, 224, 236, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--red) 0%, var(--red) 28%, var(--navy) 28%, var(--navy) 100%);
  opacity: .95;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .85rem;
  color: var(--navy);
  text-decoration: none;
  min-height: 44px;
}
.brand:hover { color: var(--navy); text-decoration: none; }
.brand-logo {
  display: block;
  height: 42px;
  width: auto;
  max-width: min(320px, 52vw);
  object-fit: contain;
  object-position: left center;
}
.brand-text {
  display: grid;
  line-height: 1.15;
  padding-left: .85rem;
  border-left: 1px solid var(--line);
}
.brand-text small {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  gap: .85rem;
  align-items: center;
  flex-wrap: wrap;
}
.topbar nav > a:not(.btn) {
  color: var(--navy);
  font-weight: 700;
  padding: .4rem .15rem;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.topbar nav > a:not(.btn):hover {
  color: var(--red);
  border-bottom-color: var(--red);
  text-decoration: none;
}
.user {
  color: var(--navy);
  font-size: .9rem;
  font-weight: 650;
  padding: .4rem .85rem;
  background: var(--navy-soft);
  border-radius: 999px;
}

.wrap {
  width: min(1560px, calc(100% - 1.5rem));
  margin: 1.75rem auto 3.25rem;
}

.card {
  background: var(--card);
  border: 1px solid rgba(215, 224, 236, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--red), var(--navy));
}

h1 {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-size: clamp(1.4rem, 2.3vw, 1.8rem);
  color: var(--navy-deep);
  letter-spacing: -.015em;
  font-weight: 700;
}
h2 {
  margin: 0 0 .85rem;
  font-size: .78rem;
  color: var(--navy);
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 800;
}
.muted { color: var(--muted); }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: .85rem;
  flex-wrap: wrap;
}
.page-head h1 { margin-bottom: .2rem; }
.page-head p { margin: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
  align-items: end;
}
.toolbar form {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: end;
  flex: 1;
}

label {
  display: grid;
  gap: .35rem;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 700;
}
input, select, textarea, button, .btn { font: inherit; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .72rem .9rem;
  background: #fff;
  color: var(--ink);
  min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #7fa0c9;
  box-shadow: 0 0 0 3px rgba(0, 59, 126, 0.14);
}
textarea { min-height: 90px; resize: vertical; }

.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 0;
  border-radius: 999px;
  padding: .7rem 1.25rem;
  background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy-deep) 100%);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
  box-shadow: 0 10px 22px rgba(0, 59, 126, 0.24);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.btn:hover, button:hover {
  filter: brightness(1.05);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(0, 59, 126, 0.28);
}
.btn-accent {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  box-shadow: 0 10px 22px rgba(211, 18, 25, 0.25);
}
.btn-ghost {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn-ghost:hover {
  border-color: var(--navy);
  color: var(--navy);
  filter: none;
  box-shadow: none;
}
.btn-danger {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  box-shadow: 0 8px 18px rgba(211, 18, 25, 0.22);
}
.btn-secondary { background: #334155; box-shadow: none; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: .42rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: .92rem;
  line-height: 1.25;
}
.table th {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 800;
  padding: .5rem .5rem;
}
.table tbody tr {
  transition: background .12s ease;
}
.table tbody tr:hover { background: #f5f9ff; }
.table a,
.table a strong {
  color: var(--navy);
  font-family: var(--font);
  font-style: normal;
  font-size: inherit;
  font-weight: 700;
}
.table a:hover,
.table a:hover strong {
  color: var(--red);
  text-decoration: none;
}
.table .badge {
  padding: .12rem .5rem;
  font-size: .74rem;
}

.badge {
  display: inline-block;
  padding: .24rem .7rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .02em;
}
.badge-nov { background: var(--navy-soft); color: var(--navy); }
.badge-u_radu { background: #e7f3ff; color: #0b5cab; }
.badge-na_cekanju { background: var(--warn-soft); color: #8a6200; }
.badge-zavrsen { background: var(--ok-soft); color: #146c2e; }
.badge-arhiviran { background: #eceff3; color: #556070; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.55fr);
  gap: 1.25rem;
  align-items: start;
}
.case-layout .stack {
  align-content: start;
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .brand-logo { height: 36px; max-width: 240px; }
  .brand-text { padding-left: .65rem; }
  .doc-category-head { flex-direction: column; align-items: stretch; }
  .doc-category-actions { width: 100%; }
  .doc-upload-btn { flex: 1; }
  .doc-category-rail {
    position: static;
    transform: none;
    margin: 0 0 .35rem;
    align-items: center;
    width: auto;
    top: auto;
    bottom: auto;
  }
  .doc-category.has-postit-open .doc-category-rail {
    width: min(180px, 100%);
    align-items: stretch;
    position: relative;
    padding-top: .35rem;
  }
  .doc-category.has-postit-open .postit {
    height: 150px;
    max-height: 150px;
  }
  .doc-category.has-postit-open .postit-toggle {
    top: .45rem;
    left: -32px;
    transform: none;
  }
  .doc-row { flex-direction: column; }
}

.stack { display: grid; gap: 1rem; }
.case-stack { gap: .55rem; }
.meta { display: grid; gap: .55rem; font-size: .98rem; }
.meta strong { color: var(--muted); font-weight: 750; margin-right: .35rem; }

.card.case-summary {
  padding: .85rem 1.15rem .9rem;
}
.case-summary .back-link {
  display: inline-block;
  margin-bottom: .25rem;
  font-size: .88rem;
}
.case-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .45rem;
}
.case-title {
  margin: 0;
  font-family: var(--font);
  font-style: normal;
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  color: var(--navy);
  letter-spacing: normal;
  font-weight: 650;
  line-height: 1.15;
}
.case-subtitle {
  margin: .2rem 0 0;
  font-size: .88rem;
  line-height: 1.3;
}
.case-meta-inline {
  gap: .2rem;
  font-size: .9rem;
}
.case-summary-notes {
  margin: .45rem 0 0;
  line-height: 1.45;
  font-size: .94rem;
}
.case-summary-head .badge {
  flex-shrink: 0;
  margin-top: .1rem;
}
.case-docs > h2 {
  margin-bottom: .55rem;
}
.case-docs > .muted {
  margin-bottom: .75rem !important;
}

.flash {
  padding: .95rem 1.1rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  font-weight: 600;
}
.flash-ok { background: var(--ok-soft); border-color: #b6e0c7; color: #146c2e; }
.flash-error { background: var(--red-soft); border-color: #f3b6b8; color: var(--red-deep); }

.login-wrap {
  min-height: calc(100vh - 5.5rem);
  display: grid;
  place-items: center;
  padding: 1rem 0 2rem;
}
.login-card {
  width: min(420px, 100%);
  text-align: center;
  padding: 2rem 1.75rem 1.75rem;
}
.login-card::before { display: none; }
.login-logo {
  width: min(100%, 320px);
  height: auto;
  margin: 0 auto 1.35rem;
  display: block;
}
.login-card h1 {
  margin-bottom: .35rem;
}
.login-card .muted {
  margin: 0 0 1.25rem;
}
.login-card form {
  text-align: left;
}
.login-card button {
  width: 100%;
  margin-top: .25rem;
}

.doc-list, .activity-list, .comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.doc-list li, .activity-list li, .comment-list li {
  padding: .9rem 0;
  border-bottom: 1px solid var(--line);
}
.doc-list li:last-child { border-bottom: 0; }
.doc-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.doc-actions form { margin: 0; }

.card.case-docs {
  overflow: visible;
}
.doc-categories {
  display: grid;
  gap: 1rem;
}
.doc-category {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .85rem 1rem;
  background: linear-gradient(180deg, #fbfdff 0%, #fff 100%);
  display: block;
  position: relative;
  overflow: visible;
}
.doc-category-rail {
  position: absolute;
  right: calc(100% + .35rem);
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 4;
  width: 26px;
  box-sizing: border-box;
}
.doc-category.has-postit-open .doc-category-rail {
  width: 158px;
  align-items: stretch;
}
.doc-category-main { min-width: 0; }
.doc-category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .85rem;
  margin-bottom: .65rem;
  flex-wrap: wrap;
}
.doc-category-title {
  flex: 0 0 auto;
  min-width: 110px;
}
.doc-category-actions {
  display: flex;
  gap: .55rem;
  flex: 0 0 auto;
  align-items: center;
  align-self: center;
}
.doc-category.is-step-done {
  border-color: #6aad82;
  background: linear-gradient(180deg, #dceee3 0%, #e8f4eb 100%);
  box-shadow: inset 0 0 0 1px rgba(22, 122, 58, 0.08);
}
.doc-subsection {
  margin-top: .85rem;
  padding-top: .85rem;
  border-top: 1px dashed var(--line);
}
.doc-subsection h4 {
  margin: 0 0 .65rem;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}
.doc-upload-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.doc-category h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--navy-deep);
  font-family: var(--display);
  font-style: italic;
}
.doc-category-meta {
  margin: .2rem 0 0;
  font-size: .85rem;
}
.doc-category-note-wrap {
  flex: 1 1 220px;
  display: grid;
  gap: .35rem;
  margin: 0;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 700;
  min-width: 0;
}
.doc-category-note {
  min-height: 44px;
  resize: vertical;
  width: 100%;
}

.postit-toggle {
  position: relative;
  z-index: 5;
  width: 28px;
  height: 28px;
  margin-top: .2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  flex: 0 0 auto;
  align-self: center;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.doc-category.has-postit-open .postit-toggle {
  position: absolute;
  top: .45rem;
  left: -34px;
  right: auto;
  margin-top: 0;
  margin-left: 0;
  transform: none;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 59, 126, .25);
}
.doc-category.has-postit-open .postit-toggle-icon {
  transform: scaleX(-1);
}
.postit-toggle:hover {
  transform: none;
  filter: none;
  border-color: var(--navy);
  background: var(--navy-soft);
  color: var(--navy-deep);
}
.postit-toggle-icon {
  display: grid;
  place-items: center;
  pointer-events: none;
  line-height: 0;
  transition: transform .15s ease;
}
.postit-toggle-icon svg {
  display: block;
}
.postit-toggle.is-on {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 59, 126, .25);
}
.doc-category.has-postit-open .postit-toggle:hover,
.postit-toggle.is-on:hover {
  background: var(--navy-deep);
  border-color: var(--navy-deep);
  color: #fff;
}
.postit {
  position: relative;
  width: 158px;
  height: 100%;
  max-height: 100%;
  box-sizing: border-box;
  background: #fff3a0;
  border: 1px solid #e6d36a;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.08);
  padding: .7rem .55rem .5rem;
  transform: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.postit[hidden] { display: none !important; }
.postit-body {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  border: 0;
  background: transparent;
  resize: none;
  overflow-y: auto;
  font-family: "Segoe Print", "Comic Sans MS", Candara, sans-serif;
  font-size: .85rem;
  line-height: 1.35;
  color: #3a2f12;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}
.postit-body:focus {
  outline: none;
  box-shadow: none;
  border: 0;
}
.doc-empty {
  margin: 0;
  font-size: .92rem;
}
.doc-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.doc-row-main { min-width: 0; flex: 1; }
.doc-filename {
  font-weight: 800;
  color: var(--navy-deep);
  line-height: 1.35;
  word-break: break-word;
}
.doc-meta {
  margin-top: .2rem;
  font-size: .88rem;
  line-height: 1.4;
}
.doc-note {
  margin: .45rem 0 0;
  padding: .55rem .7rem;
  border-radius: 10px;
  background: var(--navy-soft);
  color: var(--ink);
  font-size: .92rem;
  line-height: 1.45;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: #f8fbff;
  text-align: center;
}
.dropzone.drag { border-color: var(--navy); background: var(--navy-soft); }
.progress {
  height: 8px;
  background: #e4ebf4;
  border-radius: 999px;
  overflow: hidden;
  margin-top: .75rem;
  display: none;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--navy), var(--red));
}

.live-dot {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
  margin-right: .35rem;
  box-shadow: 0 0 0 0 rgba(211, 18, 25, .45);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(211, 18, 25, .4); }
  70% { box-shadow: 0 0 0 8px rgba(211, 18, 25, 0); }
  100% { box-shadow: 0 0 0 0 rgba(211, 18, 25, 0); }
}

.doc-icons {
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  margin: .35rem 0 1rem;
}
.doc-icon {
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 15px;
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.doc-icon:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: var(--shadow);
}
.doc-icon.is-empty {
  background: linear-gradient(160deg, #ffd56a, #e8a817);
  color: #5c4300;
}
.doc-icon.is-done {
  background: linear-gradient(160deg, #3bb56f, #1a7a48);
  color: #fff;
}
.doc-icon-num {
  position: absolute;
  right: .32rem;
  bottom: .18rem;
  font-size: .72rem;
  font-weight: 800;
  opacity: .95;
}
.doc-icon-glyph { display: grid; place-items: center; }
#uploadBox .progress { margin-top: .5rem; }

.back-link {
  font-weight: 700;
  font-size: .92rem;
}

.case-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .55rem;
}
.field-label {
  font-size: .82rem;
  color: var(--muted);
  font-weight: 700;
}

.service-toggle-board {
  display: grid;
  gap: .85rem;
}
.service-toggle-group-label {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: .45rem;
}
.service-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.service-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.service-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.service-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  padding: .35rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-weight: 700;
  font-size: .88rem;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.service-chip.is-on span,
.service-chip input:checked + span {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.service-chip:hover span {
  border-color: var(--navy);
}

.service-dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  width: min(560px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  box-shadow: var(--shadow);
}
.service-dialog::backdrop {
  background: rgba(15, 27, 45, 0.45);
}
.service-dialog-inner {
  padding: 1.15rem 1.25rem 1.25rem;
}
.service-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-bottom: .35rem;
}
.service-dialog-head h2 {
  margin: 0;
}
.service-dialog-close {
  font-size: 1.4rem;
  line-height: 1;
  padding: .25rem .7rem;
  min-width: 0;
}
.service-dialog-actions {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
