/* Inventory reference styling: visual only, keeps existing renderProducts behavior. */
body[data-active-view="products"] .view.active {
  height: calc(100vh - 112px);
  padding: 14px 14px 18px;
  overflow: hidden;
}

body[data-active-view="products"] .main > .notice.origin-warning,
body[data-active-view="products"] .origin-warning {
  height: 70px;
  min-height: 70px;
  margin: 12px 14px 20px;
  padding: 15px 54px 13px 58px;
  border: 1px solid #bfd2ff;
  border-radius: 10px;
  background: #f3f7ff;
  color: #001f52;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

#products.view.active {
  display: block;
}

#products .inventory-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#products .panel-heading {
  min-height: 42px;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#products .panel-heading h2 {
  margin: 0;
  color: #071a44;
  font-size: 14px;
  line-height: 1;
  font-weight: 800;
}

#products .inventory-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

#products #exportInventoryBtn {
  width: 138px;
  min-width: 138px;
  height: 40px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 900;
}

#products #correctInventoryBtn {
  width: 145px;
  min-width: 145px;
  height: 40px;
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: #ef1736;
  box-shadow: 0 8px 18px rgba(239, 23, 54, 0.2);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  opacity: 1;
}

#packagingInventory.view.active {
  display: block;
}

#packagingInventory .packaging-inventory-panel {
  min-height: calc(100vh - 150px);
}

#packagingInventory .panel-heading {
  margin-bottom: 14px;
}

#packagingInventory .packaging-table-wrap table {
  table-layout: fixed;
}

#packagingInventory .packaging-table-wrap th:nth-child(1),
#packagingInventory .packaging-table-wrap th:nth-child(2),
#packagingInventory .packaging-table-wrap td:nth-child(1),
#packagingInventory .packaging-table-wrap td:nth-child(2) {
  width: 13%;
}

#packagingInventory .packaging-cell {
  display: grid;
  gap: 4px;
  min-height: 38px;
  align-content: center;
}

#packagingInventory .packaging-cell strong {
  color: #071a44;
  font-size: 13px;
  font-weight: 900;
}

#packagingInventory .packaging-cell span {
  color: #506489;
  font-size: 11px;
  font-weight: 800;
}

#stockCurrent .report-table-wrap table {
  min-width: 1180px;
  table-layout: fixed;
}

#stockCurrent .report-table-wrap th,
#stockCurrent .report-table-wrap td {
  white-space: nowrap;
}

#stockCurrent .report-table-wrap th:nth-child(1),
#stockCurrent .report-table-wrap td:nth-child(1) {
  width: 118px;
}

#stockCurrent .report-table-wrap th:nth-child(2),
#stockCurrent .report-table-wrap td:nth-child(2) {
  width: 150px;
}

#stockCurrent .report-table-wrap th:nth-child(3),
#stockCurrent .report-table-wrap td:nth-child(3),
#stockCurrent .report-table-wrap th:nth-child(4),
#stockCurrent .report-table-wrap td:nth-child(4) {
  width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#stockCurrent .report-table-wrap th:nth-child(n+5),
#stockCurrent .report-table-wrap td:nth-child(n+5) {
  width: 108px;
  text-align: center;
}

#stockCurrent .report-table-wrap th:last-child,
#stockCurrent .report-table-wrap td:last-child {
  width: 82px;
}

.stock-detail-button {
  min-width: 78px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #9fc4ff;
  border-radius: 7px;
  background: #eef6ff;
  color: #005fdb;
  font-weight: 900;
  cursor: pointer;
}

.stock-detail-button:hover {
  border-color: #0069df;
  background: #e1efff;
}

.stock-open-button {
  min-width: 64px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #f3153b;
  border-radius: 7px;
  background: #fff5f7;
  color: #f3153b;
  font-weight: 900;
  cursor: pointer;
}

.stock-open-button:hover {
  background: #f3153b;
  color: #fff;
}

.stock-stage-empty {
  display: inline-flex;
  min-width: 78px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: #61708c;
  font-weight: 800;
}

.stock-available {
  color: #00875a;
}

.stock-negative {
  color: #f3153b;
}

#stockMovementDialog,
#stockLocationDialog {
  width: min(1240px, calc(100vw - 48px));
  max-width: min(1240px, calc(100vw - 48px));
  max-height: calc(100vh - 40px);
  margin: clamp(72px, 10vh, 120px) auto auto;
  overflow: hidden;
  background: transparent;
}

.stock-movement-card,
.stock-location-card {
  box-sizing: border-box;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-x: hidden;
  overflow-y: auto;
}

.stock-movement-card {
  width: 100%;
}

.stock-movement-heading {
  align-items: flex-start;
}

.stock-movement-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.stock-movement-meta div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #d7e3f4;
  border-radius: 8px;
  background: #f7fbff;
}

.stock-movement-meta span {
  display: block;
  margin-bottom: 4px;
  color: #586987;
  font-size: 12px;
  font-weight: 800;
}

.stock-movement-meta strong {
  display: block;
  overflow: hidden;
  color: #071a44;
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-movement-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.stock-movement-tab {
  display: flex;
  min-width: 0;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #d7e3f4;
  border-radius: 8px;
  background: #f8fbff;
  color: #071a44;
  font-weight: 900;
  cursor: pointer;
}

.stock-movement-tab strong {
  color: #0069df;
  font-size: 16px;
}

.stock-movement-tab.active {
  border-color: #0069df;
  background: #eaf3ff;
  box-shadow: inset 0 0 0 1px #0069df;
}

.stock-movement-table-wrap {
  max-height: min(58vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
}

.stock-movement-table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.stock-movement-table-wrap th,
.stock-movement-table-wrap td {
  overflow-wrap: anywhere;
  white-space: normal;
}

.stock-movement-table-wrap th:nth-child(1),
.stock-movement-table-wrap td:nth-child(1) {
  width: 14%;
}

.stock-movement-table-wrap th:nth-child(2),
.stock-movement-table-wrap td:nth-child(2) {
  width: 14%;
}

.stock-movement-table-wrap th:nth-child(3),
.stock-movement-table-wrap td:nth-child(3) {
  width: 28%;
}

.stock-movement-table-wrap th:nth-child(4),
.stock-movement-table-wrap td:nth-child(4) {
  width: 11%;
  text-align: center;
}

.stock-movement-table-wrap th:nth-child(5),
.stock-movement-table-wrap td:nth-child(5) {
  width: 16%;
}

.stock-movement-table-wrap th:nth-child(6),
.stock-movement-table-wrap td:nth-child(6) {
  width: 17%;
}

.stock-movement-actions {
  margin-top: 14px;
}

.stock-location-card {
  width: 100%;
}

.stock-location-heading {
  align-items: flex-start;
}

.stock-location-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.stock-location-meta div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #d7e3f4;
  border-radius: 8px;
  background: #f7fbff;
}

.stock-location-meta span {
  display: block;
  margin-bottom: 4px;
  color: #586987;
  font-size: 12px;
  font-weight: 800;
}

.stock-location-meta strong {
  display: block;
  color: #071a44;
  font-size: 16px;
  font-weight: 900;
}

.stock-location-table-wrap {
  max-height: min(58vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
}

.stock-location-table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.stock-location-table-wrap th,
.stock-location-table-wrap td {
  overflow-wrap: anywhere;
  white-space: normal;
}

.stock-location-table-wrap th:nth-child(1),
.stock-location-table-wrap td:nth-child(1) {
  width: 22%;
}

.stock-location-table-wrap th:nth-child(2),
.stock-location-table-wrap td:nth-child(2) {
  width: 30%;
}

.stock-location-table-wrap th:nth-child(n+3),
.stock-location-table-wrap td:nth-child(n+3) {
  width: 16%;
  text-align: center;
}

.stock-location-actions {
  margin-top: 14px;
}

@media (max-width: 760px) {
  #stockMovementDialog,
  #stockLocationDialog {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    margin: 12px auto auto;
  }

  .stock-movement-card,
  .stock-location-card {
    max-height: calc(100vh - 24px);
  }

  .stock-movement-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stock-movement-tabs {
    grid-template-columns: 1fr;
  }

  .stock-location-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

#products .inventory-summary-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  flex: 0 0 auto;
}

#products .inventory-metric-card {
  position: relative;
  min-height: 76px;
  height: 76px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: 23px 1fr;
  column-gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #e3e8f3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(7, 26, 68, 0.08);
  overflow: hidden;
}

#products .inventory-metric-card::before {
  content: "";
  grid-row: 1 / span 2;
  grid-column: 1;
  width: 30px;
  height: 30px;
  align-self: center;
  justify-self: start;
  border-radius: 10px;
  background: var(--inv-soft, #eef3ff);
}

#products .inventory-metric-card::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  background: var(--inv-color, #0057d9);
  -webkit-mask: var(--inv-icon) center / contain no-repeat;
  mask: var(--inv-icon) center / contain no-repeat;
}

#products .inventory-metric-card span,
#products .inventory-metric-card strong {
  grid-column: 2;
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#products .inventory-metric-card span {
  align-self: end;
  margin: 0;
  color: #536487;
  font-size: 11px;
  line-height: 1.1;
  font-weight: 800;
}

#products .inventory-metric-card strong {
  align-self: start;
  margin: 3px 0 0;
  color: #071a44;
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

#products .inventory-metric-items,
#products .inventory-metric-units {
  --inv-color: #0b5fd3;
  --inv-soft: #eef3ff;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21 8-9-5-9 5 9 5 9-5Z'/%3E%3Cpath d='M3 8v8l9 5 9-5V8'/%3E%3Cpath d='M12 13v8'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-metric-boxes {
  --inv-color: #e85d04;
  --inv-soft: #fff1e7;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='2'/%3E%3Cpath d='M8 2v4'/%3E%3Cpath d='M16 2v4'/%3E%3Cpath d='M3 9h18'/%3E%3Cpath d='m9 15 2 2 4-5'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-metric-loose {
  --inv-color: #071a44;
  --inv-soft: #f3f6fb;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.35' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-metric-counted {
  --inv-color: #ef1736;
  --inv-soft: #ffe8ee;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.05' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 2v4'/%3E%3Cpath d='M8 2v4'/%3E%3Crect x='4' y='4' width='16' height='18' rx='2'/%3E%3Cpath d='m9 14 2 2 4-5'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-metric-positive {
  --inv-color: #22c55e;
  --inv-soft: #eafaf1;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5'/%3E%3Cpath d='m5 12 7-7 7 7'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-metric-negative {
  --inv-color: #ef1736;
  --inv-soft: #fff0f3;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14'/%3E%3Cpath d='m19 12-7 7-7-7'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-metric-missing {
  --inv-color: #f59e0b;
  --inv-soft: #fff7df;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.05' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8h12l1 13H5L6 8z'/%3E%3Cpath d='M9 8a3 3 0 0 1 6 0'/%3E%3Cpath d='M12 12v4'/%3E%3Cpath d='M12 19h.01'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-metric-surplus {
  --inv-color: #7c3aed;
  --inv-soft: #f0e6ff;
  --inv-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.05' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3Cpath d='M12 11v6'/%3E%3Cpath d='M9 14h6'/%3E%3C/g%3E%3C/svg%3E");
}

#products .inventory-table-wrap {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  border: 1px solid #e3e8f3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(7, 26, 68, 0.08);
}

#products .inventory-table-wrap table {
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  color: #09265a;
  font-size: 13px;
}

#products .inventory-table-wrap th,
#products .inventory-table-wrap td {
  height: 40px;
  padding: 8px 24px;
  border-bottom: 0;
  color: #09265a;
  font-size: 13px;
  line-height: 1.15;
}

#products .inventory-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 44px;
  background: linear-gradient(180deg, #f8fbff 0%, #edf4ff 100%);
  color: #08295b;
  font-size: 12px;
  font-weight: 900;
  text-transform: none;
}

#products .inventory-table-wrap th.excel-filter-th {
  overflow: visible;
  min-width: 132px;
  padding: 5px 10px;
  vertical-align: top;
}

#products .inventory-table-wrap .excel-filter-trigger {
  min-height: 32px;
  padding: 6px 8px;
  border-color: #d7e2f3;
  background: #ffffff;
  color: #08295b;
  font-size: 11px;
  line-height: 1;
}

#products .inventory-table-wrap .inventory-sort-trigger {
  justify-content: space-between;
  gap: 10px;
}

#products .inventory-table-wrap .excel-filter-trigger span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#products .inventory-table-wrap .inventory-filter-icon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  background: #6a7a99;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h18'/%3E%3Cpath d='M7 12h10'/%3E%3Cpath d='M10 19h4'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h18'/%3E%3Cpath d='M7 12h10'/%3E%3Cpath d='M10 19h4'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

#products .inventory-table-wrap .inventory-filter-icon.asc {
  background: #0057d9;
  transform: rotate(180deg);
}

#products .inventory-table-wrap .inventory-filter-icon.desc {
  background: #0057d9;
}

#products .inventory-table-wrap .excel-filter-trigger.active {
  border-color: #0057d9;
  background: #eef6ff;
  color: #0057d9;
}

#products .inventory-table-wrap .excel-filter-menu {
  left: 10px;
  top: 40px;
  z-index: 30;
  text-align: left;
}

#products .inventory-table-wrap .inventory-sort-menu {
  width: 220px;
  padding: 8px;
}

#products .inventory-table-wrap .inventory-sort-menu .excel-filter-action {
  margin: 0;
}

#products .inventory-table-wrap .inventory-sort-menu .excel-filter-action + .excel-filter-action {
  margin-top: 6px;
}

#products .inventory-table-wrap tbody tr:nth-child(even) td {
  background: #fbfdff;
}

#products .inventory-table-wrap tbody tr:nth-child(odd) td {
  background: #ffffff;
}

#products .inventory-table-wrap td:nth-child(1),
#products .inventory-table-wrap td:nth-child(2),
#products .inventory-table-wrap td:nth-child(3) {
  font-weight: 600;
}

#products .inventory-table-wrap th:nth-child(4),
#products .inventory-table-wrap th:nth-child(5),
#products .inventory-table-wrap th:nth-child(6),
#products .inventory-table-wrap th:nth-child(7),
#products .inventory-table-wrap td:nth-child(4),
#products .inventory-table-wrap td:nth-child(5),
#products .inventory-table-wrap td:nth-child(6),
#products .inventory-table-wrap td:nth-child(7) {
  text-align: center;
}

#products .number-mark {
  width: 56px;
  min-width: 56px;
  min-height: 24px;
  height: 24px;
  justify-content: center;
  border: 1px solid #bdd4f6;
  border-radius: 6px;
  background: #f1f7ff;
  color: #0066e6;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

#products .number-mark.positive {
  border-color: #bfd4f8;
  background: #eef6ff;
  color: #0066e6;
}

#products .number-mark.negative {
  border-color: transparent;
  background: transparent;
  color: #0066e6;
}

#products .badge {
  min-width: 86px;
  min-height: 22px;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  padding: 3px 11px;
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
}

#products .badge.pending {
  background: #e9eff7;
  color: #30486a;
}

#products .badge.diff {
  background: #ffe08a;
  color: #d99100;
}

#products .badge.surplus {
  background: #e7fbef;
  color: #12833c;
}

#products .badge.missing {
  background: #ffe8ee;
  color: #ef1736;
}

#products .badge.ok {
  background: #e7fbef;
  color: #12833c;
}

#products .badge.recount {
  background: #ffe8ee;
  color: #ef1736;
}
