/* Journals, document view and compact TMC entry refinements. */
.nowrap { white-space: nowrap; }

.document-position-count {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1;
  text-align: center;
}

.document-position-number {
  color: #2f3034;
  font-size: .86rem;
  font-weight: 400;
  line-height: 1.05;
}

.document-position-label {
  color: #96969c;
  font-size: .62rem;
  font-weight: 400;
  line-height: 1.1;
}

.document-reference {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #252529;
  line-height: 1;
  white-space: nowrap;
}

.document-type-badge {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  font-size: .74rem;
  line-height: 1;
}

.document-reference-number {
  color: #252529;
  font-size: .9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.strong-link .document-reference,
.strong-link .document-reference-number {
  color: inherit;
}

.document-create-menu {
  position: relative;
  overflow: visible;
}

.document-create-action {
  position: relative;
  overflow: visible !important;
}

.document-create-action::before,
.document-create-action::after {
  position: absolute;
  z-index: 120;
  pointer-events: none;
  opacity: 0;
  transition: opacity .14s ease, transform .14s ease;
}

.document-create-action::before {
  content: "";
  top: calc(100% + 4px);
  left: 50%;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #3d3d42;
  transform: translate(-50%, -3px);
}

.document-create-action::after {
  content: attr(data-tooltip);
  top: calc(100% + 10px);
  left: 50%;
  min-width: max-content;
  padding: 7px 10px 8px;
  border-radius: 9px;
  background: #3d3d42;
  color: #fff;
  box-shadow: 0 7px 20px rgba(25, 25, 28, .20);
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .01em;
  white-space: nowrap;
  transform: translate(-50%, -3px);
}

.document-create-action:last-child::after {
  left: auto;
  right: 0;
  transform: translateY(-3px);
}

.document-create-action:hover::before,
.document-create-action:hover::after,
.document-create-action:focus-visible::before,
.document-create-action:focus-visible::after {
  opacity: 1;
}

.document-create-action:hover::before,
.document-create-action:focus-visible::before {
  transform: translate(-50%, 0);
}

.document-create-action:hover::after,
.document-create-action:focus-visible::after {
  transform: translate(-50%, 0);
}

.document-create-action:last-child:hover::after,
.document-create-action:last-child:focus-visible::after {
  transform: translateY(0);
}

.tmc-line-header {
  background: #4a4a4f !important;
  border-bottom-color: #4a4a4f !important;
  border-radius: 17px 17px 0 0;
}

.tmc-line-header strong {
  color: #fff !important;
  text-transform: uppercase;
  letter-spacing: .035em;
}

.tmc-line-header .icon-button { color: rgba(255,255,255,.9) !important; }
.tmc-line-header .icon-button:hover { color: #fff !important; }

/* Document type color language. */
.doc-chip.doc-type-receipt,
.document-type-badge.doc-type-receipt,
.doc-title-icon.doc-type-receipt { background: #e8f7ee !important; color: #287548 !important; }
.doc-chip.doc-type-issue,
.document-type-badge.doc-type-issue,
.doc-title-icon.doc-type-issue { background: #eaf2fd !important; color: #2f66ad !important; }
.doc-chip.doc-type-return_to_stock,
.document-type-badge.doc-type-return_to_stock,
.doc-title-icon.doc-type-return_to_stock { background: #fff0ef !important; color: #b44545 !important; }
.doc-chip.doc-type-transfer,
.document-type-badge.doc-type-transfer,
.doc-title-icon.doc-type-transfer { background: #ececee !important; color: #45454a !important; }
.doc-chip.doc-type-inventory,
.document-type-badge.doc-type-inventory,
.doc-title-icon.doc-type-inventory { background: #fff1df !important; color: #b76816 !important; }

.document-type-filter {
  display: flex;
  gap: 7px;
  margin: -6px 0 14px;
  overflow-x: auto;
  padding: 3px 1px 5px;
}

.document-type-filter-item {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(35,35,40,.16);
  border-radius: 999px;
  background: #f0f0f2;
  color: #252529 !important;
  font-size: .76rem;
  font-weight: 750;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, transform .15s ease;
}

.document-type-filter-item:hover { color: #111 !important; border-color: rgba(35,35,40,.30); transform: translateY(-1px); }
.document-type-filter-item.is-active { border-color: rgba(35,35,40,.34); box-shadow: inset 0 0 0 1px rgba(35,35,40,.08); }
.document-type-filter-item.doc-type-receipt { background: #e8f7ee; }
.document-type-filter-item.doc-type-receipt:hover { background: #d6f1e1; }
.document-type-filter-item.doc-type-issue { background: #eaf2fd; }
.document-type-filter-item.doc-type-issue:hover { background: #dce9fb; }
.document-type-filter-item.doc-type-return_to_stock { background: #fff0ef; }
.document-type-filter-item.doc-type-return_to_stock:hover { background: #ffe1df; }
.document-type-filter-item.doc-type-transfer { background: #ececee; }
.document-type-filter-item.doc-type-transfer:hover { background: #dddddf; }
.document-type-filter-item.doc-type-inventory { background: #fff1df; }
.document-type-filter-item.doc-type-inventory:hover { background: #ffe4c2; }
.document-type-filter-item i { opacity: .72; }

.journal-filter-card { margin-bottom: 16px; padding: 14px 16px !important; }
.journal-filter-form {
  display: grid;
  grid-template-columns: 170px 170px 150px 1fr;
  gap: 10px 12px;
  align-items: end;
}
.journal-filter-form .field { margin: 0; }
.journal-filter-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.journal-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  white-space: nowrap;
}
.journal-sort-link:hover,
.journal-sort-link.is-active { color: #222; }
.journal-sort-link i { font-size: .66rem; opacity: .55; }
.journal-sort-link.is-active i { opacity: 1; }

.document-table tbody tr[data-row-href] {
  cursor: pointer;
  transition: background .14s ease;
}

.document-table tbody tr[data-row-href]:hover {
  background: #f7f7f9;
}

.journal-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.journal-row-actions form { margin: 0; }
.is-danger-soft { color: #a33a3a !important; }
.is-danger-soft:hover { background: #fff0ef !important; color: #942c2c !important; }

.journal-pagination { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; }
.journal-pagination-summary { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.pagination .is-disabled { opacity: .45; pointer-events: none; }

.document-show-heading { margin-bottom: 20px; }
.document-show-topline { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.document-title-inline { display: flex; align-items: center; gap: 10px; }
.document-title-inline .title { margin: 0 !important; line-height: 1; }
.document-title-inline .document-reference { gap: 0; flex: 0 0 auto; }
.document-title-inline .document-reference-number { display: none; }
.document-title-inline .document-type-badge {
  width: 43px;
  height: 43px;
  flex-basis: 43px;
  border-radius: 14px;
  font-size: .9rem;
}
.document-show-actions { align-items: center; }
.document-show-actions form { margin: 0; }
.document-post-button { color: #fff !important; }
.document-summary-column .section-card { padding-left: 17px; padding-right: 17px; }
.document-summary-column .summary-row { gap: 8px; }

.document-lines-card { padding-top: 18px !important; }
.document-lines-header { margin-bottom: 10px !important; }
.document-lines-header .title { margin: 0 !important; }
.document-lines-table-wrap { margin: 0 -4px -2px; }
.document-lines-table { table-layout: fixed; }
.document-lines-table th {
  padding: 9px 10px !important;
  color: #85858b !important;
  font-size: .68rem !important;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.document-lines-table td {
  padding: 12px 10px !important;
  border-color: #eeeef1 !important;
  vertical-align: middle !important;
  font-size: .78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.document-lines-table th:nth-child(1) { width: 20%; }
.document-lines-table th:nth-child(2) { width: 10%; }
.document-lines-table th:nth-child(3) { width: 16%; }
.document-lines-table th:nth-child(4) { width: 19%; }
.document-lines-table th:nth-child(5) { width: 23%; }
.document-lines-table th:nth-child(6) { width: 12%; }

.document-lines-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 8px; }
.document-gallery-card { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.document-gallery-photo { aspect-ratio: 4 / 3; background: #f2f2f4; }
.document-gallery-photo img { width: 100%; height: 100%; display: block; object-fit: contain; padding: 6px; }
.document-gallery-photo-link { display: block; color: inherit; }
.document-gallery-photo-link:hover { background: #ececef; }
.no-photo-placeholder {
  width: 100%; height: 100%; min-height: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  color: #aaaab0; background: linear-gradient(145deg, #f6f6f7, #ececef);
  font-size: .78rem; font-weight: 700;
}
.no-photo-placeholder i { font-size: 1.6rem; }
.document-gallery-body { padding: 12px 13px 14px; }
.document-gallery-body > strong,
.document-gallery-body > .strong-link { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-gallery-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; color: var(--muted); font-size: .76rem; }
.document-gallery-body p { margin-top: 8px; color: var(--muted); font-size: .76rem; }
.inventory-submit-button[disabled] { opacity: .45; cursor: not-allowed; }

/* Issue/transfer now expose the selected input unit. */
.tmc-primary-grid.is-existing-item { grid-template-columns: 250px 150px 120px !important; }

.issue-header-fields {
  grid-template-columns: 135px minmax(190px, 1fr) minmax(185px, 1fr) minmax(210px, 1.15fr) !important;
  align-items: end;
}
.issue-header-fields .field { margin-bottom: 0; }

.stock-availability-notice {
  margin-top: 9px;
  padding: 9px 11px;
  border-radius: 11px;
  background: #f2f2f4;
  color: #55555b;
  font-size: .76rem;
  line-height: 1.35;
}
.stock-availability-notice.is-ok { background: #eaf7ef; color: #286840; }
.stock-availability-notice.is-warning { background: #fff5df; color: #86530f; }
.stock-availability-notice.is-danger { background: #fff0ef; color: #983c3c; }
.stock-availability-notice.is-hidden { display: none; }

@media (max-width: 1050px) {
  .document-lines-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .issue-header-fields { grid-template-columns: 135px 1fr 1fr !important; }
  .issue-header-fields .field:last-child { grid-column: 2 / 4; }
}

@media (max-width: 900px) {
  .tmc-primary-grid.is-existing-item { grid-template-columns: 205px 120px 105px !important; }
  .issue-header-fields { grid-template-columns: 1fr 1fr !important; }
  .issue-header-fields .field:last-child { grid-column: auto; }
}

@media (max-width: 760px) {
  .journal-filter-form { grid-template-columns: 1fr 1fr; }
  .journal-filter-actions { justify-content: flex-start; }
  .journal-pagination { align-items: stretch; flex-direction: column; }
  .document-show-topline { align-items: stretch; flex-direction: column; }
  .document-show-actions { justify-content: flex-start; flex-wrap: wrap; }
  .document-show-columns { display: block; }
  .document-lines-table { min-width: 820px; }
  .document-lines-gallery { grid-template-columns: 1fr; }
  .tmc-primary-grid.is-existing-item { grid-template-columns: 1fr !important; }
  .issue-header-fields { grid-template-columns: 1fr !important; }
}
