/* ===========================
   GLOBAL STYLE
   =========================== */

/* Theme tokens */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --primary: #1e5aa7;
  --primary-strong: #174a8a;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.12);
  --status-pending-bg: #fef3c7;
  --status-pending-text: #92400e;
  --status-info-bg: #dbeafe;
  --status-info-text: #1d4ed8;
  --status-success-bg: #dcfce7;
  --status-success-text: #166534;
  --status-danger-bg: #fee2e2;
  --status-danger-text: #b91c1c;
  --status-neutral-bg: #e2e8f0;
  --status-neutral-text: #334155;
}

/* Font i pozadina */
body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* === Pozadinski APTI wallpaper — identično VPN-APP === */
body {
  margin: 0;
  background: var(--bg);
  position: relative;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

/* Centralna svetla vertikalna traka (360px kao u VPN-APP) */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 100vw);     /* širina trake */
  height: 100vh;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.78) 0%,
    rgba(255, 255, 255, 0.62) 40%,
    rgba(255, 255, 255, 0.55) 100%
  );
  backdrop-filter: blur(2px);
  z-index: -1;                 /* traka iza login forme */
}

/* Diskretan centralni logo u pozadini (10% opacity) */
body::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(280px, 80vw);
  height: min(280px, 80vw);
  transform: translate(-50%, -50%);
  background-image: url("Amistad LOGO 5.svg");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.05;  /*malo smanjen uticaj */
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.16)) blur(0.2px);
  z-index: -2;                 /* logo ispred trake ali ispod login boxa */
}


/* ===========================
   LOGIN PAGE
   =========================== */

/* PERFECT CENTERING LOGIN CONTAINER */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  height: 100vh;
  padding: 35px;
  border-radius: var(--radius);

  background: linear-gradient(180deg, #f9fbfd 0%, #eef2f7 100%);
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.6s ease-out;
}



.app-title {
  text-align: center;
  margin-bottom: 25px;
}

.logo {
  width: 160px;
  margin-bottom: 20px;
  opacity: 0;
  animation: fadeInUp 0.8s ease-out forwards;
}

.app-title-main {
  font-size: 2.2rem;
  color: #c01531;
  margin: 0;
  opacity: 0;
  animation: fadeInUp 1s ease-out forwards;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.15);
}

.app-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 0;
  opacity: 0;
  animation: fadeInUp 1.2s ease-out forwards;
}

/* Animacija */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Login forma */
.login-form {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-form input {
  width: 260px;
  padding: 10px;
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  box-sizing: border-box;
  background: var(--surface);
}

/* ===========================
   BUTTONS (global)
   =========================== */

button,
.btn,
.btn-primary {
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.05rem;
  transition: background-color 0.2s, transform 0.15s ease, box-shadow 0.2s;
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary,
#loginBtn {
  background-color: var(--primary);
}

.btn-primary:hover,
#loginBtn:hover {
  background-color: var(--primary-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Zelena (npr. confirm / PTI / save) */
.btn-green {
  background-color: var(--success) !important;
}
.btn-green:hover {
  background-color: #16a34a !important;
  transform: translateY(-1px);
}

/* Crvena (logout, brisanje, baza plombe) */
.btn-red {
  background-color: var(--danger) !important;
}
.btn-red:hover {
  background-color: #dc2626 !important;
  transform: translateY(-1px);
}

/* Narandžasta (admin specijalne akcije) */
.btn-orange {
  background-color: var(--warning) !important;
}
.btn-orange:hover {
  background-color: #d97706 !important;
  transform: translateY(-1px);
}
.admin-buttons {
  display: flex;
  gap: 12px;
  margin-top: 15px;
}

/* ===========================
   TABLES
   =========================== */

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 15px;
  font-size: 0.95rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

th {
  background: var(--surface-muted);
  padding: 10px;
  text-align: left;
  color: var(--text);
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:hover {
  background: #f8fafc;
}

table tbody tr:nth-child(even) {
  background: #fafcff;
}

/* ===========================
   CARDS (kao VPN meta-info)
   =========================== */

.card,
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  line-height: 1.4;
  margin: 5px;
}

.my-magacin-label {
  display: inline-block;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: #e9f2ff;
  border: 1px solid #cfe1ff;
  color: var(--primary);
  font-weight: 600;
}

/* ===========================
   MOBILE OPTIMIZATION (USER)
   =========================== */

@media (max-width: 600px) {
  body {
    font-size: 14px;
    line-height: 1.45;
  }

  .login-form input {
    width: 90vw;
    max-width: 330px;
  }

  button {
    width: 90vw;
    max-width: 330px;
    height: 40px;
    font-size: 14px;
  }

  /* Keep navbar buttons from stretching on small screens */
  .navbar .nav-logout,
  .navbar .nav-action {
    width: auto;
    max-width: none;
  }

  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding-bottom: 6px;
  }

  .nav-left {
    order: 1;
  }

  .nav-center {
    order: 2;
    flex: 1;
    text-align: center;
    padding: 4px 0;
  }

  .nav-right {
    order: 3;
    width: 100%;
    justify-content: flex-end;
    gap: 6px;
    margin-right: 6px;
  }

  .nav-title {
    font-size: 16px;
  }

  .nav-logo {
    height: 20px;
  }

  .nav-action,
  .nav-logout {
    padding: 5px 8px;
    font-size: 12px;
  }

  .item-row {
    flex-direction: column;
    align-items: stretch;
  }

  .item-row .item-qty,
  .item-row .item-name,
  .item-row .removeItemBtn {
    width: 100%;
    max-width: none;
  }

  .card,
  .result-card {
    margin: 10px 8px;
  }
}

/* ===========================
   USER PANEL MOBILE LAYOUT
   =========================== */

@media (max-width: 768px) {
  .admin-container {
    padding: 0 10px;
  }

  .user-search-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .user-search-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .user-search-form input,
  .user-search-form select,
  .user-search-form button {
    height: 40px;
    border-radius: var(--radius);
  }

  .user-search-form input,
  .user-search-form select,
  .user-search-form button,
  #requestNote {
    width: 100%;
    max-width: none;
  }

  .search-results-table,
  .search-results-table thead,
  .search-results-table tbody,
  .search-results-table th,
  .search-results-table td,
  .search-results-table tr {
    display: block;
    width: 100%;
  }

  .search-results-table thead {
    display: none;
  }

  .search-results-table tr {
    margin: 10px 0;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .search-results-table td:first-child {
    padding-top: 8px;
  }

  .search-results-table td:first-child::before {
    display: block;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #eef2f7;
  }

  .search-results-table td:first-child::after {
    content: "—";
    display: block;
    height: 2px;
    color: transparent;
  }

  .search-results-table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 6px 0;
    border-bottom: 1px solid #eef2f7;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .search-results-table td:last-child {
    border-bottom: 0;
  }

  .search-results-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
  }

  #myRequestsContainer table,
  #myRequestsContainer thead,
  #myRequestsContainer tbody,
  #myRequestsContainer th,
  #myRequestsContainer td,
  #myRequestsContainer tr,
  #myStockContainer table,
  #myStockContainer thead,
  #myStockContainer tbody,
  #myStockContainer th,
  #myStockContainer td,
  #myStockContainer tr {
    display: block;
    width: 100%;
  }

  #myRequestsContainer thead,
  #myStockContainer thead {
    display: none;
  }

  #myRequestsContainer tr,
  #myStockContainer tr {
    margin: 10px 0;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    box-shadow: var(--shadow-sm);
  }

  #myRequestsContainer td,
  #myStockContainer td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 6px 0;
    border-bottom: 1px solid #eef2f7;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #myRequestsContainer td:last-child,
  #myStockContainer td:last-child {
    border-bottom: 0;
  }

  #myRequestsContainer td::before,
  #myStockContainer td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
  }

  #myRequestsContainer td:first-child,
  #myStockContainer td:first-child {
    padding-top: 8px;
  }

  #myRequestsContainer td:first-child::before,
  #myStockContainer td:first-child::before {
    display: block;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #eef2f7;
  }

  #myRequestsContainer td:first-child::after,
  #myStockContainer td:first-child::after {
    content: "—";
    display: block;
    height: 2px;
    color: transparent;
  }

  /* My Requests mobile polish */
  #myRequestsContainer td[data-label="Akcije"] {
    gap: 8px;
  }

  #myRequestsContainer td[data-label="Akcije"] button {
    width: 100%;
  }

  /* Status emphasis */
  #myRequestsContainer td[data-label="Status"],
  #myStockContainer td[data-label="Status"] {
    padding: 6px 10px;
    border-radius: 999px;
    background: #e8f1ff;
    border: 1px solid #cfe1ff;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    align-self: flex-start;
  }

  /* Kompaktne akcije */
  #myRequestsContainer td[data-label="Akcije"] button,
  #myStockContainer td[data-label="Akcije"] button {
    height: 36px;
    font-size: 13px;
    padding: 6px 10px;
  }

  #myRequestsContainer tr,
  #myStockContainer tr {
    padding: 12px 12px;
  }

  #myRequestsContainer td,
  #myStockContainer td {
    padding: 8px 0;
  }

  #myRequestsFilters {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #ffffff;
    padding: 10px 8px;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  }
}

.admin-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 15px;
  padding: 8px 12px;
  background: var(--surface-muted);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  line-height: 1.4;
}

/* === SHOW/HIDE PASSWORD === */
.password-wrapper {
  position: relative;
  width: 260px;
}

.password-wrapper input {
  width: 100%;
  padding-right: 34px; /* prostor za ikonu */
}

.password-wrapper input:not([type="password"]) {
  padding-right: 10px; /* normalno poravnanje */
}

.toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.6;
  user-select: none;
}

.toggle-password:hover {
  opacity: 1;
}

/* === INPUT FOCUS ANIMATION === */
input[type="text"],
input[type="password"] {
  transition: all 0.25s ease;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 90, 167, 0.18);
  outline: none;
}

.eye-icon {
  width: 22px;
  height: 22px;
  fill: #444;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.toggle-password:hover .eye-icon {
  opacity: 1;
}

.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 12px;
  width: 320px;
  text-align: center;
}

.modal-content.change-password-modal {
  text-align: left;
}

.modal-content.change-password-modal .password-wrapper {
  width: 100%;
}

.modal-content.change-password-modal label {
  display: block;
  font-size: 13px;
  margin: 8px 0 4px;
}

.modal-content.change-password-modal input[type="password"],
.modal-content.change-password-modal input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.modal-actions button {
  flex: 1;
}

.key-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 6px;
  fill: white;
}

.btn-logout {
  background-color: #c62828;
  color: white;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.25s ease;
  float: right;
  margin-bottom: 15px;
}

.btn-logout:hover {
  background-color: #b71c1c;
  transform: scale(1.05);
}

/* === NAVBAR === */
.navbar {
  width: 100%;
  height: 56px;
  background: linear-gradient(90deg, #12325b 0%, #1e5aa7 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  box-shadow: var(--shadow-sm);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

.nav-left {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.nav-center {
  font-size: 15px;
  opacity: 0.9;
}

.nav-logout {
  background-color: var(--danger);
  color: white;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s, transform 0.15s ease, box-shadow 0.2s;

  /* === FIX: pomeranje od ivice === */
  margin-right: 15px;
}

.nav-logout:hover {
  background-color: #dc2626;
  transform: translateY(-1px);
}

.nav-right .nav-logout {
  margin-right: 0;
}

.nav-action {
  background-color: var(--primary);
  color: white;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s, transform 0.15s ease, box-shadow 0.2s;
}

.nav-action:hover {
  background-color: var(--primary-strong);
  transform: translateY(-1px);
}

/* === Dugme Osvezi — plava tema APTI === */
.btn-refresh {
  background-color: var(--primary); /* jaka plava */
  color: white;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s, transform 0.15s ease, box-shadow 0.2s;
  margin-top: 10px;
}

.btn-refresh:hover {
  background-color: var(--primary-strong);
  transform: translateY(-1px);
}

.field-error {
  color: #c0392b;
  font-size: 12px;
  margin-top: 4px;
}

.input-error {
  border: 1px solid #c0392b !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.15);
}

/* === NAVBAR LOGO === */
.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-title {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 1px;
}

.nav-logo {
  height: 26px;        /* idealna visina za navbar */
  width: auto;
  opacity: 0.95;
  filter: brightness(3.5);
}

/* ===============================
   NOVI ZAHTEV – RED ARTIKLA
   =============================== */

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

/* Kolona: Naziv robe (autocomplete) */
.item-autocomplete {
  flex: 1;
  position: relative;
}

.item-autocomplete input {
  width: 100%;
}

#rnList {
  max-height: 420px;
  overflow: auto;
}

/* Kolona: Količina */
.item-qty {
  width: 90px;
  text-align: center;
  flex-shrink: 0;
}

/* Dugme X */
.item-row .btn-red {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}


.hidden {
  display: none;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ccc;
  max-height: 160px;
  overflow-y: auto;
  z-index: 10;
}

.autocomplete-item {
  padding: 6px 8px;
  cursor: pointer;
}

.autocomplete-item:hover {
  background-color: #eef2f7;
}

button:disabled,
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Shipment (paketi) – manja dugmad */
#shipmentCreateBox .btn-primary,
#shipmentDetail .btn-primary,
#shipmentDetail .btn-refresh,
#shipmentDetail .btn-red {
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
}

#shipmentDetail .shipment-add-split,
#shipmentDetail .shipment-reset {
  padding: 4px 8px;
  font-size: 12px;
}

/* CRIS tabs active state */
.tab.active {
  background-color: #0d47a1; /* tamnija plava */
  box-shadow: inset 0 0 0 2px #ffffff55;
}

/* ===== CRIS TICKET CARD ===== */
.ticket-card {
  background: #f9fbfd;
  border: 1px solid #dce3eb;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.ticket-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.ticket-card td {
  padding: 4px 6px;
  vertical-align: top;
}

.ticket-card td.label {
  width: 150px;
  font-weight: 600;
  color: #444;
}

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.badge-active {
  background-color: #d32f2f; /* crvena */
}

.badge-taken {
  background-color: #388e3c; /* zelena */
}

.badge-pending {
  background-color: #f9a825; /* amber */
}

.badge-defective {
  background-color: #d32f2f;
  margin-left: 6px;
}

.badge-info {
  background-color: #1976d2;
  margin-left: 6px;
}

/* ===== STATUS PILLS (global) ===== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
  line-height: 1.2;
}

.status-pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
  border-color: #fde68a;
}

.status-info {
  background: var(--status-info-bg);
  color: var(--status-info-text);
  border-color: #bfdbfe;
}

.status-success {
  background: var(--status-success-bg);
  color: var(--status-success-text);
  border-color: #bbf7d0;
}

.status-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: #fecaca;
}

.status-warning {
  background: #ffedd5;
  color: #9a3412;
  border-color: #fed7aa;
}

.status-neutral {
  background: var(--status-neutral-bg);
  color: var(--status-neutral-text);
  border-color: #cbd5e1;
}

/* ===== PENDING REQUESTS TABLE ===== */
.pending-toolbar {
  margin: 8px 0 10px;
}

.pending-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pending-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.pending-search input {
  width: 240px;
}

.pending-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  background: #fff;
}

.pending-table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.pending-table-wrap th,
.pending-table-wrap td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.pending-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f9fc;
}

.pending-table-wrap tbody tr:hover {
  background: #f9fbfd;
}

.otpremnica-row-attention {
  background: #fffdf2;
}

.otpremnica-row-muted {
  opacity: 0.72;
}

.otpremnica-selection-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  background: #f3f7ff;
}

#otpremnicaSelectionInfo {
  font-weight: 600;
  margin-right: auto;
}

#otpremnicaSelectionMessage {
  margin-top: 8px;
}

.otpremnica-quick-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.otpremnica-quick-meta .quick-meta-item {
  border: 1px solid #dbe5f3;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fbff;
}

.otpremnica-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 10px;
}

.timeline-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #d0d7e2;
  font-size: 12px;
}

.timeline-step.done {
  background: #ecfdf3;
  border-color: #86efac;
  color: #166534;
}

.timeline-step.todo {
  background: #f8fafc;
  color: #475569;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.otpremnica-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 14px;
  margin-bottom: 10px;
}

.otpremnica-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

/* ===== OTPREMNICE FULL VIEW ===== */
.otpremnica-full {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  background: #fff;
}

.otpremnica-full h4 {
  margin: 10px 0 6px;
}

.otpremnica-full .meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.otpremnica-full table {
  width: 100%;
  border-collapse: collapse;
}

.otpremnica-full th,
.otpremnica-full td {
  padding: 6px 8px;
  border-bottom: 1px solid #eef2f7;
}

@media (max-width: 768px) {
  .otpremnica-full .meta-grid {
    grid-template-columns: 1fr;
  }
}

/* Print helpers */
.print-only {
  display: none;
}

.invoicing-modal-content {
  width: min(96vw, 1500px);
  max-height: 94vh;
  overflow-y: auto;
}
.screen-only {
  display: block;
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    margin: 0;
  }

  body > * {
    display: none !important;
  }

  #printRoot {
    display: block !important;
  }

  #printRoot .otpremnica-full {
    border: none;
    padding: 0;
    display: block !important;
  }

  body {
    font-family: "Segoe UI", Arial, sans-serif;
    color: #111;
  }

  .print-header {
    display: flex !important;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid #000;
    margin-bottom: 10px;
    padding-bottom: 6px;
  }

  .print-logo {
    width: 120px;
    height: auto;
  }

  .print-meta {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    font-size: 12px;
  }

  .print-section-title {
    margin-top: 12px;
    font-weight: 700;
    border-bottom: 1px solid #aaa;
    padding-bottom: 4px;
  }

  .print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  .print-table th,
  .print-table td {
    border: 1px solid #ccc;
    padding: 6px;
  }

  #printRoot table { display: table !important; }
  #printRoot thead { display: table-header-group !important; }
  #printRoot tbody { display: table-row-group !important; }
  #printRoot tr { display: table-row !important; }
  #printRoot th,
  #printRoot td { display: table-cell !important; }

  .print-only {
    display: block !important;
  }
  .screen-only {
    display: none !important;
  }

  .print-table tbody tr:nth-child(even) {
    background: #f5f5f5;
  }

  .print-summary {
    margin-top: 8px;
    font-weight: 600;
  }

  .print-note {
    margin-top: 10px;
    border: 1px dashed #999;
    padding: 6px;
    font-size: 12px;
  }

  .print-footer {
    margin-top: 16px;
    font-size: 11px;
    border-top: 1px solid #aaa;
    padding-top: 6px;
    display: flex;
    justify-content: space-between;
  }

  .print-header,
  .print-section-title,
  .print-summary,
  .print-note,
  .print-footer {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .print-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
    page-break-after: auto;
  }

  .otpremnica-full h2,
  .otpremnica-full h4 {
    page-break-after: avoid;
    break-after: avoid;
  }
}

/* ===== ACTIVITY TABLE ===== */
.activity-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  background: #fff;
}

.activity-table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.activity-table-wrap th,
.activity-table-wrap td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.activity-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f9fc;
}

.activity-toolbar {
  margin: 8px 0 10px;
}

.activity-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.activity-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.activity-search input {
  width: 260px;
}

.stock-total {
  margin-top: 8px;
  font-size: 14px;
  color: #1c6dd0;
}

.stock-manage-section {
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid #e6e9ef;
}

.stock-manage-section h3 {
  margin: 8px 0 10px 0;
}

.stock-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.stock-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.table tr.row-selected {
  background: #e8f1ff;
}

.defective-meta {
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px dashed #d32f2f55;
  border-radius: 6px;
  background: #fff5f5;
  font-size: 12px;
  color: #6b1f1f;
}

/* ===== EXPAND / COLLAPSE ===== */
.ticket-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ticket-toggle {
  font-size: 0.9rem;
  margin-right: 8px;
  user-select: none;
}

.ticket-details {
  margin-top: 8px;
  display: none;
}

.ticket-card.expanded .ticket-details {
  display: block;
}

.comment-item {
  border: 1px solid #ddd;
  padding: 8px;
  margin-top: 6px;
  border-radius: 4px;
  background: #f9f9f9;
}
.comment-header {
  font-size: 12px;
  color: #555;
  display: flex;
  justify-content: space-between;
}
.comment-text {
  margin-top: 4px;
  color: #333;
}

.comment-author {
  color: #1e88e5;       /* plava boja */
  font-weight: 600;
  margin-bottom: 4px;
}

/* CRIS Mobile view */
@media (max-width: 768px) {

  /* sakrij tabelu na mobilnom */
  #ticketsTable {
    display: none;
  }

  /* mobile ticket cards */
  #ticketCards {
    display: block;
  }

  .ticket-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff;
  }

  .ticket-card-row {
    margin-bottom: 6px;
    font-size: 14px;
  }

  .ticket-card-label {
    font-weight: 600;
    color: #555;
  }

  .ticket-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
  }

  .ticket-card-actions button {
    flex: 1;
    padding: 8px;
    font-size: 14px;
  }

  .btn-toggle-card {
    margin-top: 8px;
    width: 100%;
  }

}

@media (max-width: 768px) {
  /* tabs sticky na mobilnom */
  .tabs {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #f8fafc;   /* kao card */
    padding: 6px 0;
    border-bottom: 1px solid #d0d7e2;
  }
}

@media (max-width: 600px) {
  /* CRIS: dugmad u card-u neka budu puna širina, ali tab dugmad neka ostanu 2 u redu */
  body h1 + .card button.btn-primary {
    width: 90vw;
    max-width: 330px;
  }

  .tabs {
    display: flex;
    gap: 8px;
  }

  .tabs .tab {
    width: 50%;
    max-width: none;
  }
}

@media (max-width: 600px) {
  .cris-header-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
  }

  .cris-header-actions button {
    width: 100%;
  }
}

#ticketCards {
  margin: 5px;
}

/* ============================
   CRIS-DETAILS  MOBILE
   ============================ */

@media (max-width: 768px) {

  /* Header kartica */
  .cris-details-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .cris-details-status {
    font-size: 15px;
  }

  .btn-back {
    width: 100%;
  }

  /* Sve kartice u detaljima */
  .card {
    margin: 10px 5px;
  }

  /* Textarea – opis i komentar */
  textarea {
    width: 100%;
    font-size: 15px;
  }

  /* Dugmad u detaljima */
  #btnTakeTicket,
  .card button.btn-primary {
    width: 100%;
    margin-top: 8px;
  }

  /* Komentari – jasni card blokovi */
  .comment-item {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }

  .comment-author {
    font-size: 14px;
  }

  .comment-text {
    font-size: 14px;
    line-height: 1.4;
  }

  /* Naslov stranice */
  h1 {
    font-size: 20px;
    text-align: center;
    margin-top: 10px;
  }
}

/* Fixed (read-only) field look */
.fixed-field{
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f7f7f7;
}

.sn-create-box {
  padding: 10px;
  border: 1px solid #ccc;
  margin-bottom: 10px;
}

#snPartsContainer .item-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.sn-defective-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  color: #6d4c41;
}

/* ============================
   SN TICKET PICKER MOBILE
   ============================ */

#snTicketCards {
  display: none;
}

.sn-mobile-cards {
  display: none;
}

.sn-mobile-card {
  background: #f9fbfd;
  border: 1px solid #dce3eb;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.sn-mobile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.sn-mobile-title {
  font-weight: 700;
}

.sn-mobile-line {
  font-size: 14px;
  margin-top: 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sn-mobile-label {
  font-weight: 600;
  color: #555;
}

.sn-mobile-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e6e9ef;
}

.sn-mobile-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.sn-mobile-actions button {
  flex: 1;
}

.sn-mobile-audit {
  margin-top: 8px;
}

.sn-closed {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed #d0d7e2;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
}

#rnApproveTargetWrap {
  min-height: 64px;
}

@media (max-width: 768px) {
  .sn-closed {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  #snTicketsTable {
    display: none;
  }

  #snTicketCards {
    display: block;
  }

  #mySnContainer table {
    display: none;
  }

  .sn-mobile-cards {
    display: block;
  }
}

/* ============================
   SN AUDIT (timeline inline)
   ============================ */

.audit-row td {
  background: #f8fafc;
}

.audit-box {
  padding: 10px 12px;
  background: rgba(25, 118, 210, 0.06);
  border: 1px solid rgba(25, 118, 210, 0.18);
  border-radius: 10px;
}

.audit-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.audit-item:last-child {
  border-bottom: none;
}

.audit-meta {
  font-size: 12px;
  opacity: 0.9;
  margin-bottom: 4px;
}

.audit-msg {
  font-size: 14px;
}

.audit-extra {
  margin-top: 4px;
  font-size: 13px;
  opacity: 0.9;
}

.sn-audit-btn .audit-caret {
  display: inline-block;
  margin-left: 6px;
  transition: transform 0.2s ease;
}

.sn-audit-btn.is-open .audit-caret {
  transform: rotate(180deg);
}

/* ============================
   SN toolbar + pagination
   ============================ */

.sn-toolbar {
  margin: 10px 0 8px;
}

.sn-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.sn-filters label {
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.sn-filters select,
.sn-filters input {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.18);
}

.sn-search input {
  width: 260px;
  max-width: 60vw;
}

.sn-loadmore {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
}

/* ============================
   SN MOBILE OPTIMIZATION
   ============================ */

@media (max-width: 768px) {
  #serviceOrdersSection {
    padding: 0 6px;
  }

  .sn-create-box,
  #snTicketPicker {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .sn-create-box input,
  .sn-create-box textarea,
  #snTicketPicker button,
  #createSnBtn,
  #btnReloadMySn,
  #snBtnReloadCrisTickets,
  #snApplyFiltersBtn,
  #snLoadMoreBtn,
  #snBackBtn {
    width: 100%;
    max-width: none;
  }

  .sn-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .sn-filters label {
    width: 100%;
    justify-content: space-between;
  }

  .sn-search input {
    width: 100%;
    max-width: none;
  }

}

@media (max-width: 600px) {
  #snPartsContainer .item-row {
    flex-direction: column;
    align-items: stretch;
  }

  #snPartsContainer .item-qty,
  #snPartsContainer .item-name,
  #addSnPartBtn,
  #closeSnBtn {
    width: 100%;
    max-width: none;
  }

  .modal-dialog {
    width: 96vw;
    max-height: 92vh;
  }
}

/* Modal overlay/dialog (SN close) */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 16px;
  z-index: 9999;
}

/* Ensure hidden wins over modal overlay */
.modal-overlay.hidden{
  display: none;
}

.modal-dialog{
  width: min(720px, 96vw);
  max-height: 90vh;
  overflow:auto;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.25);
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-title{
  font-weight: 700;
}

/* X dugme - koristi btn-primary već, ali ovo mu sredi veličinu */
.modal-x{
  padding: 6px 10px;
  line-height: 1;
}

/* ===========================
   REPORTS
   =========================== */
.report-container {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 16px;
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.report-card {
  display: block;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.report-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.report-card h3 {
  margin: 0 0 8px;
}

.report-card p {
  margin: 0;
  color: var(--text-muted);
}

.report-filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.report-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.report-filter-row label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  gap: 6px;
}

.report-filter-row input,
.report-filter-row select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.report-summary {
  background: var(--surface-muted);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-weight: 600;
}

.report-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.report-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
}

.report-table th,
.report-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  font-size: 14px;
}

.report-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f9fc;
}

@media (max-width: 720px) {
  .report-actions {
    justify-content: flex-start;
  }
}
