.app-loading-status {
  position: fixed;
  z-index: 1080;
  top: 0.75rem;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  border: var(--bs-border-width) solid var(--bs-primary-border-subtle);
  border-radius: var(--bs-border-radius-pill);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -0.75rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.app-loading-status.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

[aria-busy="true"] {
  cursor: progress;
}

.app-critical-actions {
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
  background-color: rgba(var(--bs-body-bg-rgb), 0.96) !important;
}

.app-mobile-card,
.warehouse-request-card {
  overflow-wrap: anywhere;
}

.app-navbar .nav-link,
.app-navbar .btn {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.app-primary-nav {
  min-width: 0;
}

.warehouse-request-card {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.request-phase-new {
  --request-phase-bg: #dff6fb;
  --request-phase-hover-bg: #cfeff7;
}

.request-phase-picking {
  --request-phase-bg: #e2eaff;
  --request-phase-hover-bg: #d3dfff;
}

.request-phase-ready {
  --request-phase-bg: #fff3cd;
  --request-phase-hover-bg: #ffe69c;
}

.request-phase-issued {
  --request-phase-bg: #d9f2df;
  --request-phase-hover-bg: #c8e9d1;
}

.request-phase-draft,
.request-phase-cancelled {
  --request-phase-bg: #f1f3f5;
  --request-phase-hover-bg: #e9ecef;
}

tr[class*="request-phase-"] > * {
  --bs-table-bg: var(--request-phase-bg);
}

tr[class*="request-phase-"]:hover > * {
  --bs-table-bg-state: var(--request-phase-hover-bg);
}

.warehouse-request-card[class*="request-phase-"] {
  background-color: var(--request-phase-bg);
}

.warehouse-phase-badge {
  flex: 0 0 auto;
  font-size: 0.825rem;
  font-weight: 650;
}

.warehouse-marker-badge {
  font-size: 0.75rem;
  font-weight: 600;
}

.warehouse-request-number {
  width: fit-content;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.warehouse-request-object,
.warehouse-request-recipient {
  line-height: 1.3;
}

.warehouse-request-card:hover,
.warehouse-request-card:focus-within {
  border-color: var(--bs-primary-border-subtle);
  box-shadow: var(--bs-box-shadow-sm);
}

.nomenclature-thumbnail {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  object-fit: contain;
  object-position: center;
  padding: 0.2rem;
  background: var(--bs-tertiary-bg);
}

.warehouse-status-badge {
  max-width: 100%;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: normal;
  text-align: left;
}

.warehouse-detail-header {
  border-color: var(--bs-primary-border-subtle);
  background: linear-gradient(135deg, var(--bs-body-bg), var(--bs-primary-bg-subtle));
}

.warehouse-deadline-panel {
  min-width: 12rem;
}

.warehouse-request-summary {
  font-size: 1.125rem;
}

.warehouse-deadline {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
}

.warehouse-fact-label {
  margin-bottom: 0.25rem;
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.warehouse-fact-value {
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.warehouse-current-action {
  background: var(--bs-primary-bg-subtle);
}

.warehouse-current-action .btn {
  min-height: 3rem;
}

.warehouse-metric {
  border-color: var(--bs-border-color-translucent) !important;
}

.analytics-metric .display-6,
.analytics-metric .h2 {
  overflow-wrap: anywhere;
}

.warehouse-pto-comment {
  color: var(--bs-body-color);
}

.material-grid {
  display: grid;
  grid-template-columns: 80px minmax(150px, 1.25fr) minmax(140px, 1fr) minmax(150px, 0.8fr) minmax(130px, 0.9fr);
  grid-template-areas: "photo position characteristic quantity comment";
  gap: 1rem;
  align-items: center;
}

.material-grid-header {
  padding: 0.625rem 1rem;
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  font-weight: 600;
}

.warehouse-material-card {
  min-width: 0;
  padding: 1rem;
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

.warehouse-issued-progress {
  height: 1.4rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.warehouse-material-card.fulfilment-line-closed {
  background-color: #d9f2df;
}

.warehouse-material-card.fulfilment-line-ready {
  background-color: #fff3cd;
}

.warehouse-material-card.fulfilment-line-partial {
  background-color: #ffe5cc;
}

.warehouse-material-card.fulfilment-line-none {
  background-color: #fbe2e3;
}

.warehouse-material-card.fulfilment-line-picked {
  background-color: #ffefd6;
}

.fulfilment-badge-partial {
  color: #713b00;
  background-color: #ffc078;
}

.fulfilment-badge-none {
  color: #842029;
  background-color: #f1aeb5;
}

.fulfilment-badge-picked {
  color: #664d03;
  background-color: #ffe69c;
}

.warehouse-material-card:last-child {
  border-bottom: 0;
}

.material-photo {
  grid-area: photo;
}

.material-position {
  grid-area: position;
  min-width: 0;
  overflow-wrap: anywhere;
}

.material-characteristic {
  grid-area: characteristic;
  min-width: 0;
  overflow-wrap: anywhere;
}

.material-quantity {
  grid-area: quantity;
  min-width: 0;
}

.warehouse-quantity-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.warehouse-quantity-item > span {
  color: var(--bs-secondary-color);
}

.warehouse-quantity-item > .warehouse-quantity-text {
  color: inherit;
  font-weight: 600;
}

.warehouse-history-block > summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.warehouse-history-block > summary::-webkit-details-marker {
  display: none;
}

.warehouse-history-block > summary::after {
  content: "Развернуть";
  margin-left: auto;
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  font-weight: 400;
}

.warehouse-history-block[open] > summary::after {
  content: "Свернуть";
}

.material-comment {
  grid-area: comment;
  min-width: 0;
  overflow-wrap: anywhere;
}

.nomenclature-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: 0.6875rem;
  line-height: 1.1;
  text-align: center;
}

.nomenclature-suggestions {
  left: 0.5rem;
  max-height: 18rem;
  overflow-y: auto;
  position: absolute;
  right: 0.5rem;
  top: calc(100% - 0.1rem);
  z-index: 20;
}

.nomenclature-duplicate-target {
  border-color: var(--bs-warning) !important;
  box-shadow: 0 0 0 0.2rem rgb(255 193 7 / 25%);
}

.request-line-image-preview {
  height: 64px;
  object-fit: contain;
  object-position: center;
  padding: 0.2rem;
  background: var(--bs-tertiary-bg);
  width: 64px;
}

.request-line-images .form-control[type="file"] {
  max-width: 36rem;
}

.material-image-link:focus-visible {
  outline: 3px solid rgba(var(--bs-primary-rgb), 0.4);
  outline-offset: 3px;
}

.min-width-0 {
  min-width: 0;
}

.invalid-feedback,
.alert {
  overflow-wrap: anywhere;
}

.picking-line-card {
  border-color: var(--bs-border-color);
}

.picking-required-qty {
  font-size: 1.125rem;
}

.picking-actions .btn {
  min-width: 5rem;
  min-height: 2.75rem;
}

.picking-qty-input {
  width: 10rem;
  font-size: 1rem;
}

.picking-action-bar {
  position: sticky;
  z-index: 10;
  bottom: 0.5rem;
}

.issue-quantity-column,
.issue-quantity-input {
  width: 8rem;
}

.issue-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) repeat(4, minmax(72px, 0.65fr)) 8rem;
  gap: 1rem;
  align-items: center;
}

.issue-grid-header {
  padding: 0.625rem 1rem;
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  font-weight: 600;
}

.issue-stat {
  text-align: right;
}

.issue-stat > span {
  display: none;
}

.warehouse-sticky-actions {
  position: sticky;
  z-index: 10;
  bottom: 0.25rem;
}

.return-quantity-input {
  width: 10rem;
}

.return-line-card .form-check-input,
.return-line-card .form-check-label {
  cursor: pointer;
}

.return-photo-thumbnail {
  width: 8rem;
  height: 8rem;
  object-fit: cover;
}

.audit-json {
  max-height: 24rem;
  overflow: auto;
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 767.98px) {
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  .app-navbar .container {
    align-items: center;
  }

  .app-primary-nav {
    order: 3;
    width: 100%;
    padding-top: 0.125rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  .app-navbar .btn,
  .app-navbar .nav-link,
  main .btn,
  main .form-control,
  main .form-select {
    min-height: 2.75rem;
  }

  .app-loading-status {
    top: 0.5rem;
    max-width: calc(100vw - 1rem);
    white-space: nowrap;
  }

  .analytics-metric .card-body {
    padding: 0.875rem;
  }

  .analytics-metric .display-6 {
    font-size: clamp(1.75rem, 10vw, 2.5rem);
  }

  .app-navbar .navbar-brand {
    margin-right: 0.25rem;
  }

  .app-navbar .nav-link {
    padding-right: 0.35rem;
    padding-left: 0.35rem;
    font-size: 0.9rem;
  }

  main.container {
    padding-top: 1.5rem !important;
    padding-bottom: 2rem !important;
  }

  .warehouse-back-link {
    min-height: 2.75rem;
    align-items: center;
  }

  .warehouse-detail-header .card-body {
    padding-bottom: 1.25rem !important;
  }

  .warehouse-deadline-panel {
    min-width: 0;
  }

  .warehouse-current-action {
    position: sticky;
    z-index: 20;
    bottom: 0.25rem;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
  }

  .warehouse-current-action .card-body {
    padding: 0.75rem !important;
  }

  .material-grid {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas:
      "photo position"
      "photo characteristic"
      "quantity quantity"
      "comment comment";
    gap: 0.4rem 0.85rem;
    align-items: start;
  }

  .warehouse-material-card {
    padding: 1rem;
  }

  .material-quantity {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 0.75rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: var(--bs-border-width) solid var(--bs-border-color);
  }

  .warehouse-quantity-item {
    display: block;
    font-size: 0.9rem;
  }

  .warehouse-quantity-item > span {
    display: block;
    font-size: 0.75rem;
  }

  .warehouse-quantity-item .d-md-none {
    display: none !important;
  }

  .warehouse-history-block > summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .warehouse-history-block > summary::after {
    width: 100%;
    margin-top: 0.25rem;
    margin-left: 0;
  }

  .material-comment {
    margin-top: 0.25rem;
  }

  .picking-line-card .card-body {
    padding: 1rem;
  }

  .picking-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .picking-actions form,
  .picking-actions .btn {
    width: 100%;
  }

  .picking-actions .btn {
    min-width: 0;
    min-height: 3rem;
  }

  .picking-qty-input {
    width: 100%;
    min-height: 3rem;
    font-size: 1rem;
  }

  .picking-action-bar {
    margin-right: -0.5rem;
    margin-left: -0.5rem;
    bottom: 0.25rem;
  }

  .issue-quantity-input {
    width: 100%;
    min-height: 3rem;
    font-size: 1rem;
  }

  .issue-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    align-items: start;
  }

  .issue-position,
  .issue-input {
    grid-column: 1 / -1;
  }

  .issue-stat {
    text-align: left;
  }

  .issue-stat > span {
    display: block;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
  }

  .warehouse-sticky-actions {
    margin-right: -0.5rem;
    margin-left: -0.5rem;
    padding-right: 0.5rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
    padding-left: 0.5rem;
  }

  .warehouse-sticky-actions .btn,
  .picking-action-bar .btn {
    min-height: 3rem;
  }

  .return-quantity-input {
    width: 100%;
    min-height: 3rem;
    font-size: 1rem;
  }
}
