﻿:root {
  --brand: #17436c;
  --line: #d6dde8;
  --button: #c7d8f7;
  --button-border: #8ba9df;
  --button-hover: #b5caf0;
  --text: #121820;
  --muted: #5f6f82;
  --page: #f6f8fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--page);
  color: var(--text);
}

#loader {
    position: fixed;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
}

#loader::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px;
    border: 4px solid #ccc;
    border-top: 4px solid #001c72;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.topbar {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 24px;
  background: #eef2f7;
  border-top: 2px solid #b0182a;
  border-bottom: 1px solid var(--line);
}

.brand-text {
  color: var(--brand);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-mark {
  width: 74px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 800;
  font-size: 28px;
  border-left: 2px solid #bfc9d6;
  padding-left: 16px;
}

.current-user-summary {
  margin-left: auto;
  display: flex;
  align-items: stretch;
  gap: 8px;
  color: #103f52;
  font-size: 12px;
}

.current-user-summary[hidden] {
  display: none !important;
}

.current-user-summary div {
  min-width: 116px;
  display: grid;
  gap: 2px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.current-user-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.current-user-summary strong {
  overflow: hidden;
  color: #103f52;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}


main {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 58px 18px;
  background: #ffffff;
}

body:not(.logged-in) main {
  display: none;
}

body.logged-in .login-screen {
  display: none;
}

.login-screen {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background: #ffffff;
}

.login-panel {
  width: min(100%, 440px);
  display: grid;
  gap: 12px;
  padding: 28px 34px 24px;
  border: 1px solid #d6e5ea;
  border-radius: 16px;
  background: #f8fcfd;
  box-shadow: 0 18px 50px rgba(23, 67, 108, 0.12);
}

.login-title {
  margin: 0 0 26px;
  color: #0068bf;
  font-size: 15px;
  text-align: center;
}

.login-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.login-row label {
  font-size: 13px;
  text-align: right;
}

.login-row input {
  width: 100%;
  height: 32px;
  padding: 5px 8px;
  border-radius: 6px;
  border-color: #bdd5df;
  font-size: 14px;
}

.login-actions{
    display:grid;
    grid-template-columns: repeat(3, 1fr);
    gap:14px;
    margin-top:24px;
}

.login-actions button{
    display:flex;
    align-items:center;
    justify-content:center;
    min-width:0;
    min-height:48px;
    padding:8px 10px;
    font-size:16px;
    font-weight:700;
    text-align:center;
    border:1px solid #b9d2d8;
    border-radius:9px;
    background:#e7f1f3;
    cursor:pointer;
    transition:0.2s;
    line-height:1.15;
}

.login-actions button:nth-child(2){
    font-size:14px;
}

.login-actions button:hover{
    background:#d7e8ec;
}

.login-error {
  min-height: 18px;
  color: #d31313;
  font-size: 13px;
  text-align: center;
  font-weight: 700;
}

.login-version {
  color: #0068bf;
  font-size: 12px;
  text-align: right;
}

@media (max-width: 520px) {
  .login-panel {
    padding: 24px 22px 20px;
  }

  .login-row {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .login-actions {
    gap: 10px;
  }

  .login-actions button {
    font-size: 14px;
    min-height: 44px;
    padding-inline: 6px;
  }
}

.dashboard {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
  align-items: start;
}

.section-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.actions {
  display: grid;
  gap: 10px;
}

.catalogue-item-form[hidden] {
  display: none !important;
}

.action-button {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--button-border);
  border-radius: 4px;
  background: linear-gradient(#d8e5fb, var(--button));
  color: #1a3154;
  font-size: 13px;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.action-button:hover,
.action-button:focus {
  background: linear-gradient(#cbdcf7, var(--button-hover));
  outline: 2px solid rgba(23, 67, 108, 0.2);
  outline-offset: 2px;
}

.note {
  grid-column: 1 / -1;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.dashboard-footer {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
}

.dashboard-footer .dashboard-logout {
  max-width: 220px;
  text-align: center;
  color: #b42318;
  font-weight: 600;
}

.dashboard-footer .dashboard-logout:hover {
  background: #fef3f2;
  border-color: #f9c9c2;
}

.screen {
  width: min(100%, 1060px);
  display: none;
}

.screen:target {
  display: block;
}

.item-master-screen:target {
  display: block;
}

.item-catalogue-screen:target {
  display: block;
}

.inventory-menu-screen:target,
.sap-items-screen:target,
.supplier-po-screen:target,
.product-development-screen:target,
.product-development-detail-screen:target {
  display: block;
}

body:has(.screen:target) .dashboard,
body:has(.item-master-screen:target) .dashboard,
body:has(.item-catalogue-screen:target) .dashboard,
body:has(.inventory-menu-screen:target) .dashboard,
body:has(.sap-items-screen:target) .dashboard,
body:has(.supplier-po-screen:target) .dashboard,
body:has(.product-development-screen:target) .dashboard,
body:has(.product-development-detail-screen:target) .dashboard {
  display: none;
}

.screen-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: start;
  padding: 8px 0 16px;
  border-bottom: 1px solid #bcc5d2;
  position: relative;
}

.screen-title {
  margin: 0 0 22px;
  color: #061f9e;
  font-family: "Courier New", monospace;
  font-size: 20px;
  text-align: center;
}

.screen-title.left {
  text-align: left;
}

.search-fields {
  display: grid;
  grid-template-columns: auto minmax(240px, 420px) auto auto auto;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.import-status {
  min-height: 18px;
  margin-top: 8px;
  text-align: center;
  color: #103f52;
  font-size: 13px;
  font-weight: 700;
}

.import-status.error {
  color: #c80020;
}

/* Tighten the Search Beneficiary header so the table sits closer to the
   search row: smaller title margin, less header padding, and collapse the
   import-status placeholder while it is empty. */
#search-beneficiary .screen-title {
  margin-bottom: 10px;
}

#search-beneficiary .screen-header {
  gap: 8px;
  padding: 6px 0 8px;
}

#search-beneficiary .import-status:empty {
  min-height: 0;
  margin-top: 0;
}

.import-panel {
  width: min(620px, 96vw);
  display: grid;
  gap: 12px;
}

.import-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.po-add-beneficiary-grid {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #cfe2e8;
  border-radius: 8px;
  background: #f7fbfc;
}

.po-add-beneficiary-grid table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.po-add-beneficiary-grid th:first-child {
  width: 28px;
}

.po-add-beneficiary-grid th:nth-child(3) {
  width: 96px;
}

.po-add-beneficiary-grid th:last-child {
  width: 40px;
}

.po-add-beneficiary-grid .ts-wrapper,
.po-add-beneficiary-grid .ts-control {
  width: 100%;
  min-width: 0;
}

/* TomSelect dropdowns rendered with dropdownParent: "body" must sit above modals (z-index 999). */
body > .ts-dropdown {
  z-index: 10000;
  border: 1px solid #bdd5df;
  border-radius: 6px;
}

.po-add-beneficiary-grid th,
.po-add-beneficiary-grid td {
  padding: 6px 8px;
  border-bottom: 1px solid #dce8ec;
  text-align: left;
  font-size: 13px;
}

.po-add-beneficiary-grid th {
  position: sticky;
  top: 0;
  background: #eaf3f6;
  font-weight: 600;
}

.po-add-beneficiary-grid td:first-child {
  width: 28px;
  color: var(--muted);
}

.po-add-beneficiary-grid td:nth-child(3) {
  width: 96px;
}

.po-add-beneficiary-grid td:last-child {
  width: 40px;
}

.po-add-beneficiary-grid select {
  width: 100%;
  min-height: 30px;
}

.po-add-ben-remove {
  min-height: 28px;
  min-width: 28px;
  padding: 0 8px;
}

.import-file-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #cfe2e8;
  border-radius: 8px;
  background: #f7fbfc;
}

.import-file-card > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.import-file-label,
.import-preview-grid span {
  color: var(--muted);
  font-size: 12px;
}

#beneficiaryImportFileName,
#beneficiaryImportFilePath,
#sapItemsImportFileName,
#sapItemsImportFilePath,
#supplierPoImportFileName,
#supplierPoImportFilePath {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#beneficiaryImportFilePath,
#sapItemsImportFilePath,
#supplierPoImportFilePath {
  color: #3d5968;
  font-size: 12px;
}

.import-preview-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
}

.import-preview-grid > div,
.import-result-box {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #cfe2e8;
  border-radius: 8px;
  background: #ffffff;
}

.import-result-box {
  min-height: 76px;
  color: #103f52;
  font-weight: 700;
  white-space: pre-line;
}

.import-result-box.error {
  color: #c80020;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-soft {
  background: #dff4f7;
  border-color: #9bced8;
  color: #003c54;
  font-weight: 700;
}

.danger-soft {
  background: #fff1f3;
  border-color: #e7aab4;
  color: #9b1024;
}

.search-fields.left {
  justify-content: start;
}

label {
  font-size: 14px;
}

input,
select {
  height: 25px;
  border: 1px solid #8792a0;
  border-radius: 0;
  padding: 2px 6px;
  font: inherit;
  background: #fff;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #eef3f8;
  color: #435268;
  cursor: not-allowed;
}

.utility-actions {
  display: grid;
  grid-template-columns: repeat(1, 112px);
  gap: 8px;
  justify-content: end;
  align-self: end;
  position: relative;
}

.utility-actions.customer-actions {
  grid-template-columns: repeat(2, 66px);
  align-self: center;
}

#custom-order .customer-header > .utility-actions.customer-actions,
#custom-order-preparation .customer-header > .utility-actions.customer-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  position: static;
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0;
  align-self: center;
}
#custom-order .customer-header .utility-actions.customer-actions .exit-button,
#custom-order-preparation .customer-header .utility-actions.customer-actions .exit-button {
  position: relative;
  top: auto;
  right: auto;
}

.small-button {
  min-height: 36px;
  border: 1px solid var(--button-border);
  border-radius: 4px;
  background: linear-gradient(#d8e5fb, var(--button));
  color: #1a3154;
  font-size: 13px;
  cursor: pointer;
}

.small-button.exit-button{
    width: 40px;
    height: 30px;
    border-radius: 8px !important;
}

.screen,
.profile-screen,
.po-delivery-screen,
.order-item-screen,
.workshop-detail-screen,
.beneficiary-upload-screen,
.standard-size-screen,
.standard-size-body,
.measurement-print-screen,
.receiving-print-screen {
  position: relative;
}

.exit-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid #afafb2;
  background: #d0d0d0;
  color: #1a3154;
  display: inline-grid;
  place-items: center;
  position: relative;
  z-index: 5;
}

.screen-header .exit-button {
  position: absolute;
  top: 28px;
  right: 16px;
}

.customer-header .exit-button,
.upload-top .exit-button,
.print-actions .exit-button {
  position: absolute;
  top: 4px;
  right: 16px;
}

.icon-exit::before,
.icon-exit::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 2px;
  background: #1a3154;
  border-radius: 1px;
  transform: translate(-50%, -50%);
}

.icon-exit::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.icon-exit::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.prn-column,
.prn-cell {
  width: 88px;
  min-width: 80px;
  max-width: 100px;
  font-size: 13px;
}

.icon-exit::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.inline-edit-button {
  width: 30px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #b9d8e1;
  border-radius: 7px;
  background: #eaf8fa;
  color: var(--brand);
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  line-height: 1;
}

.inline-edit-button:hover,
.inline-edit-button:focus {
  background: #d9f0f4;
  outline: 1px solid #bdd5df;
}

.inline-edit-button.delete {
  color: #a51d2d;
  background: #fff0f2;
  border-color: #f0c7ce;
}

.inline-edit-button.packing-button {
  width: 44px;
  font-size: 12px;
  color: #ffffff;
  background: #1d68b3;
  border-color: #15518e;
}

.inline-edit-button.packing-button:hover,
.inline-edit-button.packing-button:focus {
  background: #155da3;
  outline-color: #9fc7ef;
}

.icon-only {
  position: relative;
  font-size: 0;
}

.icon-only::before,
.icon-only::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
}

.icon-edit::before {
  width: 13px;
  height: 5px;
  border-radius: 2px;
  background: var(--brand);
  transform: translate(-50%, -50%) rotate(-35deg);
}

.icon-edit::after {
  width: 0;
  height: 0;
  border-left: 5px solid var(--brand);
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  transform: translate(4px, -7px) rotate(-35deg);
}

.icon-delete::before,
.icon-delete::after {
  width: 15px;
  height: 2px;
  border-radius: 2px;
  background: #a51d2d;
}

.icon-delete::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.icon-delete::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.master-edit-input {
  width: 100%;
  height: 24px;
  border: 1px solid transparent;
  background: transparent;
  padding: 1px 4px;
}

.master-edit-input:focus {
  border-color: #9ac8d5;
  background: #fff;
  outline: none;
}

.sort-header {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.sort-header::after {
  content: "  v";
  color: #5f6f82;
  font-size: 10px;
}

.update-menu {
  display: none;
  position: absolute;
  right: 120px;
  top: 44px;
  width: 210px;
  border: 1px solid #8ba9df;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.18);
  z-index: 2;
}

.update-menu.open {
  display: block;
}

.menu-choice {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-bottom: 1px solid #d8d8d8;
  background: #ffffff;
  color: #1a3154;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
}

.menu-choice:hover,
.menu-choice:focus {
  background: #eef4ff;
}

.grid-wrap {
  margin-top: 8px;
  border-top: 6px solid #c7c7cc;
  overflow: auto;
  max-height: 58vh;
  background: #fff;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border: 1px solid #d8d8d8;
  padding: 3px 6px;
  white-space: nowrap;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f7;
  color: #213247;
  font-weight: 400;
}

tbody tr:nth-child(even) {
  background: #f1f1f1;
}

.open-cell {
  width: 34px;
  padding: 0;
  text-align: center;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
}

.open-cell a {
  min-width: 34px;
  width: auto;
  padding: 0 8px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #04719a;
  border-radius: 8px;
  background: #057da8;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(0, 63, 87, 0.18);
}

.back-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--brand);
  font-size: 13px;
  text-decoration: none;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 0 0;
  font-size: 13px;
  color: #1a3154;
}

.pagination-bar .small-button {
  min-height: 30px;
  padding: 4px 12px;
}

.pagination-bar input {
  width: 70px;
  height: 30px;
  border-radius: 8px;
  border-color: #bdd5df;
}

.profile-screen {
  width: min(100%, 1180px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.profile-screen:target,
.customer-info-screen:target,
.po-info-screen:target,
.po-delivery-screen:target,
.beneficiary-upload-screen:target,
.item-order-screen:target,
.workshop-detail-screen:target,
.order-item-screen:target,
.measurement-print-screen:target,
.receiving-print-screen:target {
  display: block;
}

.standard-size-screen:target {
  display: grid;
}

body:has(.profile-screen:target) .dashboard,
body:has(.profile-screen:target) .screen,
body:has(.customer-info-screen:target) .dashboard,
body:has(.customer-info-screen:target) .screen,
body:has(.po-info-screen:target) .dashboard,
body:has(.po-info-screen:target) .screen,
body:has(.po-info-screen:target) .customer-info-screen,
body:has(.po-delivery-screen:target) .dashboard,
body:has(.po-delivery-screen:target) .screen,
body:has(.po-delivery-screen:target) .customer-info-screen,
body:has(.beneficiary-upload-screen:target) .dashboard,
body:has(.beneficiary-upload-screen:target) .screen,
body:has(.beneficiary-upload-screen:target) .customer-info-screen,
body:has(.beneficiary-upload-screen:target) .po-delivery-screen,
body:has(.item-order-screen:target) .dashboard,
body:has(.item-order-screen:target) .screen,
body:has(.item-order-screen:target) .profile-screen,
body:has(.workshop-detail-screen:target) .dashboard,
body:has(.workshop-detail-screen:target) .screen,
body:has(.workshop-detail-screen:target) .profile-screen,
body:has(.order-item-screen:target) .dashboard,
body:has(.order-item-screen:target) .screen,
body:has(.order-item-screen:target) .item-order-screen,
body:has(.standard-size-screen:target) .dashboard,
body:has(.standard-size-screen:target) .screen,
body:has(.measurement-print-screen:target) .dashboard,
body:has(.measurement-print-screen:target) .screen,
body:has(.measurement-print-screen:target) .profile-screen,
body:has(.receiving-print-screen:target) .dashboard,
body:has(.receiving-print-screen:target) .screen,
body:has(.receiving-print-screen:target) .item-order-screen,
body:has(.custom-prep-screen:target) .dashboard,
body:has(.custom-prep-screen:target) .screen {
  display: none;
}

body:has(.standard-size-screen:target) .profile-screen {
  display: block;
}

.profile-top {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 6px 10px;
  background: #eeeeee;
  border-top: 2px solid #c80020;
  border-bottom: 1px solid #c8c8c8;
}

.profile-id {
  color: #ff1730;
  font-size: 14px;
  padding-top: 8px;
}

.profile-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 400;
}

.profile-meta {
  display: grid;
  grid-template-columns: auto 130px 188px auto 188px;
  gap: 4px;
  align-items: center;
  font-size: 13px;
}

.profile-meta input {
  width: 100%;
}

.profile-actions {
  display: grid;
  grid-template-columns: 70px;
  justify-content: end;
  gap: 4px;
  /* Exit (X) is absolutely positioned top-right; the container's own
     padding-right already reserves its space, so a single right-aligned
     track puts Search snug beside the X without an empty gap or overlap. */
}

.profile-body {
  padding: 10px;
}

.profile-form {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(680px, 2fr);
  gap: 14px;
  align-items: start;
}

.field-grid {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 5px;
  align-items: center;
}

.field-grid.compact {
  grid-template-columns: 104px minmax(220px, 1fr);
}

.field-grid input,
.field-grid select,
.field-grid.compact input,
.field-grid.compact select {
  width: 100%;
  min-width: 0;
}

.field-grid label {
  color: #7b8795;
}

.edit-button {
  height: 29px;
  border: 1px solid var(--button-border);
  border-radius: 4px;
  background: linear-gradient(#d8e5fb, var(--button));
  color: #1a3154;
  cursor: pointer;
}

.two-col-fields {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) minmax(330px, 1fr);
  gap: 8px 18px;
}

.wide-field {
  grid-column: 1 / -1;
}


.name-badge-row {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) minmax(330px, 1fr);
  gap: 8px 18px;
  align-items: center;
  margin-top: 6px;
  font-size: 14px;
}

.badge-name-row {
  display: grid;
  grid-template-columns: 98px 1fr;
  gap: 8px 14px;
  align-items: center;
}

.badge-name-row.wide {
  grid-column: 1 / -1;
}

.badge-name-row input {
  width: 100%;
  min-width: 0;
}

.tabs {
  display: flex;
  align-items: end;
  gap: 1px;
  margin-top: 10px;
}

.tab {
  border: 1px solid #9ca9ba;
    border-bottom: 0;
    background: #e8edf4;
    padding: 10px;
    color: #24364d;
    font-size: 13px;
    border-radius: 0;
  }

.tab.active {
  background: #ffffff;
  color: #001c72;
}

.tab-panel {
  min-height: 460px;
  border: 1px solid #9ca9ba;
  background: #ffffff;
  padding: 10px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.delivery-title {
  margin-bottom: 16px;
  font-weight: 700;
  text-align: center;
}

.delivery-title span {
  display: inline-block;
}

.delivery-form {
  display: none;
}

.delivery-table {
  width: 100%;
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.delivery-table table {
  min-width: 820px;
}

.delivery-form label {
  color: #7b8795;
  text-align: center;
}

.delivery-form input,
.delivery-form select {
  width: 100%;
}

.delivery-open-button {
  min-width: 44px;
  width: auto;
  height: 28px;
  padding: 0 8px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #b9d8e1;
  border-radius: 9px;
  background: #eaf8fa;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.delivery-open-button::before,
.workshop-open-button::before {
  content: none;
}

.delivery-open-button:hover,
.delivery-open-button:focus {
  background: #d9f0f4;
  outline: 1px solid #bdd5df;
}

.delivery-form .delivery-open-button ~ .delivery-open-button {
  display: none;
}

.measurement-layout {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 10px;
  min-height: 430px;
}

.standard-size-panel,
.detail-size-panel {
  border-right: 1px solid #9ca9ba;
  padding: 4px 8px;
}

.detail-size-panel {
  border-right: 0;
}

.measurement-heading {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 700;
}

.standard-size-title {
  font-size: 14px;
  font-weight: 700;
}

.std-size-table table {
  min-width: 455px;
}

.std-size-table th,
.std-size-table td {
  padding: 2px 4px;
}

.measurement-detail-grid {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 12px;
  align-items: start;
}

.measure-table {
  border: 1px solid #9ca9ba;
  padding: 6px 10px;
}

.measure-table table {
  min-width: 240px;
  font-size: 14px;
}

.measure-table th,
.measure-table td {
  height: 32px;
  font-size: 14px;
}

.measure-table input {
  width: 100%;
  min-height: 28px;
  border: 0;
  background: transparent;
  padding: 2px 6px;
}

.remarks-panel {
  display: grid;
  gap: 4px;
}

.remarks-panel textarea {
  height: 110px;
  border: 1px solid #9ca9ba;
  resize: vertical;
  font: inherit;
}

.workshop-panel {
  min-height: 430px;
  padding: 6px;
  border: 1px solid #c8d4e1;
  background: #fff;
}

.workshop-title {
  margin: 0 0 16px 24px;
  color: #001c9f;
  font-weight: 700;
}

.workshop-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 24px 12px;
}

.workshop-title-row .workshop-title {
  margin: 0;
}

.workshop-table table {
  min-width: 940px;
}

.workshop-open-button {
  width: auto;
  min-width: 44px;
  height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.workshop-detail-screen {
  width: min(100%, 1180px);
  display: none;
  background: #f7fbfc;
  border: 1px solid #c8d4e1;
  border-top: 0;
  border-radius: 10px;
  box-shadow: 0 18px 45px rgba(0, 40, 55, 0.12);
  padding: 18px;
}

.workshop-detail-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.workshop-detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#workshopDetailExit {
    transform: translateY(-16px);
}

#workshopStickerButton {
  min-width: 104px;
  padding-inline: 12px;
}

.workshop-detail-title {
  margin: 0 0 12px;
  color: var(--brand);
  font-size: 22px;
  letter-spacing: 0;
}

.workshop-detail-grid {
  display: grid;
  /* 20 columns = LCM(4,5): row 1 fits 4 fields (span 5 each) and row 2
     fits 5 fields (span 4 each), so everything stays on two rows. */
  grid-template-columns: repeat(20, minmax(0, 1fr));
  gap: 10px 14px;
  margin-bottom: 14px;
}

/* Row 1: PO#, Date, Target Date, Item No */
.workshop-detail-grid > .workshop-detail-field:nth-child(-n+4) {
    grid-column: span 5;
}
/* Row 2: Order No, Job Type, Item, Size, Qty */
.workshop-detail-grid > .workshop-detail-field:nth-child(n+5):nth-child(-n+9) {
    grid-column: span 4;
}
/* Job Description fills the lower row, with the Job button beside it */
.workshop-detail-grid .workshop-detail-wide {
    grid-column: 1 / 16;
}
.workshop-detail-grid > #openJobDescListButton {
    grid-column: 16 / 21;
}
.workshop-meta-row {
  display: grid;
  grid-template-columns: 120px minmax(160px, 210px) minmax(190px, 250px) minmax(180px, 260px);
  gap: 14px;
  align-items: end;
  margin: 0 0 16px;
  justify-content: start;
}

.workshop-job-no {
  display: grid;
  gap: 4px;
  color: #c80020;
}

.workshop-job-no span {
  color: #687790;
  font-size: 13px;
}

.workshop-job-no strong {
  color: #c80020;
  font-size: 17px;
}

.workshop-detail-field {
  display: grid;
  gap: 4px;
  font-size: 13px;
  min-width: 0;
}

.workshop-detail-field span {
  color: #687790;
}

.workshop-detail-field strong {
  min-height: 24px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

.workshop-detail-field input,
.workshop-detail-field select,
.workshop-prep-control,
.workshop-action-row select,
.workshop-action-row strong {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid #c6dce5;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
}

.workshop-prep-control:disabled {
  color: #627386;
  background: transparent;
  border-color: transparent;
  opacity: 1;
  padding-left: 0;
}

.workshop-action-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 220px) auto auto minmax(150px, 220px) 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 4px 0 14px;
  font-size: 13px;
}

.workshop-action-row label {
  color: #687790;
}

#workshopSubmitButton,
#workshopClaimButton {
  width: 88px;
  min-width: 88px;
  justify-self: start;
  padding-inline: 10px;
}

.workshop-detail-wide {
  grid-column: span 2;
}

.workshop-item-field {
  grid-column: 2;
}

.workshop-size-field {
  grid-column: 3;
}

.workshop-qty-field {
  grid-column: 4;
  max-width: 92px;
}

.workshop-item-used-field[hidden] {
  display: none;
}

.workshop-worker-qty {
  width: 46px;
  min-height: 30px;
  padding: 4px 6px;
  text-align: center;
}

.workshop-row-action {
  width: 34px;
  min-width: 34px;
  height: 32px;
  padding: 0;
  border-radius: 7px;
  font-size: 16px;
  line-height: 1;
}

.workshop-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.workshop-panel-heading h2 {
  margin: 0;
}

.workshop-detail-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  border-bottom: 1px solid #c8d4e1;
}

.workshop-detail-tab {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  color: #526577;
  font-weight: 700;
  cursor: pointer;
}

.workshop-detail-tab.active {
  border-color: #c8d4e1;
  background: #fff;
  color: var(--brand);
}

.workshop-tab-pane {
  display: none;
}

.workshop-tab-pane.active {
  display: block;
}

.workshop-bottom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  margin: 8px 0 0 0;
}

.workshop-detail-status {
  color: #000;
  font-size: 20px;
  font-weight: 800;
  text-align: left;
  align-self: end;
  padding-bottom: 2px;
}

.workshop-detail-panels {
  display: block;
}

.workshop-detail-panel {
  min-width: 0;
  border: 1px solid #c8d4e1;
  background: #fff;
  padding: 10px;
  overflow: hidden;
}

.workshop-timing-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 8px;
}

.workshop-detail-panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--brand);
}

.workshop-detail-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

.workshop-detail-table th,
.workshop-detail-table td {
  border: 1px solid #d8e5eb;
  padding: 6px 8px;
  text-align: left;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workshop-detail-table th {
  background: #eaf5f6;
}

.workshop-detail-table input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid #c6dce5;
  border-radius: 6px;
  background: #fff;
  font: inherit;
}

.workshop-item-use-table th:nth-child(1),
.workshop-item-use-table td:nth-child(1) {
  width: 182px;
}

.workshop-item-use-table th:nth-child(2),
.workshop-item-use-table td:nth-child(2) {
  width: auto;
}

.workshop-item-use-table th:nth-child(3),
.workshop-item-use-table td:nth-child(3) {
  width: 80px;
  text-align: center;
}

.workshop-item-use-table th:nth-child(4),
.workshop-item-use-table td:nth-child(4) {
  width: 70px;
}

.workshop-item-use-table th:nth-child(5),
.workshop-item-use-table td:nth-child(5) {
  width: 150px;
}

.workshop-item-use-table th:nth-child(6),
.workshop-item-use-table td:nth-child(6) {
  width: 44px;
  text-align: center;
}

.workshop-item-use-table .ts-wrapper {
  width: 100%;
  min-width: 0;
  font-size: 12px;
}

.workshop-item-use-qty {
  text-align: center;
}

.workshop-item-use-warehouse {
  display: block;
  width: 100%;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid #c6dce5;
  border-radius: 6px;
  background: #f7fbfc;
  font: inherit;
  box-sizing: border-box;
  line-height: 1.4;
}

.workshop-timing-table th:nth-child(1),
.workshop-timing-table td:nth-child(1) {
  width: 55%;
}

.workshop-timing-table {
  width: 100%;
  min-width: 0;
}

.workshop-timing-table th:nth-child(2),
.workshop-timing-table td:nth-child(2),
.workshop-timing-table th:nth-child(3),
.workshop-timing-table td:nth-child(3) {
  width: 22.5%;
  text-align: center;
}

.workshop-timing-total {
  display: grid;
  grid-template-columns: 1fr 58px 58px;
  gap: 4px;
  align-items: center;
  margin-top: 0;
  font-size: 13px;
}

.workshop-timing-total span {
  text-align: right;
  font-weight: 700;
  padding-right: 8px;
}

.workshop-timing-total strong {
  min-height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #c8d4e1;
  background: #fff;
  font-weight: 600;
}

.record-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 365px;
  color: #4b5a6b;
  font-size: 12px;
}

.customer-info-screen {
  width: min(100%, 1290px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.customer-info-top {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 6px 12px 2px;
  background: #e3e9f1;
  border-top: 2px solid #c80020;
}

.customer-info-title {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
}

.customer-info-actions {
  display: grid;
  grid-template-columns: repeat(2, 84px);
  gap: 4px;
}

.customer-info-body {
  padding: 8px 12px 0;
}

.customer-fields {
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(500px, 1fr);
  gap: 54px;
  align-items: start;
}

.customer-field-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px;
  align-items: center;
  font-size: 14px;
}

.customer-field-grid label {
  color: #000;
}

.customer-code-row {
  display: grid;
  grid-template-columns: 58px 116px 64px 98px 64px 100px;
  gap: 4px;
  align-items: center;
}

.po-panel {
  margin-top: 12px;
  border: 1px solid #aeb7c4;
  background: #ffffff;
  max-width: 1100px;
  min-height: 520px;
  padding: 8px 16px 0;
}

.po-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  color: #001c9f;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
}

.po-heading-title {
  grid-column: 1 / -1;
}

.po-search-row {
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) auto;
  gap: 6px;
  align-items: center;
  justify-self: start;
  color: #062f43;
  font-weight: 400;
  text-align: left;
}

.po-search-row input {
  width: 100%;
}

.customer-save-status {
  grid-column: 1 / -1;
  min-height: 22px;
  color: #1f6f4a;
  font-size: 13px;
  font-weight: 700;
}

.po-create-form {
  display: none;
  grid-template-columns: 160px 140px 1fr 120px 96px;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 12px;
  background: #f8fbfb;
}

.po-create-form.open {
  display: grid;
}

.po-create-form input {
  width: 100%;
}

.po-grid {
  overflow: auto;
  max-height: 440px;
}

.po-grid table {
  min-width: 1040px;
}

.po-icon-cell {
  width: auto;
  text-align: center;
  background: transparent;
}

.po-icon-cell a {
  min-width: 34px;
  width: auto;
  padding: 0 8px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #04719a;
  border-radius: 8px;
  background: #057da8;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(0, 63, 87, 0.18);
}

.po-icon-cell a:hover,
.po-icon-cell a:focus {
  background: #026487;
  outline: 1px solid #81c7d8;
}

.po-icon-cell.delivery a {
  background: #f4b400;
  border-color: #d99d00;
  color: #1d1600;
  box-shadow: 0 2px 5px rgba(96, 70, 0, 0.2);
}

.po-info-screen {
  width: min(100%, 970px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.po-delivery-screen {
  width: min(100%, 1300px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.delivery-data-top {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 6px 28px 8px;
  border-top: 2px solid #c80020;
  background: #f4f4f4;
}

.delivery-actions {
  display: grid;
  grid-template-columns: repeat(2, 92px);
  gap: 4px;
  max-width: 80px;
  margin-left: auto;
}

.delivery-data-body {
  padding: 6px 28px 24px;
}

.delivery-data-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(360px, 420px);
  gap: 16px;
  align-items: start;
}

.delivery-data-layout > *,
.delivery-left-top > * {
  min-width: 0;
}

.delivery-left {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.delivery-left-top {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) 210px;
  gap: 10px;
  align-items: start;
}

.delivery-side-actions {
  display: grid;
  gap: 8px;
  width: 70px;
  margin-top: 12px;
}

.beneficiary-list-title {
  margin: 8px 0;
  text-align: center;
  font-size: 18px;
  font-weight: 400;
}

.beneficiary-delivery-grid {
  overflow: auto;
  max-height: 430px;
  background: #fff;
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 12px;
}

.beneficiary-delivery-grid table {
  min-width: 720px;
}

.yellow-cell {
  width: 34px;
  padding: 0;
  text-align: center;
  background: transparent;
  color: #5a4900;
  font-weight: 700;
}

.yellow-cell a {
  min-width: 34px;
  width: auto;
  padding: 0 8px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d99d00;
  border-radius: 8px;
  background: #f4b400;
  color: #1d1600;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(96, 70, 0, 0.2);
}

.delivery-right {
  display: grid;
  gap: 8px;
  align-items: start;
}

.delivery-right-top {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.remarks-box {
  display: grid;
  gap: 4px;
}

.remarks-box textarea {
  min-height: 160px;
  border: 1px solid #8792a0;
  font: inherit;
}


.sap-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 4px;
  align-items: center;
}

.uniform-tabs {
  display: flex;
  gap: 1px;
  margin-top: 2px;
}

.uniform-tab {
  border: 1px solid #9aa7b5;
  border-bottom: 0;
  background: #e8edf2;
  color: #17242d;
  padding: 5px 10px;
  font: inherit;
  cursor: pointer;
}

.uniform-tab.active {
  background: #ffffff;
  font-weight: 700;
}

.uniform-tab-panel[hidden] {
  display: none;
}

.uniform-panel {
  min-height: 160px;
  border-top: 1px solid #aeb7c4;
  background: #ffffff;
  padding: 8px;
  overflow-x: auto;
}

.uniform-set-grid {
  display: grid;
  grid-template-columns: minmax(124px, 1fr) repeat(5, 42px) minmax(150px, 1.2fr);
  gap: 4px;
  align-items: end;
  font-size: 13px;
  min-width: 560px;
}

.uniform-set-grid label {
  text-align: center;
  color: #000;
}

.uniform-set-grid select,
.uniform-set-grid input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.uniform-qty-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(124px, 1fr) repeat(5, 42px) minmax(150px, 1.2fr);
  gap: 4px;
  align-items: center;
}

.uniform-item-name {
  background: #f3f7f8;
  color: #17242d;
  }

.remaining-po-grid {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) repeat(3, 70px);
  gap: 4px;
  align-items: center;
  font-size: 13px;
  min-width: 360px;
}

.remaining-po-grid label {
  text-align: center;
  color: #000;
  font-weight: 700;
}

.remaining-po-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(130px, 1fr) repeat(3, 70px);
  gap: 4px;
  align-items: center;
}

.remaining-po-cell {
  min-height: 28px;
  border: 1px solid #8792a0;
  background: #f8fafc;
  padding: 4px 6px;
  box-sizing: border-box;
}

.remaining-po-number {
  text-align: right;
}

.remaining-po-empty {
  grid-column: 1 / -1;
  padding: 12px;
  text-align: center;
  color: #64748b;
}

.uniform-qty-row .po-qty-control {
  border: 1px solid rgba(31, 111, 139, 0.2);
  background: #ffffff;
  border-radius: 9px;
}

.uniform-qty-row .po-qty-control:disabled {
  background: #eef3f8;
  color: #435268;
}

.uniform-empty-message {
  grid-column: 1 / -1;
  min-height: 28px;
  display: grid;
  align-items: center;
  color: #5f6f82;
  font-size: 13px;
}

.beneficiary-upload-screen {
  width: min(100%, 1140px);
  display: none;
  background: #ffffff;
  border: 1px solid #aeb7c4;
}

.upload-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 10px 140px 8px 50px;
  border-top: 2px solid #c80020;
  position: relative;
}

.upload-title {
  margin: 0;
  color: #061f9e;
  font-family: "Courier New", monospace;
  font-size: 22px;
  text-align: center;
}

.upload-warning {
  margin: 4px 0 18px;
  color: #ff0000;
  font-size: 13px;
}

.upload-body {
  padding: 0 0 130px;
}

.upload-grid {
  display: grid;
  grid-template-columns: 22px 100px 158px 120px 126px 104px 108px 222px 110px;
  align-items: end;
  gap: 4px;
  font-size: 13px;
}

.upload-grid label {
  color: #6e7885;
  text-align: center;
}

.upload-grid input,
.upload-grid select {
  width: 100%;
}

.item-order-screen {
  width: min(100%, 1008px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.item-order-body {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 10px;
  padding: 16px 20px 0;
  
}

.item-order-header {
  display: grid;
  grid-template-columns: 56px 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.item-order-title {
  margin: 4px 0 12px;
  color: #061f9e;
  font-family: "Courier New", monospace;
  font-size: 22px;
  text-align: center;
}

.item-order-fields {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 10px 8px;
  align-items: center;
  font-size: 14px;
}

.item-order-fields strong {
  font-size: 18px;
}

.item-order-fields.right {
  grid-template-columns: 92px 1fr;
  padding-top: 42px;
}

.item-side-actions {
  display: grid;
  align-content: start;
  gap: 8px;
}

.item-side-actions .small-button {
  width: 96px;
  min-height: 32px;
  padding: 4px 8px;
  font-size: 12px;
}

.item-remarks {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 4px;
  align-items: center;
  margin-top: 12px;
}

.entitled-panel {
  grid-column: 1 / -1;
  border: 1px solid #aeb7c4;
  background: #ffffff;
  margin-top: 12px;
  min-height: 390px;
}

.entitled-title {
  margin: 0;
  padding: 4px 0;
  font-size: 14px;
  font-weight: 700;
}

.entitled-grid {
  width: 100%;
  overflow: auto;
}

.entitled-grid table {
  min-width: 820px;
}

.edit-cell {
  width: 38px;
  background: transparent;
  text-align: center;
  font-weight: 700;
}

.edit-cell a {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.order-item-screen {
  width: min(100%, 840px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.order-item-top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 8px 20px 12px;
  border-top: 2px solid #c80020;
}

.order-item-title {
  margin: 6px 0 24px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.order-item-actions {
  display: grid;
  grid-template-columns: 50px 50px;
  gap: 6px;
}

.maintenance-grid {
  display: grid;
  grid-template-columns: 76px 92px 64px 160px 136px 220px;
  gap: 4px;
  align-items: end;
  font-size: 13px;
}

.maintenance-grid label {
  text-align: center;
  color: #000;
  font-weight: 700;
}

.maintenance-details {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 5px;
  align-items: center;
  margin: 6px 0 14px 56px;
  font-size: 14px;
}

.maintenance-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-bottom: 158px;
}

.maintenance-buttons .small-button {
  min-width: 94px;
  min-height: 42px;
}

.standard-size-screen {
  position: fixed;
  inset: 0;
  z-index: 22;
  width: 100%;
  display: none;
  place-items: center;
  background: rgba(0, 23, 38, 0.24);
  border: 0;
  padding: 24px;
}

.standard-size-body {
  width: min(500px, 94vw);
  padding: 24px 32px 28px;
  border: 1px solid #c8e1e8;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 60px rgba(0, 40, 55, 0.18);
}

.standard-size-form-title {
  margin: 0 0 16px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.standard-size-grid {
  display: grid;
  grid-template-columns: 64px 140px 140px;
  gap: 6px;
  align-items: end;
  justify-content: center;
  font-size: 13px;
}

.standard-size-grid label {
  text-align: center;
  font-weight: 700;
  color: #000;
}

/* TomSelect - standard size grid size field */
.standard-size-grid .ts-wrapper {
  width: 140px;
}
.standard-size-grid .ts-control,
.standard-size-grid .ts-control input,
.standard-size-grid .ts-dropdown {
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}
.standard-size-grid .ts-control {
  min-height: 28px;
  border: 1px solid #bdd5df;
  border-radius: 6px;
  padding: 3px 8px;
  background: #ffffff;
  box-shadow: none;
  cursor: text;
}
.standard-size-grid .ts-control input {
  min-height: unset;
  border: 0;
  padding: 0;
  background: transparent;
}
.standard-size-grid .ts-control .item {
  font-size: inherit;
  font-family: inherit;
  font-weight: 700;
  line-height: inherit;
}
.standard-size-grid .ts-dropdown {
  z-index: 9999;
  border: 1px solid #bdd5df;
  border-radius: 6px;
}
.standard-size-grid .ts-dropdown .option {
  padding: 4px 8px;
}
.standard-size-grid .ts-dropdown .option:hover,
.standard-size-grid .ts-dropdown .option.active {
  background: #eaf3f7;
  color: inherit;
}

.barcode-row {
  display: grid;
  grid-template-columns: 92px 1fr 126px;
  gap: 8px;
  align-items: center;
  max-width: none;
  margin: 8px auto 0;
  width: 398px;
  font-size: 14px;
}

.standard-size-buttons {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 6px;
  justify-content: end;
}

.standard-size-buttons .small-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.standard-size-buttons .delete {
  color: #a51d2d;
  background: #fff0f2;
  border-color: #f0c7ce;
  position: absolute;
  top: 12px;
  left: 12px;
}

.standard-size-buttons .undo {
  color: #4d5b66;
  background: #f5fafb;
  border-color: #c8e1e8;
}

#deleteStandardSizeButton,
#undoStandardSizeButton,
#finishStandardSizeButton {
  font-size: 12px;
}

#deleteStandardSizeButton::before,
#undoStandardSizeButton::before,
#finishStandardSizeButton::before {
  font-size: 18px;
}

#deleteStandardSizeButton::before {
  content: "\1F5D1";
}

#undoStandardSizeButton::before {
  content: "\21b6";
}

#finishStandardSizeButton::before {
  content: "\2713";
}

.history-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 23, 38, 0.28);
  padding: 24px;
  animation: history-overlay-fade 0.18s ease-out;
}

.history-overlay[hidden] {
  display: none;
}

.history-panel {
  width: min(920px, 96vw);
  max-height: 82vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #c8e1e8;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 40, 55, 0.18);
  padding: 18px;
  animation: history-panel-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center top;
  will-change: transform, opacity;
}

@keyframes history-overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes history-panel-pop {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-overlay,
  .history-panel {
    animation: none;
  }
}

/* History loading state */
.history-loading {
  text-align: center;
  padding: 28px 12px !important;
  color: #5a7a86;
  font-weight: 600;
}

.history-loading .history-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: -4px;
  border: 2px solid #c8e1e8;
  border-top-color: #2a6f86;
  border-radius: 50%;
  animation: history-spin 0.7s linear infinite;
}

@keyframes history-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .history-loading .history-spinner {
    animation: none;
  }
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.measurement-print-screen,
.receiving-print-screen {
  display: none;
  background: #c7c7c7;
  padding: 28px 0;
}

.a4-page {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: #ffffff;
  color: #000;
  padding: 28px 42px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  font-family: Arial, Helvetica, sans-serif;
}

.print-header {
  display: grid;
  grid-template-columns: 72px 1fr 96px;
  align-items: start;
  gap: 12px;
}

.print-logo {
  color: var(--brand);
  font-weight: 800;
  font-size: 16px;
  line-height: 1.1;
  text-align: center;
}

.print-title-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  margin: 28px 0 18px;
  font-size: 16px;
  text-align: center;
}

.print-info-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 16px;
  font-size: 16px;
}

.print-box {
  border: 1px solid #000;
  margin-bottom: 4px;
}

.print-line {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #000;
}

.print-line:last-child {
  border-bottom: 0;
}

.print-cell {
  padding: 6px 8px;
  border-right: 1px solid #000;
  min-height: 30px;
}

.print-cell:last-child {
  border-right: 0;
}

.print-section-title {
  background: #f0f0f0;
  padding: 5px 0;
  font-weight: 700;
}

.print-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 14px;
}

.print-table th,
.print-table td {
  border: 1px solid #b8b8b8;
  padding: 5px;
  height: 28px;
  white-space: normal;
}

.print-table th {
  background: #ffffff;
  color: #000;
  font-weight: 700;
  position: static;
}

.print-measure-layout {
  display: grid;
  grid-template-columns: 270px 270px;
  gap: 102px;
  margin: 8px 4px 0;
  align-items: start;
}

.receiving-page {
  width: 744px;
  min-height: 1052px;
  margin: 0 auto;
  background: #ffffff;
  color: #000;
  padding: 28px 32px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  font-family: Arial, Helvetica, sans-serif;
}

.receiving-header {
  display: grid;
  grid-template-columns: 90px 1fr 78px;
  gap: 10px;
  align-items: start;
}

.receiving-title {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin: 16px 0 22px;
  font-size: 16px;
}

.receiving-title-main {
  grid-column: 2;
  text-align: center;
}

.receiving-title-po {
  grid-column: 3;
  text-align: right;
  padding-right: 18px;
}

.receiving-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 14px;
  font-size: 14px;
}

.receiving-info-line {
  margin-bottom: 8px;
}

.receiving-center-line {
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr;
  column-gap: 22px;
  margin-bottom: 22px;
  font-size: 18px;
  align-items: center;
}

.receiving-company-line {
  text-align: center;
  justify-self: center;
  max-width: 100%;
}

.receiving-prn-line {
  text-align: right;
  justify-self: end;
  white-space: nowrap;
}

.receiving-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 14px;
}

.receiving-table th,
.receiving-table td {
  border: 1px solid #aeb7c4;
  height: 32px;
  padding: 3px;
  white-space: normal;
}

.receiving-table th {
  position: static;
  background: #ffffff;
  color: #000;
  font-weight: 400;
  text-align: center;
}

.receiving-table .release-col {
  width: 54px;
  text-align: center;
}

.receiving-table .qty-col {
  width: 62px;
  text-align: center;
}

.receiving-table .signature-col {
  width: 132px;
  text-align: center;
}

.receiving-table .size-col {
  width: 172px;
}

.receiving-table .remarks-col {
  width: 122px;
}

/* TomSelect - receiving form size column */
.receiving-table .size-col .ts-wrapper {
  width: 100%;
}
.receiving-table .size-col .ts-control,
.receiving-table .size-col .ts-control input,
.receiving-table .size-col .ts-dropdown {
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}
.receiving-table .size-col .ts-control {
  min-height: 28px;
  border: 1px solid #bdd5df;
  border-radius: 6px;
  padding: 3px 8px;
  background: #ffffff;
  box-shadow: none;
  cursor: text;
}
.receiving-table .size-col .ts-control input {
  min-height: unset;
  border: 0;
  padding: 0;
  background: transparent;
}
.receiving-table .size-col .ts-control .item {
  font-size: inherit;
  font-family: inherit;
  font-weight: 700;
  line-height: inherit;
}
.receiving-table .size-col .ts-dropdown {
  z-index: 9999;
  border: 1px solid #bdd5df;
  border-radius: 6px;
}
.receiving-table .size-col .ts-dropdown .option {
  padding: 4px 8px;
}
.receiving-table .size-col .ts-dropdown .option:hover,
.receiving-table .size-col .ts-dropdown .option.active {
  background: #eaf3f7;
  color: inherit;
}

.receiving-table input,
.receiving-table select {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
}

.scan-size-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 4px;
  align-items: center;
}

.release-scan-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 4px;
  align-items: center;
}

.release-scan-fields .release-sap-no {
  grid-column: 1;
}

.release-scan-button {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}

.release-stock-info {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: #314154;
}

.release-stock-info .error {
  color: #b00020;
  font-weight: 700;
}

.scan-size-button {
  border: 1px solid #b9d8e1;
  background: #e7f6f8;
  color: var(--brand);
  border-radius: 6px;
  min-height: 28px;
  font-weight: 700;
  cursor: pointer;
}

.scanner-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 24, 36, 0.58);
  z-index: 999;
  padding: 18px;
}

.scanner-modal[hidden] {
  display: none !important;
}

.scanner-panel {
  width: min(520px, 96vw);
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #b9d8e1;
  padding: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
  position: relative;
}

.scanner-panel h2 {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--brand);
}

.receiving-history-panel {
  width: min(980px, 96vw);
}

.beneficiary-sizes-panel {
  width: min(1200px, 97vw);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.beneficiary-sizes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.beneficiary-sizes-head h2 {
  margin: 0;
}

.beneficiary-sizes-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.beneficiary-sizes-tools input[type="search"] {
  min-width: 260px;
  padding: 6px 10px;
  border: 1px solid #b9d8e1;
  border-radius: 6px;
}

.beneficiary-sizes-status {
  font-size: 13px;
  color: #56707b;
  margin-bottom: 6px;
}

.beneficiary-sizes-status.error {
  color: #b3261e;
}

.beneficiary-sizes-grid {
  overflow: auto;
  border: 1px solid #d7e7ec;
  border-radius: 6px;
}

.beneficiary-sizes-grid table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
  white-space: nowrap;
}

.beneficiary-sizes-grid th,
.beneficiary-sizes-grid td {
  border: 1px solid #e1edf1;
  padding: 5px 9px;
  text-align: left;
}

.beneficiary-sizes-grid thead th {
  position: sticky;
  top: 0;
  background: #eef6f9;
  color: var(--brand);
  z-index: 1;
}

.beneficiary-sizes-grid tbody tr:nth-child(even) {
  background: #f7fbfc;
}

.receiving-history-wrap {
  max-height: min(62vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
}

.receiving-history-table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed;
}

.receiving-history-table th,
.receiving-history-table td {
  white-space: normal;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.receiving-history-table th:nth-child(1),
.receiving-history-table td:nth-child(1) {
  width: 136px !important;
  min-width: 0 !important;
}

.receiving-history-table th:nth-child(2),
.receiving-history-table td:nth-child(2) {
  width: 46px !important;
  min-width: 0 !important;
  text-align: center;
}

.receiving-history-table th:nth-child(3),
.receiving-history-table td:nth-child(3) {
  width: 120px !important;
  min-width: 0 !important;
}

.receiving-history-table th:nth-child(4),
.receiving-history-table td:nth-child(4) {
  width: 74px !important;
  min-width: 0 !important;
}

.receiving-history-table th:nth-child(6),
.receiving-history-table td:nth-child(6),
.receiving-history-table th:nth-child(7),
.receiving-history-table td:nth-child(7) {
  width: 92px !important;
  min-width: 0 !important;
}

.receiving-history-table .history-action-cell {
  text-align: center;
}

.receiving-history-table .small-button {
  width: 78px;
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
  box-sizing: border-box;
  white-space: nowrap;
}

.receiving-history-table th {
  font-size: 12px;
}

.receiving-history-table td {
  font-size: 12px;
}

.receiving-history-empty {
  text-align: center;
  color: #65727a;
  padding: 18px 8px;
}

.po-reports-choice-panel {
  width: min(360px, 92vw);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.po-reports-choice-panel .import-actions {
  justify-content: center;
}

.scanner-video {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #001824;
  border-radius: 6px;
  object-fit: cover;
}

.scanner-status {
  min-height: 22px;
  margin: 8px 0;
  color: var(--brand);
  font-weight: 700;
}

.packing-panel {
  width: min(620px, 96vw);
}

.packing-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.packing-header h2 {
  margin: 0;
}

.packing-top-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0 8px;
   align-items: left;
}

.packing-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: var(--brand);
  font-weight: 700;
}

.packing-loading[hidden] {
  display: none !important;
}

.packing-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #cfe4ea;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: packing-spin 0.8s linear infinite;
}

@keyframes packing-spin {
  to {
    transform: rotate(360deg);
  }
}

.packing-summary,
.packing-form {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 8px 10px;
  align-items: center;
  margin: 12px 0;
}

.packing-summary label,
.packing-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.packing-summary strong,
.packing-form strong {
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #d3e1e8;
  border-radius: 6px;
  background: #f8fbfd;
}

.packing-form input {
  width: 100%;
  box-sizing: border-box;
  min-height: 34px;
  border: 1px solid #bdd5df;
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
}

.packing-summary input {
  width: 100%;
  box-sizing: border-box;
  min-height: 34px;
  border: 1px solid #bdd5df;
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
}

.packing-form input[readonly] {
  background: #f8fbfd;
  color: var(--ink);
  font-weight: 700;
}

.packing-form select {
  width: 100%;
  box-sizing: border-box;
  min-height: 34px;
  border: 1px solid #bdd5df;
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
  background: #ffffff;
}

/* TomSelect - Size field (inside .packing-summary) */
.packing-summary .ts-wrapper,
.packing-form .ts-wrapper {
  width: 100%;
}
/* Override TomSelect's hardcoded font-size:13px / line-height:18px */
.packing-summary .ts-control,
.packing-summary .ts-control input,
.packing-summary .ts-dropdown,
.packing-form .ts-control,
.packing-form .ts-control input,
.packing-form .ts-dropdown {
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}
.packing-summary .ts-control,
.packing-form .ts-control {
  min-height: 34px;
  border: 1px solid #bdd5df;
  border-radius: 6px;
  padding: 5px 9px;
  background: #ffffff;
  box-shadow: none;
  cursor: text;
}
.packing-summary .ts-control input,
.packing-form .ts-control input {
  min-height: unset;
  border: 0;
  padding: 0;
  background: transparent;
}
.packing-summary .ts-control .item,
.packing-form .ts-control .item {
  font-size: inherit;
  font-family: inherit;
  font-weight: 700;
  line-height: inherit;
}
.packing-summary .ts-dropdown,
.packing-form .ts-dropdown {
  z-index: 9999;
  border: 1px solid #bdd5df;
  border-radius: 6px;
}
.packing-summary .ts-dropdown .option,
.packing-form .ts-dropdown .option {
  padding: 6px 10px;
}
.packing-summary .ts-dropdown .option:hover,
.packing-summary .ts-dropdown .option.active,
.packing-form .ts-dropdown .option:hover,
.packing-form .ts-dropdown .option.active {
  background: #eaf3f7;
  color: inherit;
}
.packing-form .ts-dropdown .option:hover,
.packing-form .ts-dropdown .option.active {
  background: #eaf3f7;
  color: inherit;
}

.packing-sap-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.packing-sap-open-button,
.packing-scan-button {
  min-height: 34px;
  white-space: nowrap;
  padding: 0 10px;
}

.packing-status {
  min-height: 22px;
  color: var(--brand);
  font-weight: 700;
}

.packing-status.error {
  color: #b0182a;
}

.packing-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.release-check {
  width: 18px !important;
  height: 18px;
  accent-color: var(--brand);
}

.release-signature-img:not([hidden]) {
  max-width: 118px;
  max-height: 26px;
  display: block;
  margin: 0 auto;
}

.release-signature-img[hidden] {
  display: none !important;
}

.release-controls {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #aeb7c4;
  background: #f8fcfd;
  font-size: 13px;
}

.release-controls[hidden],
.release-otp-row[hidden] {
  display: none !important;
}

.release-control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.release-signature-canvas {
  width: 100%;
  height: 138px;
  border: 1px solid #aeb7c4;
  background: #ffffff;
  touch-action: none;
  display: block;
  margin-top: 8px;
}

.release-status-text {
  color: var(--brand);
  font-weight: 700;
  min-height: 18px;
}

.release-receiver-option {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #aeb7c4;
  background: #ffffff;
  font-size: 13px;
}

.release-receiver-option label {
  font-weight: 700;
}

.release-receiver-option input[type="checkbox"] {
  width: auto;
  margin-right: 6px;
  accent-color: var(--brand);
}

.release-other-person-fields {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.release-other-person-fields[hidden] {
  display: none !important;
}

.release-other-person-fields textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid #aeb7c4;
  border-radius: 4px;
  padding: 6px;
  font: inherit;
}

.nothing-follows {
  margin-top: 338px;
  text-align: center;
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.receiving-remarks-print {
  margin-top: 18px;
  font-size: 13px;
  white-space: pre-wrap;
}

.signature-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 88px;
  margin-top: 48px;
  font-size: 14px;
}

.signature-line {
  display: inline-block;
  width: 200px;
  border-bottom: 1px solid #000;
  margin-left: 8px;
  vertical-align: bottom;
  min-height: 42px;
  position: relative;
}

.print-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  width: 794px;
  margin: 0 auto 8px;
  position: relative;
}

@page {
  size: A4 portrait;
  margin: 8mm;
}

@page customPrep {
  size: A4 landscape;
  margin: 6mm;
}

@media print {
  body {
    background: #ffffff;
    margin: 0;
  }

  .topbar,
  .dashboard,
  .screen,
  .profile-screen,
  .customer-info-screen,
  .po-info-screen,
  .po-delivery-screen,
  .beneficiary-upload-screen,
  .item-order-screen,
  .order-item-screen,
  .release-actions,
  .release-controls,
  .print-actions {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .measurement-print-screen,
  .receiving-print-screen {
    display: none !important;
    padding: 0;
    background: #ffffff;
  }

  body:has(#measurement-print:target) #measurement-print,
  body:has(#receiving-print:target) #receiving-print {
    display: block !important;
  }

  body:has(.custom-prep-screen:target),
  body:has(.custom-prep-screen:target) main {
    page: customPrep;
  }
  html:has(.custom-prep-screen:target),
  body:has(.custom-prep-screen:target),
  body:has(.custom-prep-screen:target) main {
    height: 190mm !important;
    max-height: 190mm !important;
    overflow: hidden !important;
  }
  body:has(.custom-prep-screen:target) #loader,
  body:has(.custom-prep-screen:target) .login-screen {
    display: none !important;
  }

  /* Custom Order preparation: print the prep page on A4, dropping the drawing
     toolbar (Pen/Size/Eraser/Erase Part/Undo/Clear/Save) and header buttons.
     The drawing itself (background + SVG strokes) is kept. */
  body:has(.custom-prep-screen:target) .custom-prep-screen:target {
    display: block !important;
    width: 285mm !important;
    height: 190mm !important;
    box-sizing: border-box !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    overflow: hidden !important;
    /* Print this page on landscape A4 (other prints stay portrait). */
    page: customPrep;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .customer-header {
    padding: 2mm 4mm !important;
    min-height: 0 !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .screen-title {
    font-size: 20px !important;
    line-height: 1.1 !important;
    margin: 0 !important;
  }
  body:has(.custom-prep-screen:target) .custom-prep-draw-tools,
  body:has(.custom-prep-screen:target) #custom-order-preparation .customer-header .utility-actions {
    display: none !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-grid {
    grid-template-columns: 68mm 1fr !important;
    gap: 2mm !important;
    margin-top: 2mm !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-order-panel {
    padding: 2mm !important;
    border-radius: 0 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-info {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 2mm !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-info div,
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-measure {
    padding: 1mm 1.5mm !important;
    border-radius: 0 !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-measure {
    height: 12.5mm !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-info span,
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-measure span {
    font-size: 8px !important;
    line-height: 1.1 !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-info strong,
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-measure strong {
    min-height: 12px !important;
    font-size: 10px !important;
    line-height: 1.15 !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-measure-grid-sm {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1mm !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-prep-measure input {
    height: 5mm !important;
    padding: 0 1mm !important;
    font-size: 10px !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-panel {
    margin-top: 2mm !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-panel:first-child {
    margin-top: 0 !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-wrap {
    max-height: none !important;
    overflow: visible !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-table {
    font-size: 9px !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-table th,
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-table td {
    padding: 1mm 1.5mm !important;
  }
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-table th:last-child,
  body:has(.custom-prep-screen:target) #custom-order-preparation .custom-workshop-table td:last-child {
    display: none !important;
  }
  /* Keep the drawing proportional in print: set a definite width and let the
     height come from the background image's aspect ratio (set inline by JS), so
     the absolutely-positioned layers still have a height but nothing is squished. */
  body:has(.custom-prep-screen:target) .custom-prep-drawing-stage {
    width: 165mm !important;
    height: auto !important;
    max-height: 150mm !important;
    min-height: 0 !important;
    margin: 2mm auto 0 !important;
    border-radius: 0 !important;
  }

  .a4-page,
  .receiving-page {
    width: 194mm;
    min-height: auto;
    margin: 0;
    box-shadow: none;
    padding: 0;
    transform: none;
  }
}

.po-info-top {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 6px 28px 8px;
  border-top: 2px solid #c80020;
  background: #f4f4f4;
}

.po-title {
  margin: 8px 0 4px;
  font-size: 22px;
  font-weight: 400;
  text-align: center;
}

.po-actions {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

#poCreateCatalogueGroupButton {
  white-space: nowrap;
}

.po-body {
  padding: 0 28px 24px;
}

.po-layout {
  display: grid;
  grid-template-columns: 1fr 490px 206px;
  gap: 14px;
  align-items: start;
}

.po-fields {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 4px;
  align-items: center;
  font-size: 13px;
}

.po-fields input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  height: 30px;
  padding: 2px 8px;
  box-sizing: border-box;
}

.po-fields textarea {
  min-height: 75px;
  resize: vertical;
  border: 1px solid #8792a0;
  font: inherit;
  padding: 4px 6px;
}

.po-fields .date-alert {
  background: #ffc7cc;
}

.amount-row {
  display: grid;
  grid-template-columns: 86px 120px 34px 70px 78px 1fr;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
}

.status-box {
  background: #edf8fb;
  padding: 6px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 54px;
  gap: 4px;
  align-items: center;
  font-size: 13px;
}

.status-grid strong {
  text-align: center;
}

.status-grid input {
  text-align: center;
  font-weight: 700;
}

.delivery-percent {
  margin-top: 0;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
}

.delivery-percent input {
  height: 30px;
  min-height: 30px;
  padding: 2px 4px;
}

.item-qty-panel {
  margin-top: 8px;
  border: 1px solid #aeb7c4;
  background: #ffffff;
  min-height: 340px;
  padding: 0 8px;
}

.item-qty-title {
  margin: 0 0 14px;
  padding-top: 2px;
  text-align: center;
  font-size: 18px;
  font-weight: 400;
}

.item-qty-grid {
  display: grid;
  grid-template-columns: 42px minmax(220px, 2fr) 70px 70px minmax(220px, 1.5fr) auto;
  gap: 4px;
  align-items: end;
  font-size: 13px;
}

.item-qty-grid input,
.item-qty-grid select,
.item-qty-grid button {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.item-qty-grid button {
  justify-self: start;
}

.item-qty-grid label {
  text-align: center;
  color: #000;
}

.po-qty-table {
  min-width: 1360px;
}

.po-qty-table th:nth-child(1),
.po-qty-table td:nth-child(1) {
  width: 48px;
  text-align: center;
}

.po-qty-table th:nth-child(3),
.po-qty-table td:nth-child(3),
.po-qty-table th:nth-child(4),
.po-qty-table td:nth-child(4),
.po-qty-table th:nth-child(5),
.po-qty-table td:nth-child(5) {
  width: 100px;
}

.po-qty-table th:nth-child(n+6):nth-child(-n+10),
.po-qty-table td:nth-child(n+6):nth-child(-n+10) {
  width: 64px;
}

.po-qty-table th:nth-child(12),
.po-qty-table td:nth-child(12) {
  width: 104px;
  text-align: center;
}

/* TomSelect - PO qty item name column */
.po-qty-table .ts-wrapper {
  width: 100%;
}
.po-qty-table .ts-control,
.po-qty-table .ts-control input,
.po-qty-table .ts-dropdown {
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}
.po-qty-table .ts-control {
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 6px;
  background: transparent;
  box-shadow: none;
  cursor: text;
}
.po-qty-table .ts-control:focus-within {
  border-color: #8ba9df;
  background: #ffffff;
  outline: 2px solid rgba(23, 67, 108, 0.14);
}
.po-qty-table .ts-control input {
  min-height: unset;
  border: 0;
  padding: 0;
  background: transparent;
}
.po-qty-table .ts-control .item {
  font-size: inherit;
  font-family: inherit;
  font-weight: 700;
  line-height: inherit;
}
.po-qty-table .ts-dropdown {
  z-index: 9999;
  border: 1px solid #bdd5df;
  border-radius: 6px;
}
.po-qty-table .ts-dropdown .option {
  padding: 4px 8px;
}
.po-qty-table .ts-dropdown .option:hover,
.po-qty-table .ts-dropdown .option.active {
  background: #eaf3f7;
  color: inherit;
}

.po-qty-control {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 6px;
  font: inherit;
}

.po-qty-control:focus {
  border-color: #8ba9df;
  background: #ffffff;
  outline: 2px solid rgba(23, 67, 108, 0.14);
}

.po-qty-number,
.po-qty-amount {
  text-align: right;
}

.po-qty-amount {
  color: #1f2937;
  font-weight: 700;
}

.po-qty-new-row {
  background: #f7fbfb;
}

.po-qty-add-button {
  min-height: 30px;
  padding: 4px 8px;
}

.po-qty-state {
  font-size: 11px;
  text-align: center;
}

.po-qty-actions {
  text-align: center;
  white-space: nowrap;
}

.po-qty-delete {
  min-width: 28px;
  min-height: 22px;
  padding: 1px 4px;
}

.po-qty-actions .po-qty-state {
  display: block;
}

.customer-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: start;
  padding: 8px 0 16px;
  border-bottom: 1px solid #bcc5d2;
  position: relative;
}

.item-master-screen {
  width: min(100%, 1180px);
  display: none;
  background: #ffffff;
}

.item-master-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(520px, 1.4fr);
  gap: 16px;
  padding: 18px;
}

.item-master-panel {
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 14px;
  background: #ffffff;
  overflow: hidden;
}

.item-master-panel h2 {
  margin: 0;
  padding: 12px 14px;
  background: #ecf5f5;
  color: #103f52;
  font-size: 16px;
}

.item-master-panel .grid-wrap {
  border: 0;
  border-radius: 0;
  max-height: 560px;
}

.item-catalogue-screen {
  width: min(100%, 1180px);
  display: none;
  background: #ffffff;
}

.inventory-menu-screen,
.sap-items-screen {
  width: min(100%, 1180px);
  display: none;
  background: #ffffff;
}

.supplier-po-screen {
  width: min(100%, 1180px);
  display: none;
  background: #ffffff;
}

.inventory-subtitle {
  margin: -12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.inventory-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
  gap: 12px;
  padding: 16px 0;
}

.inventory-card {
  min-height: 118px;
  display: grid;
  gap: 10px;
  align-content: center;
  padding: 20px;
  border: 1px solid #cfe0e7;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96), rgba(236,245,245,0.92)),
    radial-gradient(circle at top right, rgba(31,111,139,0.16), transparent 34%);
  color: #103f52;
  text-decoration: none;
  box-shadow: 0 18px 45px rgba(23, 67, 108, 0.10);
}

.inventory-card strong {
  font-size: 18px;
}

.inventory-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.inventory-card:hover {
  border-color: #8eb9c7;
  transform: translateY(-1px);
}

.inventory-low-stock-panel {
  margin-top: 8px;
  border: 1px solid #cfe0e7;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.inventory-low-stock-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.inventory-low-stock-heading h2 {
  margin: 0;
  color: #103f52;
  font-size: 16px;
}

#lowStockItemsStatus {
  color: var(--muted);
  font-size: 12px;
}

.inventory-low-stock-wrap {
  max-height: 280px;
}

.inventory-low-stock-wrap table {
  min-width: 920px;
}

.inventory-low-stock-wrap th,
.inventory-low-stock-wrap td {
  padding: 4px 6px;
  font-size: 12px;
}

.stock-status-ok {
  color: #116b3a;
  font-weight: 800;
}

.stock-status-low {
  color: #a05a00;
  font-weight: 800;
}

.stock-status-out {
  color: #b00020;
  font-weight: 800;
}

.inventory-search-fields {
  grid-template-columns: auto minmax(260px, 520px) auto auto auto;
}

.sap-items-grid-wrap {
  margin-top: 18px;
  max-height: 660px;
}

#sapItemsTable {
  table-layout: auto;
  min-width: 860px;
}

#sapItemsTable th,
#sapItemsTable td {
  padding: 2px 5px;
  font-size: 11px;
  line-height: 1.05;
  height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sapItemsTable th:first-child,
#sapItemsTable td:first-child {
  width: 30px;
  padding-inline: 3px;
  text-align: center;
}

#sapItemsTable th:nth-child(2),
#sapItemsTable td:nth-child(2) {
  width: 120px;
}

#sapItemsTable th:nth-child(3),
#sapItemsTable td:nth-child(3) {
  min-width: 280px;
}

#sapItemsTable th:nth-child(4),
#sapItemsTable td:nth-child(4) {
  width: 70px;
}

#sapItemsTable th:nth-child(5),
#sapItemsTable td:nth-child(5) {
  width: 70px;
}

#sapItemsTable th:nth-child(6),
#sapItemsTable td:nth-child(6) {
  width: 54px;
  text-align: center;
}

#sapItemsTable th:nth-child(7),
#sapItemsTable td:nth-child(7) {
  width: 74px;
}

#sapItemsTable th:nth-child(8),
#sapItemsTable td:nth-child(8) {
  width: 82px;
}

#sapItemsTable th:nth-child(9),
#sapItemsTable td:nth-child(9) {
  width: 96px;
  text-align: center;
}

#sapItemsTable th:nth-child(10),
#sapItemsTable td:nth-child(10) {
  width: 112px;
}

#sapItemsTable .sap-items-col-sap-no {
  width: 120px;
}

#sapItemsTable .sap-items-col-desc {
  min-width: 280px;
}

#sapItemsTable .sap-items-col-group {
  min-width: 120px;
}

#sapItemsTable .sap-items-col-type {
  min-width: 130px;
}

#sapItemsTable .sap-items-col-qty,
#sapItemsTable .sap-items-col-total {
  width: 82px;
  text-align: right;
}

.sap-report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#sap-items-report .customer-header {
  padding-right: 0;
}

#sap-items-report .customer-header > .utility-actions.customer-actions,
#sap-items-report .customer-header > .utility-actions:has(> .exit-button) {
  position: static;
  width: auto;
  min-width: 0;
  height: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 8px;
  overflow: visible;
}

#sap-items-report .customer-header .exit-button {
  position: relative;
  top: auto;
  right: auto;
}

#sap-items-report .customer-header > .utility-actions.customer-actions .sap-report-toolbar {
  flex-wrap: nowrap;
}

.sap-report-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sap-report-qty-filter {
  min-height: 34px;
  border: 1px solid #b9d8e1;
  border-radius: 6px;
  background: #ffffff;
  color: #103f52;
  font-weight: 700;
  padding: 6px 10px;
}

.sap-report-tabs .tab-button {
  min-height: 32px;
  padding: 6px 14px;
  border: 1px solid #b9d8e1;
  border-radius: 6px;
  background: #ffffff;
  color: #103f52;
  font-weight: 700;
}

.sap-report-tabs .tab-button.active {
  background: #dff4f7;
  border-color: #78b6c6;
}

.sap-items-report-grid-wrap {
  max-height: 680px;
}

.sap-report-matrix-area {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 14px;
  align-items: start;
}

.sap-report-matrix-area[hidden] {
  display: none;
}

#sapItemsReportTable {
  table-layout: auto;
  min-width: 860px;
}

#sapItemsReportTable th,
#sapItemsReportTable td {
  padding: 2px 5px;
  font-size: 11px;
  line-height: 1.05;
  height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sapItemsReportTable .sap-items-col-desc {
  min-width: 300px;
}

#sapItemsReportTable .sap-items-col-qty,
#sapItemsReportTable .sap-items-col-total {
  width: 82px;
  text-align: right;
}

.sap-items-report-filter-panel {
  width: min(560px, 96vw);
}

.sap-items-report-filter-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.sap-items-report-filter-grid input,
.sap-items-report-filter-grid select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #c6d7df;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
}

.sap-items-report-filter-grid .ts-wrapper {
  width: 100%;
}

.sap-items-report-filter-grid .ts-control {
  min-height: 34px;
  border-color: #c6d7df;
  border-radius: 6px;
  font-size: 13px;
}

.sap-item-input {
  width: 100%;
  min-width: 120px;
  border: 1px solid #d6dde8;
  border-radius: 6px;
  padding: 5px 7px;
  font: inherit;
  font-size: 12px;
}

.sap-item-record-layout {
  display: grid;
  grid-template-columns: minmax(0, 660px) minmax(360px, 460px);
  gap: 12px;
  align-items: start;
  justify-content: start;
}

.sap-item-detail-grid {
  min-width: 0;
}

.sap-item-stock-panel {
  margin-top: 22px;
  width: min(460px, 100%);
  box-sizing: border-box;
  border: 1px solid #d6dde8;
  border-radius: 8px;
  background: #f8fbfc;
  padding: 8px 10px 10px;
}

.sap-item-stock-panel h2 {
  margin: 0 0 12px;
  font-size: 14px;
  color: #103f52;
}

.sap-item-stock-summary {
  display: block;
  margin: 0;
  font-size: 12px;
}

#sap-item-detail .utility-actions.customer-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: auto;
}

#sap-item-detail .utility-actions.customer-actions .exit-button {
  position: relative;
  top: auto;
  right: auto;
}

#printSapItemQrStickerButton {
  min-width: 118px;
  white-space: nowrap;
}

.sap-item-sticker-panel {
  width: min(320px, 92vw);
}

.sap-item-sticker-form {
  display: grid;
  grid-template-columns: 94px 1fr;
  gap: 10px;
  align-items: center;
  margin: 12px 0 16px;
}

.sap-item-sticker-form label {
  color: #103f52;
  font-size: 13px;
  font-weight: 700;
}

.sap-item-stock-matrix-wrap {
  margin-top: 4px;
  overflow-x: hidden;
  border: 1px solid #d9e6ec;
  border-radius: 6px;
  background: #fff;
}

.sap-item-stock-matrix {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 11px;
}

.sap-item-stock-matrix th,
.sap-item-stock-matrix td {
  padding: 4px 3px;
  border-bottom: 1px solid #e4eef2;
  text-align: center;
  white-space: nowrap;
}

.sap-item-stock-matrix th {
  background: #eef7f8;
  color: #103f52;
  font-weight: 700;
}

.sap-item-stock-matrix th:nth-child(2),
.sap-item-stock-matrix td:nth-child(2) {
  width: 95px;
  text-align: left;
}

.sap-item-stock-matrix th:first-child,
.sap-item-stock-matrix td:first-child {
  width: 34px;
  padding-inline: 2px;
}

.sap-item-stock-matrix th:not(:first-child):not(:nth-child(2)),
.sap-item-stock-matrix td:not(:first-child):not(:nth-child(2)) {
  width: 50px;
}

.sap-item-stock-warehouse-head {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sap-item-stock-status-cell {
  font-weight: 700;
  color: #103f52;
}

.sap-item-stock-drill-cell .stock-history-button {
  min-width: 28px;
  width: 28px;
  height: 20px;
  padding: 0 3px;
  font-size: 10px;
}

.sap-item-stock-matrix tbody tr:last-child th,
.sap-item-stock-matrix tbody tr:last-child td {
  border-bottom: 0;
}

.sap-item-stock-matrix-total {
  font-weight: 800;
  color: #103f52;
}

.stock-history-button {
  min-width: 32px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid #9ec9d6;
  border-radius: 5px;
  background: #eaf6f9;
  color: #075c78;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.stock-history-button:hover,
.stock-history-button:focus-visible {
  background: #d6edf4;
  border-color: #61aabd;
}

.stock-history-modal {
  z-index: 9100;
  pointer-events: auto;
}

.stock-history-panel {
  width: min(980px, 96vw);
  z-index: 1;
}

.stock-history-wrap {
  max-height: min(58vh, 520px);
  overflow: auto;
  border: 1px solid #d9e6ec;
  border-radius: 6px;
}

.stock-history-wrap table {
  min-width: 820px;
}

.sap-item-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.sap-item-delete {
  border-color: #f1b5b5;
  background: #fff1f1;
  color: #9f1d1d;
}

.sap-item-open {
  min-width: 44px;
  padding-inline: 8px;
}

.sap-item-detail-grid {
  display: grid;
  grid-template-columns: 92px minmax(220px, 520px);
  gap: 10px 8px;
  padding: 22px 28px;
  align-items: center;
  max-width: 660px;
}

.sap-item-detail-grid label {
  color: #103f52;
  font-weight: 700;
  font-size: 13px;
}

.sap-item-detail-grid .sap-item-input {
  min-height: 34px;
}

#sap-item-detail.sap-item-detail-modal {
  position: fixed;
  inset: 34px 40px;
  z-index: 9000;
  display: block;
  width: auto;
  max-width: none;
  overflow: auto;
  border: 1px solid #b8d4df;
  box-shadow: 0 18px 45px rgba(15, 40, 55, 0.22);
}

.supplier-po-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 18px 0;
}

.supplier-detail-grid {
  display: grid;
  grid-template-columns: 110px minmax(180px, 1fr);
  gap: 8px 10px;
  padding: 14px;
  align-items: center;
}

.supplier-detail-grid label {
  color: #103f52;
  font-weight: 700;
  font-size: 12px;
}

.supplier-control {
  width: 100%;
  min-height: 30px;
  border: 1px solid #d6dde8;
  border-radius: 6px;
  padding: 4px 7px;
  font: inherit;
  font-size: 12px;
}

.supplier-po-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 12px;
  background: #ecf5f5;
}

.supplier-po-grid-wrap,
.supplier-po-items-wrap,
.supplier-maintenance-wrap,
.warehouse-maintenance-wrap {
  max-height: 560px;
}

.warehouse-maintenance-wrap table {
  min-width: 720px;
}

.warehouse-maintenance-wrap th:nth-child(1),
.warehouse-maintenance-wrap td:nth-child(1) {
  width: 180px;
}

.warehouse-maintenance-wrap th:nth-child(3),
.warehouse-maintenance-wrap td:nth-child(3) {
  width: 140px;
}

.warehouse-maintenance-wrap th:nth-child(4),
.warehouse-maintenance-wrap td:nth-child(4) {
  width: 70px;
  text-align: center;
}

.supplier-po-screen table th,
.supplier-po-screen table td {
  font-size: 12px;
  padding: 3px 6px;
}

.supplier-po-detail-screen {
  width: min(100%, 1120px);
  border: 0;
  background: #fff;
  color: #000;
  position: relative;
}

.detail-loading-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 50;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

.detail-loading-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #cfe4ea;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: packing-spin 0.8s linear infinite;
}

.supplier-po-detail-top {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 8px 10px 10px;
  background: #faf7f7;
}

.supplier-po-window-title {
  font-size: 12px;
  padding-top: 2px;
}

.supplier-po-detail-title {
  margin: 2px 0 8px;
  text-align: center;
  color: #000;
  font-size: 26px;
  font-weight: 400;
}

.supplier-po-update-meta {
  display: grid;
  grid-template-columns: auto 132px 186px;
  justify-content: center;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  color: #6b7280;
}

.supplier-po-update-meta input,
.supplier-po-form-layout input,
.supplier-po-form-layout select,
.supplier-po-form-layout textarea,
.supplier-po-totals-row input {
  min-height: 24px;
  border: 1px solid #aeb4bc;
  border-radius: 0;
  padding: 2px 4px;
  background: #fff;
  color: #000;
  font-size: 13px;
}

.supplier-po-detail-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.supplier-po-detail-actions .small-button,
.supplier-po-items-actions .small-button {
  min-width: 68px;
  min-height: 32px;
}

.supplier-po-detail-actions .icon-only {
  min-width: 40px;
}

.supplier-po-detail-body {
  padding: 8px 10px 0;
}

.supplier-po-form-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) minmax(210px, 0.75fr) minmax(300px, 1fr);
  gap: 8px;
  align-items: start;
}

.supplier-po-left-fields,
.supplier-po-mid-fields {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 4px 0;
  align-items: center;
}

.supplier-po-mid-fields {
  grid-template-columns: 72px 1fr;
}

.supplier-po-left-fields label,
.supplier-po-mid-fields label,
.supplier-po-remarks label {
  font-size: 13px;
  font-weight: 400;
}

.supplier-po-left-fields > div,
.supplier-po-mid-fields > div,
.supplier-po-remarks > div {
  min-width: 0;
}

.supplier-po-left-fields .supplier-control,
.supplier-po-mid-fields .supplier-control,
.supplier-po-remarks .supplier-control {
  width: 100%;
  min-height: 24px;
  border-radius: 0;
}

#supplierPoSubject .supplier-control,
#supplierPoRemarks .supplier-control {
  min-height: 48px;
}

.supplier-po-remarks {
  display: grid;
  grid-template-rows: auto 112px;
  gap: 4px;
}

.supplier-po-remarks .supplier-control {
  height: 112px;
}

.supplier-po-remarks-input {
  cursor: text;
  caret-color: #000;
}

.supplier-po-items-panel {
  position: relative;
  margin-top: 4px;
  border-top: 1px solid #c6cbd2;
  min-height: 490px;
}

.supplier-po-items-title {
  padding: 2px 0 4px;
  text-align: center;
  font-size: 16px;
}

.supplier-po-items-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 4px;
}

/* BOM tab bar: tabs on the left, Import Excel on the right, all on one row
   and uniformly sized. */
.bom-tab-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bom-tab-bar .tab-button {
  min-width: 110px;
  min-height: 32px;
  padding: 6px 14px;
  text-align: center;
}
.bom-tab-bar .bom-import-btn {
  margin-left: auto;
}

/* User & Staff Maintenance */
.staff-panel { width: min(900px, 94vw); }
.staff-edit-panel { width: min(680px, 94vw); }
.po-report-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.staff-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.staff-toolbar input[type="search"] { flex: 1; min-width: 0; }
.staff-list-wrap { max-height: 60vh; overflow: auto; }
.staff-tab-bar { display: flex; gap: 6px; margin-bottom: 10px; }
.staff-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.staff-form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: #34506a;
  gap: 4px;
}
.staff-form-grid input,
.staff-form-grid select {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid #c3d0db;
  border-radius: 6px;
}
.staff-edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.staff-edit-actions .import-status { margin-right: auto; }
@media (max-width: 560px) {
  .staff-form-grid { grid-template-columns: 1fr; }
}

.purchase-order-items-wrap {
  max-height: 430px;
  border: 0;
  overflow: auto;
}

.supplier-po-items-table {
  min-width: 1050px;
  table-layout: fixed;
}

.goods-received-items-table {
  min-width: 0;
}

.warehouse-transfer-items-table {
  min-width: 860px;
  width: 100%;
  table-layout: fixed;
}

.warehouse-transfer-items-table th:nth-child(1),
.warehouse-transfer-items-table td:nth-child(1) {
  width: 44px;
  text-align: center;
}

.warehouse-transfer-items-table th:nth-child(2),
.warehouse-transfer-items-table td:nth-child(2) {
  width: 44px;
  text-align: center;
}

.warehouse-transfer-items-table th:nth-child(3),
.warehouse-transfer-items-table td:nth-child(3) {
  width: 210px;
  min-width: 210px;
}

.warehouse-transfer-items-table th:nth-child(4),
.warehouse-transfer-items-table td:nth-child(4) {
  width: auto;
}

.warehouse-transfer-items-table th:nth-child(5),
.warehouse-transfer-items-table td:nth-child(5),
.warehouse-transfer-items-table th:nth-child(7),
.warehouse-transfer-items-table td:nth-child(7) {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  text-align: center;
}

.warehouse-transfer-items-table th:nth-child(8),
.warehouse-transfer-items-table td:nth-child(8) {
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  text-align: center;
}

.warehouse-transfer-items-table th:nth-child(6),
.warehouse-transfer-items-table td:nth-child(6) {
  width: 120px;
  text-align: center;
}

.warehouse-transfer-items-table .warehouse-transfer-readonly-qty,
.warehouse-transfer-items-table .warehouse-transfer-readonly-qty input {
  background: #eceff2;
  color: #26323a;
  text-align: center;
}

.warehouse-transfer-items-table .warehouse-transfer-readonly-qty input {
  width: 100%;
  border: 0;
  cursor: default;
  pointer-events: none;
}

/* Inventory Adjustment items grid - fixed layout so the Item No column stays
   compact and Item Description flexes (mirrors the Warehouse Transfer grid).
   Columns: RowNo, Go, Item No, Item Description, Available, Actual Count,
   Difference, Delete. */
.inventory-adjustment-items-table {
  min-width: 900px;
  width: 100%;
  table-layout: fixed;
}

.inventory-adjustment-items-table th:nth-child(1),
.inventory-adjustment-items-table td:nth-child(1),
.inventory-adjustment-items-table th:nth-child(2),
.inventory-adjustment-items-table td:nth-child(2) {
  width: 44px;
  text-align: center;
}

.inventory-adjustment-items-table th:nth-child(3),
.inventory-adjustment-items-table td:nth-child(3) {
  width: 190px;
  min-width: 190px;
  max-width: 190px;
}

.inventory-adjustment-items-table th:nth-child(4),
.inventory-adjustment-items-table td:nth-child(4) {
  width: auto;
}

.inventory-adjustment-items-table th:nth-child(5),
.inventory-adjustment-items-table td:nth-child(5),
.inventory-adjustment-items-table th:nth-child(7),
.inventory-adjustment-items-table td:nth-child(7) {
  width: 96px;
  min-width: 96px;
  max-width: 96px;
  text-align: center;
}

.inventory-adjustment-items-table th:nth-child(6),
.inventory-adjustment-items-table td:nth-child(6) {
  width: 112px;
  min-width: 112px;
  max-width: 112px;
  text-align: center;
}

.inventory-adjustment-items-table th:nth-child(8),
.inventory-adjustment-items-table td:nth-child(8) {
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  text-align: center;
}

.inventory-adjustment-items-table td input {
  width: 100%;
  box-sizing: border-box;
}

/* Center the qty boxes (Available / Actual Count / Difference) in their cells,
   with a little side padding so they don't touch the column borders. */
.inventory-adjustment-items-table td:nth-child(5),
.inventory-adjustment-items-table td:nth-child(6),
.inventory-adjustment-items-table td:nth-child(7) {
  vertical-align: middle;
  padding-left: 6px;
  padding-right: 6px;
}

.inventory-adjustment-items-table td:nth-child(5) input,
.inventory-adjustment-items-table td:nth-child(6) input,
.inventory-adjustment-items-table td:nth-child(7) input {
  text-align: center;
  margin: 0 auto;
  display: block;
}

.warehouse-transfer-items-table .warehouse-transfer-qty-input {
  background: #fff;
  text-align: center;
}

.warehouse-transfer-items-table tfoot input {
  text-align: center;
}

.goods-received-form-layout {
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 1fr);
}

.goods-received-po-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px;
}

.goods-received-po-control .small-button {
  min-height: 24px;
  padding: 2px 8px;
}

.goods-received-po-panel {
  width: min(760px, 96vw);
}

.goods-received-po-list-wrap {
  max-height: 430px;
  margin-top: 8px;
}

.goods-received-po-list-wrap table {
  min-width: 660px;
}

.goods-received-label-panel {
  width: min(1120px, 96vw);
}

.goods-received-label-wrap {
  max-height: 62vh;
  margin-top: 8px;
}

.goods-received-label-table {
  min-width: 980px;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.goods-received-label-table th,
.goods-received-label-table td {
  border-bottom: 1px solid #d6dde3;
  padding: 4px 6px;
  text-align: left;
  vertical-align: middle;
}

.goods-received-label-table th {
  background: #eef3f7;
  color: #001b2e;
  font-weight: 700;
}

.goods-received-label-table th:nth-child(1),
.goods-received-label-table td:nth-child(1) {
  width: 54px;
  text-align: center;
}

.goods-received-label-table th:nth-child(2),
.goods-received-label-table td:nth-child(2) {
  width: 150px;
}

.goods-received-label-table th:nth-child(4),
.goods-received-label-table td:nth-child(4),
.goods-received-label-table th:nth-child(5),
.goods-received-label-table td:nth-child(5),
.goods-received-label-table th:nth-child(6),
.goods-received-label-table td:nth-child(6),
.goods-received-label-table th:nth-child(7),
.goods-received-label-table td:nth-child(7) {
  width: 92px;
}

.goods-received-label-table th:nth-child(8),
.goods-received-label-table td:nth-child(8) {
  width: 170px;
}

.goods-received-label-qty {
  width: 72px;
}

.goods-received-label-preview {
  width: 150px;
  height: 75px;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid #c5cdd4;
  background: #fff;
  color: #000;
  overflow: hidden;
}

.goods-received-label-preview img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.goods-received-label-preview strong,
.goods-received-label-preview span {
  display: block;
  overflow: hidden;
}

.goods-received-label-preview strong {
  font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
  font-size: 9px;
  line-height: 1;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 28px;
}

.goods-received-label-preview span {
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carton-tag-panel {
  width: min(1040px, 96vw);
}

.carton-tag-wrap {
  max-height: 62vh;
  margin-top: 8px;
}

.po-report-panel {
  width: min(1320px, 96vw);
}

.po-report-wrap {
  max-height: 60vh;
  margin-top: 8px;
}

.po-report-table {
  min-width: 1100px;
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.po-report-table th,
.po-report-table td {
  border-bottom: 1px solid #d6dde3;
  padding: 4px 6px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.po-report-table th {
  background: #eef3f7;
  color: #001b2e;
  font-weight: 700;
}

/* PRN */
.po-report-table th:nth-child(1),
.po-report-table td:nth-child(1) {
  width: 84px;
}

/* Full Name gets the remaining space */
.po-report-table th:nth-child(2),
.po-report-table td:nth-child(2) {
  min-width: 200px;
  white-space: normal;
}

/* Gender */
.po-report-table th:nth-child(4),
.po-report-table td:nth-child(4) {
  width: 64px;
}

/* Qty */
.po-report-table th:nth-child(10),
.po-report-table td:nth-child(10) {
  width: 40px;
  text-align: center;
}

.po-report-toolbar select {
  max-width: 140px;
}

.po-report-po-no {
  font-size: 0.7em;
  font-weight: 600;
  color: #345;
}

.po-shipping-confirm-panel {
  max-width: 460px;
  width: 100%;
}

.po-shipping-confirm-body {
  margin: 8px 0 14px;
  font-size: 13.5px;
}

.po-shipping-confirm-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px;
  border-bottom: 1px solid #e6ebf1;
}

.po-shipping-confirm-label {
  color: #34495e;
  font-weight: 600;
}

.po-shipping-confirm-value {
  color: #1f3a5f;
  text-align: right;
}

#poShippingModal .po-shipping-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#poShippingModal .po-shipping-header h2 {
  margin: 0;
}

#poShippingModal .po-shipping-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#poShippingModal #closePoShipping {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  margin: 0 0 0 4px;
  align-self: center;
}

#poShippingModal .po-report-toolbar {
  align-items: center;
  gap: 8px;
}

#poShippingModal .po-report-toolbar label {
  font-size: 13px;
  font-weight: 600;
  color: #34495e;
  white-space: nowrap;
}

#poShippingModal #poShippingFromWarehouse {
  font-size: 13px;
  font-weight: 600;
  color: #1f6feb;
  white-space: nowrap;
}

#poShippingModal .po-report-toolbar input[type="search"],
#poShippingModal .po-report-toolbar select {
  font-size: 13px;
  height: 30px;
}

.po-report-mode-hint {
  font-size: 12px;
  color: #6a7785;
  font-style: italic;
}

.po-report-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 8px;
  padding: 6px 10px;
  background: #eef4f8;
  border: 1px solid #cdd9e2;
  border-radius: 8px;
  font-size: 13px;
}

.carton-tag-table {
  min-width: 900px;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.carton-tag-table th,
.carton-tag-table td {
  border-bottom: 1px solid #d6dde3;
  padding: 4px 6px;
  text-align: left;
  vertical-align: middle;
}

.carton-tag-table th {
  background: #eef3f7;
  color: #001b2e;
  font-weight: 700;
}

.carton-tag-table th:nth-child(1),
.carton-tag-table td:nth-child(1) {
  width: 54px;
  text-align: center;
}

.carton-tag-table th:nth-child(2),
.carton-tag-table td:nth-child(2),
.carton-tag-table th:nth-child(4),
.carton-tag-table td:nth-child(4) {
  width: 130px;
}

.carton-tag-table th:nth-child(5),
.carton-tag-table td:nth-child(5),
.carton-tag-table th:nth-child(6),
.carton-tag-table td:nth-child(6) {
  width: 150px;
}

.supplier-po-items-table th {
  background: #fff;
  color: #000;
  font-weight: 400;
  border: 0;
  border-bottom: 1px solid #cfd5db;
}

.supplier-po-items-table td {
  height: 25px;
  padding: 1px 4px;
  border: 1px solid #b8bdc5;
  background: #f9f9f9;
}

.supplier-po-items-table .supplier-control {
  min-height: 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.supplier-po-items-table .supplier-po-sap-input.invalid {
  background: #fff4f4;
  color: #b42318;
  outline: 1px solid #f04438;
}

.supplier-po-sap-desc {
  min-width: 300px;
}

.supplier-po-items-table .supplier-po-col-row {
  width: 42px;
  max-width: 42px;
  text-align: center;
}

.supplier-po-items-table .supplier-po-col-go {
  width: 34px;
  max-width: 34px;
  padding-inline: 2px;
  text-align: center;
}

.supplier-po-items-table .supplier-po-col-sap-no {
  width: 170px;
  min-width: 170px;
}

.supplier-po-items-table .supplier-po-col-sap-desc,
.supplier-po-items-table .supplier-po-sap-desc {
  width: 300px;
  min-width: 300px;
  white-space: normal;
}

.supplier-po-items-table .supplier-po-col-id {
  width: 46px;
  max-width: 46px;
}

.supplier-po-items-table .supplier-po-col-qty,
.supplier-po-items-table .supplier-po-col-received,
.supplier-po-items-table .supplier-po-col-total {
  width: 66px;
  max-width: 66px;
}

.supplier-po-items-table .supplier-po-col-date {
  width: 116px;
  max-width: 116px;
}

.supplier-po-items-table .supplier-po-col-track {
  width: 130px;
  max-width: 130px;
}

.supplier-po-items-table .supplier-po-col-id,
.supplier-po-items-table .supplier-po-col-qty,
.supplier-po-items-table .supplier-po-col-received,
.supplier-po-items-table .supplier-po-col-total {
  text-align: center;
}

.supplier-po-items-table .supplier-po-col-sap-no .supplier-control {
  min-width: 162px;
  overflow: visible;
  text-overflow: clip;
}

.supplier-po-items-table .supplier-po-col-date .supplier-control {
  min-width: 108px;
}

/* TomSelect - goods received item number column */
.supplier-po-col-sap-no .ts-wrapper {
  width: 100%;
}
.supplier-po-col-sap-no .ts-control,
.supplier-po-col-sap-no .ts-control input,
.supplier-po-col-sap-no .ts-dropdown {
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}
.supplier-po-col-sap-no .ts-control {
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 6px;
  background: transparent;
  box-shadow: none;
  cursor: text;
}
.supplier-po-col-sap-no .ts-control:focus-within {
  border-color: #8ba9df;
  background: #ffffff;
}
.supplier-po-col-sap-no .ts-control input {
  min-height: unset;
  border: 0;
  padding: 0;
  background: transparent;
}
.supplier-po-col-sap-no .ts-control .item {
  font-size: inherit;
  font-family: inherit;
  font-weight: 700;
  line-height: inherit;
}
.supplier-po-col-sap-no .ts-dropdown {
  z-index: 9999;
  border: 1px solid #bdd5df;
  border-radius: 6px;
  min-width: 320px;
}
.supplier-po-col-sap-no .ts-dropdown .option {
  padding: 4px 8px;
}
.supplier-po-col-sap-no .ts-dropdown .option:hover,
.supplier-po-col-sap-no .ts-dropdown .option.active {
  background: #eaf3f7;
  color: inherit;
}

.supplier-po-delete-cell {
  width: 34px;
  max-width: 34px;
  padding-inline: 2px;
  text-align: center;
}

.supplier-po-go-button,
.supplier-po-delete-row {
  min-width: 28px;
  min-height: 22px;
  padding: 1px 4px;
}

.supplier-po-go-button {
  border: 1px solid #155f7a;
  border-radius: 6px;
  background: #1f6f8b;
  color: #ffffff;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.supplier-po-go-button:hover {
  background: #185a72;
}

.supplier-po-items-table tfoot td {
  background: #fff;
}

.supplier-po-total-label {
  text-align: right;
  font-weight: 700;
}

.supplier-po-items-table tfoot input {
  width: 100%;
  min-width: 0;
  height: 24px;
  box-sizing: border-box;
  border: 1px solid #d6dde8;
  border-radius: 6px;
  padding: 2px 5px;
  text-align: center;
  font: inherit;
}

.supplier-po-sr,
.supplier-po-number-cell {
  text-align: center;
}

.receive-button {
  min-height: 22px;
  padding: 1px 6px;
}

.supplier-receive-dialog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.35);
}

.supplier-receive-card {
  width: min(360px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 16px;
  border: 1px solid #b8d4df;
  border-radius: 8px;
  background: #fff;
}

.supplier-receive-card h2,
.supplier-receive-actions {
  grid-column: 1 / -1;
}

.supplier-receive-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.supplier-receive-card input {
  min-height: 30px;
  border: 1px solid #aeb4bc;
  padding: 3px 6px;
}

.supplier-receive-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.supplier-po-totals-row {
  position: absolute;
  left: 464px;
  right: 250px;
  bottom: 16px;
  display: grid;
  grid-template-columns: auto 54px 1fr 62px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.supplier-po-totals-row input:last-child {
  grid-column: 4;
}

.catalogue-layout {
  grid-template-columns: minmax(300px, 0.8fr) minmax(520px, 1.4fr);
}

.catalogue-sidebar {
  min-height: 560px;
}

.catalogue-style-list {
  max-height: 560px;
  overflow-y: auto;
}

.catalogue-style-button {
  width: 100%;
  min-height: 36px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 0;
  border-bottom: 1px solid #dbe7ed;
  padding: 4px 12px;
  background: #fff;
  color: #17242d;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.catalogue-style-button.active {
  font-weight: 800;
  background: #f2f9fa;
  box-shadow: inset 3px 0 0 #1f6f8b;
}

.catalogue-style-button::after {
  content: "\203a";
  color: #a8a8a8;
  font-size: 24px;
  font-weight: 300;
}

.catalogue-main {
  min-width: 0;
}

.catalogue-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: #eef7f7;
  border-bottom: 1px solid #dbe7ed;
}

.catalogue-panel-header h2 {
  margin: 0;
}

.catalogue-style-info {
  display: grid;
  grid-template-columns: 64px minmax(220px, 1fr);
  gap: 6px 12px;
  margin: 10px 14px 8px;
  font-size: 14px;
}

.catalogue-style-info label {
  font-size: 14px;
}

.catalogue-style-info input,
.catalogue-style-info textarea {
  width: min(100%, 680px);
  padding: 6px 10px;
  border: 1px solid #9fb9c4;
  border-radius: 6px;
  font: inherit;
  line-height: 1.35;
}

.catalogue-style-info textarea {
  min-height: 90px;
  resize: vertical;
}

.catalogue-save-status {
  min-height: 18px;
  color: #1f6f4a;
  font-size: 13px;
  font-weight: 700;
}

.catalogue-save-status.error {
  color: #c80020;
}

.catalogue-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin: 0;
}

.catalogue-picker {
  position: relative;
}

.catalogue-picker-button {
  min-width: 128px;
  text-align: left;
  padding-inline: 10px 28px;
}

.catalogue-picker-button::after {
  content: "\25be";
  position: absolute;
  right: 10px;
}

.catalogue-picker-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  width: 280px;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #b9d2dc;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(16, 36, 58, 0.16);
}

.catalogue-picker-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 6px;
  border-radius: 4px;
  font-size: 13px;
}

.catalogue-picker-option:hover {
  background: #eef7f7;
}

.catalogue-picker-option input {
  margin-top: 2px;
}

.catalogue-picker-option strong,
.catalogue-picker-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalogue-picker-empty {
  padding: 8px;
  color: #687790;
  font-size: 13px;
}

.catalogue-item-form {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 12px;
  margin: 16px 40px;
  padding: 16px 20px;
  background: #f6f9fc;
  border: 1px solid #d6e0eb;
  border-radius: 10px;
  align-items: center;
}

.catalogue-item-form label {
  font-size: 13px;
  font-weight: 600;
  color: #1f3a5f;
  text-align: right;
}

.catalogue-item-form input,
.catalogue-item-form textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #bac8d9;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.catalogue-item-form input:focus,
.catalogue-item-form textarea:focus {
  border-color: #6b8fc7;
  box-shadow: 0 0 0 2px rgba(23, 67, 108, 0.1);
}

.catalogue-item-form textarea {
  min-height: 64px;
  resize: vertical;
}

.catalogue-form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 6px;
}

.catalogue-grid {
  min-height: 300px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start;
  gap: 14px;
  margin: 0;
  padding: 10px 18px 18px;
  border: 0;
  border-top: 1px solid #dbe7ed;
  overflow: auto;
}

.catalogue-grid > div {
  padding: 0;
  color: #10243a;
  font-size: 16px;
}

.catalogue-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  position: relative;
}

.catalogue-card-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #d0d5dd;
  border-radius: 50%;
  background: #fff;
  color: #b42318;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.catalogue-card-remove:hover {
  background: #fef3f2;
  border-color: #b42318;
}

.catalogue-card img {
  width: 128px;
  height: 150px;
  object-fit: contain;
  background: #fafafa;
}

.catalogue-card-placeholder {
  width: 128px;
  height: 150px;
  display: grid;
  place-items: center;
  background: #f4f7f8;
  color: #687790;
  font-size: 13px;
}

.catalogue-photo-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.catalogue-photo-strip img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border: 1px solid #d1e2ea;
}

.catalogue-card-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.catalogue-card h3 {
  margin: 0;
  color: #10243a;
  font-size: 14px;
}

.catalogue-card p {
  margin: 0;
  color: #27394b;
  white-space: pre-line;
}

.catalogue-all-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.catalogue-all-list {
  max-height: 650px;
  overflow-y: auto;
  border: 1px solid #c8d4e1;
  background: #fff;
}

.catalogue-all-row {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid #dbe7ed;
  background: #fff;
  color: #17242d;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.catalogue-all-row.active {
  background: #f0f8fb;
  box-shadow: inset 3px 0 0 #1f6f8b;
}

.catalogue-all-row img,
.catalogue-all-row span {
  width: 54px;
  height: 54px;
  margin-left: 8px;
  object-fit: contain;
  background: #f7fbfc;
}

.catalogue-all-row small {
  padding-right: 12px;
  color: #5e7182;
}

.catalogue-all-detail {
  min-height: 600px;
  padding: 18px;
  border: 1px solid #c8d4e1;
  background: #fff;
}

.catalogue-all-detail-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 280px);
  gap: 16px 32px;
  margin-bottom: 18px;
}

.catalogue-all-detail-head div {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  align-items: start;
}

.catalogue-all-detail-head p {
  margin: 0;
  white-space: pre-line;
}

.catalogue-all-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.catalogue-all-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-start;
}

.catalogue-photo-item {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.catalogue-photo-item img {
  width: 260px;
  height: 330px;
  object-fit: contain;
  background: #fafafa;
}

.catalogue-photo-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #ffffff;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  justify-items: center;
  padding: 20px;
}

.catalogue-photo-zoom-toolbar {
  display: flex;
  gap: 8px;
  justify-self: center;
  margin-bottom: 8px;
}

.catalogue-photo-zoom-btn,
.catalogue-photo-zoom-close {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid #bfd6e3;
  background: #ffffff;
  color: #072b3a;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}

.catalogue-photo-zoom-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10002;
}

.catalogue-photo-zoom-stage {
  width: min(96vw, 1400px);
  height: calc(100vh - 84px);
  display: grid;
  place-items: center;
  overflow: auto;
}

.catalogue-photo-zoom-image {
  max-width: 96vw;
  max-height: calc(100vh - 120px);
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
}

.catalogue-photo-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

@media (max-width: 430px) {
  .topbar {
    padding: 10px 16px;
  }

  .brand-text {
    font-size: 15px;
  }

  .brand-mark {
    width: 56px;
    font-size: 22px;
    padding-left: 10px;
  }

  .current-user-summary {
    width: 100%;
    flex-wrap: wrap;
    order: 3;
  }

  .current-user-summary div {
    flex: 1 1 100px;
    min-width: 0;
  }

  .dashboard {
    max-width: 230px;
    grid-template-columns: 1fr;
  }

  .screen-header,
  .search-fields {
    display: block;
  }

  .search-fields label,
  .search-fields input {
    width: 100%;
    display: block;
    margin-bottom: 8px;
  }

  .utility-actions {
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
  }

  .profile-top,
  .profile-form,
  .two-col-fields,
  .name-badge-row,
  .delivery-form {
    display: block;
  }

  .profile-actions {
    grid-template-columns: 1fr 1fr;
  }

  .customer-info-top,
  .customer-fields,
  .customer-code-row,
  .po-info-top,
  .po-layout,
  .amount-row,
  .item-qty-grid,
  .delivery-data-top,
  .delivery-data-layout,
  .delivery-right-top,
  .sap-row,
  .uniform-set-grid,
  .upload-top,
  .upload-grid,
  .item-order-body,
  .item-order-header,
  .item-order-fields,
  .item-remarks,
  .order-item-top,
  .maintenance-grid,
  .maintenance-details,
  .maintenance-buttons,
  .standard-size-grid,
  .barcode-row,
  .standard-size-buttons,
  .measurement-layout,
  .measurement-detail-grid,
  .measurement-heading {
    display: block;
  }
}

/* Modern responsive layer */
body {
  background:
    radial-gradient(circle at top left, rgba(31, 111, 139, 0.18), transparent 34rem),
    linear-gradient(135deg, #f7faf8 0%, #eef6f7 46%, #f4f0e8 100%);
  color: #16222a;
}

.topbar {
  min-height: 76px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  border-top: 0;
  border-bottom: 1px solid rgba(31, 111, 139, 0.16);
  box-shadow: 0 12px 36px rgba(22, 34, 42, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand-text {
  color: #103f52;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 16px;
  padding: 0;
  background: #103f52;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(16, 63, 82, 0.22);
  font-size: 22px;
}

main {
  align-items: flex-start;
  background: transparent;
  padding: 28px clamp(12px, 3vw, 32px);
}

.dashboard,
.screen,
.profile-screen,
.customer-info-screen,
.po-info-screen,
.po-delivery-screen,
.beneficiary-upload-screen,
.item-order-screen,
.order-item-screen {
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 70px rgba(22, 34, 42, 0.12);
  overflow: hidden;
}

.item-master-screen {
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 70px rgba(22, 34, 42, 0.12);
  overflow: hidden;
}

.dashboard {
  width: min(100%, 760px);
  padding: 30px;
  gap: 22px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-title,
.screen-title,
.profile-title,
.customer-info-title,
.po-title,
.item-order-title,
.order-item-title,
.standard-size-form-title,
.upload-title {
  color: #103f52;
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

.section-title {
  text-align: left;
  font-size: 18px;
  margin-bottom: 14px;
}

.action-button,
.small-button,
.edit-button {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(31, 111, 139, 0.18);
  background: #e8f3f4;
  color: #103f52;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.action-button {
  min-height: 52px;
  justify-content: flex-start;
  padding-inline: 18px;
  background: #ffffff;
  border-color: rgba(31, 111, 139, 0.16);
  box-shadow: 0 8px 20px rgba(22, 34, 42, 0.06);
  font-size: 14px;
}

.action-button:hover,
.small-button:hover,
.edit-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(16, 63, 82, 0.16);
  background: #d7ecee;
}

input,
select,
textarea {
  min-height: 34px;
  border: 1px solid rgba(31, 111, 139, 0.2);
  border-radius: 9px;
  background: #ffffff;
  color: #17242d;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #1f6f8b;
  outline: 3px solid rgba(31, 111, 139, 0.16);
}

.screen,
.customer-info-screen,
.po-info-screen,
.po-delivery-screen,
.profile-screen,
.item-order-screen {
  width: min(100%, 1180px);
}

.screen-header,
.customer-header,
.profile-top,
.customer-info-top,
.po-info-top,
.delivery-data-top,
.upload-top,
.order-item-top {
  background: linear-gradient(135deg, #ffffff 0%, #eef7f7 100%);
  border-top: 0;
  border-bottom: 1px solid rgba(31, 111, 139, 0.12);
  padding: 18px;
}

.grid-wrap,
.beneficiary-delivery-grid,
.po-grid,
.entitled-grid {
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 12px;
  border-top: 1px solid rgba(31, 111, 139, 0.14);
  background: #ffffff;
}

table {
  font-size: 13px;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background: #ecf5f5;
  color: #25424e;
  font-weight: 700;
  border-color: #d8e7e8;
}

td {
  color: #16283f;
  border-color: #e5ecee;
}

tbody tr:nth-child(even) {
  background: #f8fbfb;
}

tbody tr:hover {
  background: #edf8f8;
}

.open-cell,
.po-icon-cell,
.yellow-cell,
.edit-cell {
  border-radius: 3px;
}

.profile-body,
.customer-info-body,
.po-body,
.delivery-data-body,
.upload-body {
  padding: 20px;
}

.tab-panel,
.po-panel,
.item-qty-panel,
.uniform-panel,
.entitled-panel {
  border-color: rgba(31, 111, 139, 0.14);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(22, 34, 42, 0.05);
}

.tab {
  border-color: rgba(31, 111, 139, 0.14);
  border-radius: 999px;
  background: #edf4f4;
  font-weight: 700;
  margin-right: 6px;
}

.tab.active {
  background: #103f52;
  color: #ffffff;
}

.status-box {
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 14px;
  background: #f2faf9;
}

.screen-title,
.profile-title,
.customer-info-title,
.po-title,
.item-order-title,
.upload-title {
  font-size: clamp(20px, 2.3vw, 28px);
  font-weight: 800;
}

.profile-id {
  color: #b42318;
  font-weight: 800;
}

.open-cell {
  background: transparent;
  color: #1f6f8b;
}

.edit-cell:has(.delivery-open-button),
.edit-cell:has(.workshop-open-button) {
  background: transparent;
}

.open-cell a,
.supplier-po-go-button,
.delivery-open-button,
.workshop-open-button {
  min-width: 32px;
  height: 26px;
  padding: 2px 8px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #155f7a;
  border-radius: 6px;
  background: #1f6f8b;
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
}

/* Bigger, finger-friendly drill (>>) buttons on tablets and touch devices. */
@media (max-width: 1024px), (pointer: coarse) {
  .open-cell a,
  .supplier-po-go-button,
  .delivery-open-button,
  .workshop-open-button {
    min-width: 44px;
    height: 36px;
    padding: 6px 14px;
    font-size: 15px;
    border-radius: 8px;
  }
}

.open-cell a:hover,
.open-cell a:focus,
.supplier-po-go-button:hover,
.supplier-po-go-button:focus,
.delivery-open-button:hover,
.delivery-open-button:focus,
.workshop-open-button:hover,
.workshop-open-button:focus {
  background: #185a72;
  outline: 1px solid #bdd5df;
}

.po-icon-cell,
.edit-cell {
  background: #e0f0f1;
  color: #103f52;
}

.edit-cell:has(.delivery-open-button),
.edit-cell:has(.workshop-open-button) {
  background: transparent;
}

.yellow-cell {
  background: transparent;
}

.measurement-print-screen,
.receiving-print-screen {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

@media (max-width: 1000px) {
  main {
    padding: 18px 10px;
  }

  .customer-info-top,
  .po-info-top,
  .delivery-data-top,
  .profile-top,
  .item-order-body,
  .order-item-top,
  .sap-item-record-layout {
    grid-template-columns: 1fr;
  }

  .customer-fields,
  .po-layout,
  .delivery-data-layout,
  .delivery-left-top,
  .profile-form,
  .measurement-layout,
  .item-master-layout,
  .inventory-action-grid,
  .item-order-header,
  .measurement-detail-grid,
  .delivery-right-top {
    grid-template-columns: 1fr;
  }

  .profile-meta,
  .customer-code-row,
  .amount-row,
  .sap-row,
  .name-badge-row {
    grid-template-columns: 1fr 1fr;
  }

  .delivery-actions,
  .profile-actions,
  .po-actions,
  .customer-info-actions,
  .item-side-actions,
  .order-item-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .grid-wrap,
  .po-grid,
  .beneficiary-delivery-grid,
  .entitled-grid {
    max-width: 100%;
    overflow-x: auto;
  }

  .sap-item-stock-panel {
    width: 100%;
    max-width: 460px;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 62px;
  }

  .brand-text {
    font-size: 14px;
  }

  .current-user-summary {
    flex: 1 1 100%;
    justify-content: stretch;
  }

  .dashboard {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .screen-header,
  .customer-header,
  .search-fields,
  .search-fields.left,
  .inventory-search-fields,
  .sap-item-detail-grid,
  .field-grid,
  .field-grid.compact,
  .two-col-fields,
  .badge-name-row,
  .profile-meta,
  .customer-field-grid,
  .po-fields,
  .delivery-form,
  .upload-grid,
  .item-qty-grid,
  .uniform-set-grid,
  .maintenance-grid,
  .maintenance-details,
  .standard-size-grid,
  .barcode-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .screen-title,
  .screen-title.left,
  .profile-title,
  .customer-info-title,
  .po-title {
    text-align: left;
  }

  .action-button,
  .small-button {
    width: 100%;
  }

  .tabs,
  .uniform-tabs {
    overflow-x: auto;
    align-items: stretch;
  }

.tab {
    white-space: nowrap;
  }
}

/* Keep every exit control in the same top-right location on desktop and mobile. */
.screen-header,
.customer-header,
.profile-top,
.customer-info-top,
.po-info-top,
.delivery-data-top,
.upload-top,
.workshop-detail-header,
.item-order-body,
.order-item-top,
.history-header,
.print-actions,
.scanner-panel {
  position: relative;
}

.screen-header > .utility-actions:has(> .exit-button),
.customer-header > .utility-actions:has(> .exit-button) {
  position: static;
  width: 0;
  min-width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
}

.screen-header,
.customer-header,
.profile-top,
.customer-info-top,
.po-info-top,
.delivery-data-top,
.upload-top,
.workshop-detail-header,
.item-order-body,
.order-item-top,
.history-header {
  padding-right: 72px;
}

.exit-button {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0 !important;
  border-radius: 999px;
  flex: 0 0 40px;
  line-height: 1;
}

.screen-header .exit-button,
.customer-header .exit-button,
.profile-top .exit-button,
.customer-info-top .exit-button,
.po-info-top .exit-button,
.delivery-data-top .exit-button,
.upload-top .exit-button,
.workshop-detail-header .exit-button,
.item-order-body .item-side-actions .exit-button,
.order-item-top .exit-button,
.history-header .exit-button,
.scanner-panel .exit-button {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
}

.print-actions {
  min-height: 40px;
  padding-right: 52px;
}

.print-actions .exit-button {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
}

.item-side-actions {
  padding-top: 48px;
}

.scanner-panel h2 {
  padding-right: 48px;
}

@media (max-width: 1000px) {
  .delivery-actions,
  .profile-actions,
  .po-actions,
  .customer-info-actions,
  .item-side-actions,
  .order-item-actions {
    padding-top: 48px;
  }

  .item-side-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .screen-header,
  .customer-header,
  .profile-top,
  .customer-info-top,
  .po-info-top,
  .delivery-data-top,
  .upload-top,
  .workshop-detail-header,
  .item-order-body,
  .order-item-top,
  .history-header {
    padding: 16px 66px 16px 16px;
  }

  .screen-header .exit-button,
  .customer-header .exit-button,
  .profile-top .exit-button,
  .customer-info-top .exit-button,
  .po-info-top .exit-button,
  .delivery-data-top .exit-button,
  .upload-top .exit-button,
  .workshop-detail-header .exit-button,
  .item-order-body .item-side-actions .exit-button,
  .order-item-top .exit-button,
  .history-header .exit-button,
  .scanner-panel .exit-button {
    top: 12px;
    right: 12px;
  }
}
  
.photo-zoom-stage {  
  display: flex;  
  justify-content: center;  
  align-items: flex-start;  
  width: 100%;  
  min-height: calc(100vh - 120px);  
  overflow: auto;  
  padding: 12px;  
  background: #0d1117;  
} 
.photo-zoom-stage .catalogue-photo-zoom-image {  
  max-width: none;  
  max-height: none;  
  transform-origin: top center;  
  transition: transform 0.15s ease;  
  display: block;  
}  
#photo-zoom .customer-header {  
  background: #111827;  
  padding: 10px 16px;  
  gap: 16px;  
} 
.photo-zoom-stage {  
  background: #fff;  
  display: flex;  
  justify-content: center;  
  align-items: flex-start;  
  padding: 16px;  
  overflow: auto;  
  min-height: 0;  
  flex: 1 1 auto;  
}  
.photo-zoom-stage .catalogue-photo-zoom-image {  
  max-width: 100%;  
  max-height: calc(100vh - 80px);  
  width: auto;  
  height: auto;  
  object-fit: contain;  
  transform-origin: top center;  
  display: block;  
}  
#photo-zoom {  
  display: none;  
  flex-direction: column;  
  height: 100vh;  
  background: #fff;  
}  
#photo-zoom:target {  
  display: flex;  
}  
#photo-zoom .customer-header {  
  background: #f5f6fa;  
  border-bottom: 1px solid #dde1e7;  
  padding: 10px 16px;  
  flex-shrink: 0;  
  display: flex;  
  align-items: center;  
  gap: 12px;  
} 
#photo-zoom.item-catalogue-screen {  
  position: fixed;  
  top: 0;  
  left: 0;  
  width: 100%;  
  height: 100%;  
  z-index: 1000;  
  display: none;  
  flex-direction: column;  
  align-items: center;  
  justify-content: center;  
  background: #fff;  
  margin: 0;  
  padding: 0;  
}  
#photo-zoom.item-catalogue-screen:target {  
  display: flex;  
}  
#photo-zoom .catalogue-photo-zoom-toolbar {  
  display: flex;  
  gap: 8px;  
  align-items: center;  
}  
#photo-zoom .customer-header {  
  width: 100%;  
  flex-shrink: 0;  
  display: flex;  
  align-items: center;  
  justify-content: center;  
  gap: 12px;  
  padding: 8px 16px;  
  background: #f5f6fa;  
  border-bottom: 1px solid #dde1e7;  
  position: relative;  
}  
#photo-zoom .customer-header .exit-button {  
  position: absolute;  
  right: 12px;  
  top: 50%;  
  transform: translateY(-50%);  
}  
#photo-zoom .photo-zoom-stage {  
  flex: 1 1 auto;  
  display: flex;  
  align-items: center;  
  justify-content: center;  
  width: 100%;  
  overflow: auto;  
  background: #fff;  
  padding: 16px;  
  min-height: 0;  
}  
#photo-zoom .photo-zoom-stage .catalogue-photo-zoom-image {  
  max-width: 100%;  
  max-height: 100%;  
  width: auto;  
  height: auto;  
  object-fit: contain;  
  transform-origin: center center;  
  display: block;  
} 
#photo-zoom.item-catalogue-screen {  
  position: fixed;  
  inset: 0;  
  z-index: 2000;  
  display: none;  
  align-items: center;  
  justify-content: center;  
  background: rgba(0,0,0,0.45);  
  padding: 24px;  
  flex-direction: row;  
  width: auto;  
  height: auto;  
  margin: 0;  
}  
#photo-zoom.item-catalogue-screen:target {  
  display: flex;  
}  
#photo-zoom .photo-zoom-card {  
  background: #fff;  
  border-radius: 10px;  
  box-shadow: 0 8px 40px rgba(0,0,0,0.28);  
  display: flex;  
  flex-direction: column;  
  max-width: 90vw;  
  max-height: 90vh;  
  min-width: 320px;  
  overflow: hidden;  
}  
#photo-zoom .photo-zoom-toolbar-bar {  
  display: flex;  
  align-items: center;  
  justify-content: space-between;  
  padding: 8px 12px;  
  border-bottom: 1px solid #e5e7eb;  
  background: #f9fafb;  
  flex-shrink: 0;  
  gap: 8px;  
}  
#photo-zoom .photo-zoom-stage {  
  flex: 1 1 auto;  
  display: flex;  
  align-items: center;  
  justify-content: center;  
  overflow: auto;  
  padding: 16px;  
  background: #fff;  
  min-height: 0;  
}  
#photo-zoom .photo-zoom-stage .catalogue-photo-zoom-image {  
  max-width: 80vw;  
  max-height: 80vh;  
  width: auto;  
  height: auto;  
  object-fit: contain;  
  transform-origin: center center;  
  display: block;  
} 
.po-requirement-screen {
  width: min(100%, 1320px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.po-requirement-screen:target {
  display: block;
}

body:has(.po-requirement-screen:target) .dashboard,
body:has(.po-requirement-screen:target) .screen,
body:has(.po-requirement-screen:target) .customer-info-screen,
body:has(.po-requirement-screen:target) .po-delivery-screen {
  display: none;
}

.po-req-top {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 8px 18px 10px;
  background: #f4f4f4;
}

.po-req-header-grid {
  display: grid;
  grid-template-columns: 120px minmax(140px, 1fr) 120px minmax(160px, 1fr) 90px minmax(120px, 1fr);
  gap: 5px;
  align-items: center;
  font-size: 13px;
}

.po-req-header-grid input {
  width: 100%;
  min-height: 28px;
}

.po-req-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  justify-content: flex-end;
  max-width: 620px;
}

.po-req-actions .small-button:not(.exit-button) {
  min-width: 90px;
  width: 104px;
  height: 42px;
  padding: 4px 10px;
  line-height: 1.1;
  text-align: center;
  font-size: 11px;
  flex: 0 0 auto;
}

.po-req-actions .exit-button {
  min-width: 44px;
  width: 44px;
  height: 44px;
  margin-left: 4px;
  flex: 0 0 auto;
}

.po-req-body {
  padding: 10px 18px 18px;
}

.po-req-tabs {
  display: flex;
  gap: 1px;
  align-items: end;
}

.po-req-tab-view {
  display: none;
  min-height: 560px;
  border: 1px solid #9ca9ba;
  background: #ffffff;
  padding: 10px;
}

.po-req-tab-view.active {
  display: block;
}

.po-req-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  margin-bottom: 8px;
}

.po-req-toolbar #poReqSearch {
  flex: 1 1 220px;
  max-width: 420px;
}

.po-req-toolbar #poReqWarehouseSelect {
  flex: 0 1 220px;
}

.po-req-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.po-req-check input {
  height: auto;
}

.po-req-grid-wrap {
  max-height: 62vh;
  border-top: 6px solid #c7c7cc;
}

.po-req-list-table {
  min-width: 1120px;
}


.po-req-list-table input,
.po-req-matrix-card input {
  width: 100%;
  height: 24px;
  border: 1px solid transparent;
  background: transparent;
  text-align: right;
  font: inherit;
}

.po-req-list-table input:focus,
.po-req-matrix-card input:focus {
  border-color: #8ba9df;
  background: #ffffff;
  outline: 2px solid rgba(23, 67, 108, 0.14);
}

.po-req-list-table tfoot td {
  background: #ecf5f5;
  color: #103f52;
  font-weight: 700;
}

.po-req-matrix-area {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 14px;
  align-items: start;
}

.po-req-matrix-card {
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
}

.po-req-matrix-card.small {
  max-width: 420px;
}

.po-req-matrix-card h2 {
  margin: 0;
  padding: 10px 12px;
  background: #ecf5f5;
  color: #103f52;
  font-size: 15px;
}

.po-req-matrix-wrap {
  margin-top: 0;
  border-top: 0;
  max-height: none;
}

.po-req-matrix-wrap table {
  min-width: 360px;
}

.po-req-matrix-card td,
.po-req-matrix-card th {
  text-align: center;
}

@media (max-width: 900px) {
  .po-req-top,
  .po-req-header-grid,
  .po-req-actions,
  .po-req-toolbar,
  .po-req-matrix-area {
    display: block;
  }

  .po-req-actions {
    display: flex;
    margin-top: 10px;
    max-width: none;
  }

  .po-req-actions .small-button {
    margin: 3px 0;
  }
}
.po-requirement-screen {
    max-width: 1600px;
    margin: 0 auto;
}

.primary-button {
    font-weight: 700;
}

/* Final PO Requirement table column sizes */
.po-req-list-table {
    table-layout: fixed;
    width: 100%;
    min-width: 1040px;
}

/* Item */
.po-req-list-table th:nth-child(1),
.po-req-list-table td:nth-child(1) {
    width: 130px;
}

/* Size */
.po-req-list-table th:nth-child(2),
.po-req-list-table td:nth-child(2) {
    width: 150px;
}

/* Required */
.po-req-list-table th:nth-child(3),
.po-req-list-table td:nth-child(3) {
    width: 70px;
}

/* Released */
.po-req-list-table th:nth-child(4),
.po-req-list-table td:nth-child(4) {
    width: 70px;
}

/* Available */
.po-req-list-table th:nth-child(5),
.po-req-list-table td:nth-child(5) {
    width: 70px;
}

/* Buffer */
.po-req-list-table th:nth-child(6),
.po-req-list-table td:nth-child(6) {
    width: 70px;
}

/* Suggested PO */
.po-req-list-table th:nth-child(7),
.po-req-list-table td:nth-child(7) {
    width: 80px;
}

/* Item No */
.po-req-list-table th:nth-child(8),
.po-req-list-table td:nth-child(8) {
    width: 180px;
}

/* Item Description */
.po-req-list-table th:nth-child(9),
.po-req-list-table td:nth-child(9) {
    width: auto;
}

/* Small qty inputs (Buffer / Suggested) */
.po-req-list-table td:nth-child(6) input,
.po-req-list-table td:nth-child(7) input {
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
    text-align: center;
}

/* Qty columns - wrapped and centered */
.po-req-list-table th:nth-child(3),
.po-req-list-table th:nth-child(4),
.po-req-list-table th:nth-child(5),
.po-req-list-table th:nth-child(6),
.po-req-list-table th:nth-child(7),
.po-req-list-table td:nth-child(3),
.po-req-list-table td:nth-child(4),
.po-req-list-table td:nth-child(5),
.po-req-list-table td:nth-child(6),
.po-req-list-table td:nth-child(7) {
    text-align: center;
    white-space: normal;
    line-height: 1.2;
}

/* Wrap header text */
.po-req-list-table th {
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
    height: auto;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* Smaller header text for the narrow quantity columns so they don't wrap */
.po-req-list-table th:nth-child(3),
.po-req-list-table th:nth-child(4),
.po-req-list-table th:nth-child(5),
.po-req-list-table th:nth-child(6),
.po-req-list-table th:nth-child(7) {
    font-size: 0.78rem;
    padding-left: 4px;
    padding-right: 4px;
}

/* Final Matrix View compact columns */
.po-req-matrix-card table {
    table-layout: fixed !important;
    width: 100% !important;
    min-width: 0 !important;
}

.po-req-matrix-card th,
.po-req-matrix-card td {
    text-align: center !important;
    font-size: 13px !important;
    padding: 4px 6px !important;
    white-space: normal !important;
}

/* Size / Waist column */
.po-req-matrix-card th:first-child,
.po-req-matrix-card td:first-child {
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
}

/* A, B, C / 40, 42, 44 columns */
.po-req-matrix-card th:not(:first-child):not(:last-child),
.po-req-matrix-card td:not(:first-child):not(:last-child) {
    width: 30px;
    min-width: 30px;
    max-width: 30px;
}

/* Size / Waist column */
.po-req-matrix-card th:first-child,
.po-req-matrix-card td:first-child {
    width: 30px;
    min-width: 30px;
}

/* Total column */
.po-req-matrix-card th:last-child,
.po-req-matrix-card td:last-child {
    width: 30px;
    min-width: 30px;
    
}

/* Center the textbox */
.po-req-matrix-card input {
    margin: 0 auto;
    display: block;
    text-align: center;
}

#poReqNoSizeView table {
    table-layout: auto !important;
    width: auto !important;
}

#poReqNoSizeView th:nth-child(1),
#poReqNoSizeView td:nth-child(1) {
    width: 30px !important;
}

#poReqNoSizeView th:nth-child(2),
#poReqNoSizeView td:nth-child(2),
#poReqNoSizeView th:nth-child(3),
#poReqNoSizeView td:nth-child(3),
#poReqNoSizeView th:nth-child(4),
#poReqNoSizeView td:nth-child(4) {
    width: 10px !important;
    text-align: center !important;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.history-header .exit-button {
    margin-top: -22px;
}

/* Row No */
.goods-received-items-table th:nth-child(1),
.goods-received-items-table td:nth-child(1) {
    width: 34px;
}

/* Go */
.goods-received-items-table th:nth-child(2),
.goods-received-items-table td:nth-child(2) {
    width: 42px;
}

/* Item No */
.goods-received-items-table th:nth-child(3),
.goods-received-items-table td:nth-child(3) {
    width: 120px;
}

/* Item Description - kept narrow; long text wraps within this width */
.goods-received-items-table th:nth-child(4),
.goods-received-items-table td:nth-child(4) {
    width: 240px;
    max-width: 240px;
    white-space: normal;
    word-break: break-word;
}

/* Ordered Qty */
.goods-received-items-table th:nth-child(5),
.goods-received-items-table td:nth-child(5) {
    width: 30px;
    text-align: center;
}

/* Previously Received */
.goods-received-items-table th:nth-child(6),
.goods-received-items-table td:nth-child(6) {
    width: 30px;
    text-align: center;
}

/* Remaining Qty */
.goods-received-items-table th:nth-child(7),
.goods-received-items-table td:nth-child(7) {
    width: 30px;
    text-align: center;
}

/* Receive Qty */
.goods-received-items-table th:nth-child(8),
.goods-received-items-table td:nth-child(8) {
    width: 30px;
    text-align: center;
}

/* Delete/X column (TrackNo column removed - tracking is a single per-GR value) */
.goods-received-items-table th:nth-child(9),
.goods-received-items-table td:nth-child(9) {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    text-align: center;
}

.goods-received-items-table tr {
    height: 24px !important;
}

.goods-received-items-table td {
    padding: 0 4px !important;
    vertical-align: middle;
}

/* Compact headers and the qty columns (Order / Prev Rcvd / Bal / Rcvd). */
.goods-received-items-table th {
    font-size: 11px;
    padding: 0 3px !important;
    line-height: 1.1;
}

.goods-received-items-table th:nth-child(5),
.goods-received-items-table td:nth-child(5),
.goods-received-items-table th:nth-child(6),
.goods-received-items-table td:nth-child(6),
.goods-received-items-table th:nth-child(7),
.goods-received-items-table td:nth-child(7),
.goods-received-items-table th:nth-child(8),
.goods-received-items-table td:nth-child(8) {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    font-size: 11px;
    text-align: center;
}

/* Keep inputs (incl. the Totals footer boxes) from forcing the column wide. */
.goods-received-items-table td:nth-child(5) input,
.goods-received-items-table td:nth-child(6) input,
.goods-received-items-table td:nth-child(7) input,
.goods-received-items-table td:nth-child(8) input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0 2px;
    text-align: center;
}

.job-desc-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    display: grid;
    place-items: center;
    z-index: 999;
}

.job-desc-panel {
    width: 380px;
    background: white;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 18px 45px rgba(0,0,0,.22);
}

.job-desc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-desc-header h2 {
    margin: 0;
    color: #103f52;
}

.job-desc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 16px;
}

.job-desc-buttons button {
    min-height: 38px;
    border: 1px solid #8ba9df;
    border-radius: 6px;
    background: #d8e5ff;
    cursor: pointer;
}

.job-desc-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.28);
    display: grid;
    place-items: center;
    z-index: 9999;
}

.job-desc-popup[hidden] {
    display: none;
}

.job-desc-panel {
    width: 390px;
    max-width: 92vw;
    background: #ffffff;
    border: 1px solid #b9d7e4;
    border-radius: 12px;
    padding: 16px 18px 18px;
    box-shadow: 0 18px 45px rgba(23, 67, 108, 0.25);
}

.job-desc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.job-desc-header h2 {
    margin: 0;
    color: #103f52;
    font-size: 20px;
    text-align: center;
    flex: 1;
}

.job-desc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.location-custom-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.location-custom-input {
    flex: 1;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #b9d7e4;
    border-radius: 6px;
    font-size: 14px;
}

.location-custom-save {
    flex: 0 0 42px;
    border: 1px solid #8ba9df;
    border-radius: 6px;
    background: linear-gradient(#edf4ff, #c9dcff);
    color: #136f3a;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
}

.location-custom-save:hover {
    background: linear-gradient(#f8fbff, #bdd4ff);
}

.location-custom-save:disabled,
.location-custom-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.workshop-email-note {
    margin: 0 0 12px;
    color: #44606c;
    font-size: 13px;
    line-height: 1.45;
}

#workshopEmailInput {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 16px;
    padding: 8px 10px;
    border: 1px solid #b9d7e4;
    border-radius: 6px;
    font-size: 14px;
}

.workshop-email-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.job-desc-buttons button {
    min-height: 38px;
    border: 1px solid #8ba9df;
    border-radius: 6px;
    background: linear-gradient(#edf4ff, #c9dcff);
    color: #103f52;
    font-weight: 600;
    cursor: pointer;
}

.job-desc-buttons button:hover {
    background: linear-gradient(#f8fbff, #bdd4ff);
}

#openJobDescListButton {
    width: 80px;
    height: 34px;
    flex: 0 0 80px;
}

#openJobDescListButton {
    align-self: end;
}

#sapItemStockSummary {
    overflow-x: auto;
    max-width: 100%;
}

#sapItemStockSummary table {
    table-layout: auto !important;
    width: max-content !important;
    min-width: 100% !important;
}

/* >> column */
#sapItemStockSummary th:nth-child(1),
#sapItemStockSummary td:nth-child(1) {
    width: 45px !important;
    min-width: 45px !important;
    text-align: center !important;
}

/* Status column */
#sapItemStockSummary th:nth-child(2),
#sapItemStockSummary td:nth-child(2) {
    width: 130px !important;
    min-width: 130px !important;
}

/* All warehouse columns */
#sapItemStockSummary th:nth-child(n+3),
#sapItemStockSummary td:nth-child(n+3) {
    width: 70px !important;
    min-width: 70px !important;
    text-align: center !important;
    white-space: nowrap !important;
}

#sapItemStockSummary table {
    margin-bottom: 8px;
}

.delivery-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    max-width: none;
    flex-wrap: nowrap;
}

.delivery-actions .small-button {
    width: 92px;
    min-width: 92px;
    height: 40px;
    font-size: 12px;
    line-height: 1.1;
}

#poDeliveryExitButton {
    width: 42px;
    min-width: 42px;
}

.search-fields.left.inventory-search-fields {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

#workshop-orders .search-fields {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    justify-content: flex-start;
}

#workshop-orders .workshop-order-search-row,
#workshop-orders .workshop-order-filter-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    max-width: 100%;
}

#workshop-orders .workshop-order-search-row label {
    margin-right: 0;
}

#workshopOrderSearch {
    width: 420px;
    max-width: min(420px, calc(100vw - 320px));
}

#workshop-orders #clearWorkshopOrderSearch {
    min-width: 92px;
}

#workshop-orders .search-fields select {
    width: 178px;
    min-width: 0;
    max-width: 178px;
}

#workshopOrderPoFilter {
    width: 178px;
    min-width: 0;
}

#workshop-orders .customer-header {
    padding-right: 210px;
}

#workshop-orders .customer-header > .utility-actions.customer-actions {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    width: auto;
    min-width: 0;
    height: auto;
    overflow: visible;
}

#workshop-orders .customer-header .utility-actions.customer-actions .exit-button {
    position: relative;
    top: auto;
    right: auto;
    margin: 0;
}

#exportWorkshopOrdersExcel {
    min-width: 118px;
}

#openTailorReportButton {
    min-width: 112px;
}

#tailor-productivity-report .customer-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 16px;
    padding-right: 16px;
}

#tailor-productivity-report .customer-header > .utility-actions.customer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    grid-template-columns: none;
    width: auto;
    min-width: 234px;
    align-self: start;
    padding-top: 18px;
}

#tailor-productivity-report .customer-header .utility-actions.customer-actions .small-button:not(.exit-button) {
    width: auto;
    min-width: 86px;
    padding-left: 14px;
    padding-right: 14px;
    white-space: nowrap;
}

#tailorReportExportExcel {
    min-width: 112px;
}

#tailor-productivity-report .customer-header .utility-actions.customer-actions .exit-button {
    position: relative;
    top: auto;
    right: auto;
    margin: 0;
    flex: 0 0 40px;
}

.tailor-report-filters {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.tailor-report-filters > label {
    flex: 1 1 0;
    min-width: 0;
}

.tailor-report-filters label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: #475569;
}

.tailor-report-filters input,
.tailor-report-filters select {
    min-width: 0;
}

/* Match the TomSelect controls to the plain filter inputs so the row is uniform. */
.tailor-report-filters input,
.tailor-report-filters .ts-wrapper .ts-control {
    height: 34px;
    min-height: 34px;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    padding: 4px 8px;
    font: inherit;
    box-shadow: none;
}

.tailor-report-filters .ts-wrapper {
    min-width: 0;
}

.tailor-report-filters .ts-wrapper.single .ts-control {
    padding-right: 22px;
}

.tailor-report-filters .ts-wrapper .ts-control,
.tailor-report-filters .ts-wrapper .ts-control > input {
    line-height: 24px;
    margin: 0;
}

.tailor-report-grid td.num,
.tailor-report-grid th.num {
    text-align: center;
}

.tailor-report-group-total td {
    background: #eef4fb;
    font-weight: 600;
    border-top: 1px solid #c7d6ea;
    border-bottom: 2px solid #c7d6ea;
}

.tailor-report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.tailor-report-summary .summary-card {
    border: 1px solid #d9e2ef;
    border-radius: 6px;
    background: #fff;
    padding: 8px 10px;
}

.tailor-report-summary span {
    display: block;
    color: #64748b;
    font-size: 11px;
}

.tailor-report-summary strong {
    display: block;
    color: #0f172a;
    font-size: 16px;
    margin-top: 2px;
}

.tailor-report-tabs {
    margin: 10px 0;
}

.tailor-report-grid {
    max-height: calc(100vh - 290px);
}

.tailor-report-grid table {
    min-width: 1180px;
}

.sap-item-filter-row {
    display: flex;
    align-items: center;
    flex-basis: 100%;
    gap: 8px;
}

.sap-item-filter-row select {
    min-width: 180px;
}

.sap-items-export-panel {
    width: min(620px, 94vw);
}

.sap-items-export-grid {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 8px 10px;
    align-items: center;
    margin: 12px 0;
}

.sap-items-export-grid label {
    font-weight: 700;
    color: #103f52;
}

.sap-items-export-grid input,
.sap-items-export-grid select {
    width: 100%;
    min-height: 32px;
    border: 1px solid #bdd5df;
    border-radius: 6px;
    padding: 5px 8px;
}

#cartonTagSearch {
    width: 220px;
    flex: 0 0 220px;
}

#cartonTagGenderFilter {
    width: 120px;
    flex: 0 0 120px;
}


.packing-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#releaseNowButton,
#returnButton {
    white-space: nowrap;
}

.packing-date-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.packing-date-actions input {
    flex: 1;
}

/* Compact header for ERP transaction screens */
body.compact-header .topbar {
    padding: 4px 12px !important;
    min-height: 36px !important;
    height: 36px !important;
}

body.compact-header .brand-text {
    font-size: 10px !important;
    line-height: 1 !important;
}

body.compact-header .brand-mark {
    width: 28px !important;
    height: 28px !important;
    font-size: 10px !important;
    border-radius: 9px !important;
    background: #103f52 !important;
    color: #ffffff !important;
    display: grid !important;
    place-items: center !important;
    padding-left: 0 !important;
    border-left: 0 !important;
}

body.compact-header .current-user-summary {
    gap: 6px;
    font-size: 10px;
}

body.compact-header .current-user-summary div {
    min-width: 94px;
    gap: 0;
    padding: 2px 8px;
    border-radius: 7px;
}

body.compact-header .current-user-summary span {
    font-size: 8px;
}

body.compact-header .current-user-summary strong {
    font-size: 10px;
}

/* Inventory Adjustment table sizing */
#inventoryAdjustmentItemsHead,
#inventoryAdjustmentItemsRows,
#inventoryAdjustmentItemsFoot {
    font-size: 13px;
}

/* Available column */
#inventoryAdjustmentItemsHead th:nth-child(5),
#inventoryAdjustmentItemsRows td:nth-child(5),
#inventoryAdjustmentItemsFoot td:nth-child(2) {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
    text-align: center !important;
}

/* Actual Count column */
#inventoryAdjustmentItemsHead th:nth-child(6),
#inventoryAdjustmentItemsRows td:nth-child(6),
#inventoryAdjustmentItemsFoot td:nth-child(3) {
    width: 112px !important;
    min-width: 112px !important;
    max-width: 112px !important;
    text-align: center !important;
}

/* Difference column */
#inventoryAdjustmentItemsHead th:nth-child(7),
#inventoryAdjustmentItemsRows td:nth-child(7),
#inventoryAdjustmentItemsFoot td:nth-child(4) {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
    text-align: center !important;
}

/* Inputs inside qty columns */
#inventoryAdjustmentItemsRows td:nth-child(5) input,
#inventoryAdjustmentItemsRows td:nth-child(6) input,
#inventoryAdjustmentItemsRows td:nth-child(7) input,
#inventoryAdjustmentItemsFoot input {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
    text-align: center !important;
}

/* RowNo */
#inventoryAdjustmentItemsHead th:nth-child(1),
#inventoryAdjustmentItemsRows td:nth-child(1) {
    width: 40px !important;
    text-align: center;
}

/* Go */
#inventoryAdjustmentItemsHead th:nth-child(2),
#inventoryAdjustmentItemsRows td:nth-child(2) {
    width: 45px !important;
    text-align: center;
}

/* Delete button column */
#inventoryAdjustmentItemsHead th:nth-child(8),
#inventoryAdjustmentItemsRows td:nth-child(8) {
    width: 40px !important;
    text-align: center;
}


.workshop-action-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.workshop-action-row label {
    white-space: nowrap;
}

#workshopSubmitToSelect {
    width: 500px;
}

#workshopReceivedLocation {
    width: 220px;
}

#workshopReceivedDate {
    min-width: 100px;
    display: inline-block;
}

#workshopSubmitButton,
#workshopLocationButton,
#workshopClaimButton {
    width: 70px;
    min-width: 70px;
}

.workshop-worker-row select:first-child {
    width: 260px;
    font-size: 12px;
}

.workshop-worker-table select {
    width: 150px !important;
    font-size: 12px !important;
}

.workshop-worker-table .ts-wrapper {
    width: 150px;
    font-size: 12px;
}
/* Admin Panel */
.admin-panel-body {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 0;
}

.admin-section {
  background: #fff;
  border: 1px solid #c8d4e1;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.admin-section h2 {
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--brand);
  border-bottom: 1px solid #e8f0f5;
  padding-bottom: 10px;
}

.admin-setting {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.admin-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-label span {
  font-weight: 700;
  font-size: 14px;
}

.admin-label small {
  color: #7a8fa0;
  font-size: 12px;
  max-width: 400px;
  line-height: 1.4;
}

.admin-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 160px;
}

.admin-control-cc {
  flex: 1;
  align-items: stretch;
  min-width: 260px;
}

.admin-control-cc textarea,
.admin-control-cc input {
  width: 100%;
  border: 1px solid #c8d4e1;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.admin-control-cc textarea {
  resize: vertical;
}

.admin-control-cc .small-button {
  align-self: flex-end;
}

#receivingFormCcStatus {
  font-size: 11px;
  color: #7a8fa0;
  text-align: right;
}

#allowNegativeQtyStatus {
  font-size: 11px;
  color: #7a8fa0;
  text-align: right;
  max-width: 160px;
}

/* Admin: letterhead logo upload */
.admin-control-logo {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.letterhead-preview {
  width: 320px;
  max-width: 100%;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px dashed #b9c7d2;
  border-radius: 8px;
  background: #fff;
}
.letterhead-preview img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
}
#letterheadPreviewEmpty {
  font-size: 12px;
  color: #7a8fa0;
  text-align: center;
}
.letterhead-actions {
  display: flex;
  gap: 6px;
}

/* Workshop locked fields - always disabled, greyed out */
.workshop-locked-control:disabled {
  background: #f0f4f7;
  color: #555;
  cursor: not-allowed;
  opacity: 1;
  border-color: #d0dce5;
}

.packing-avail-inline {
  font-size: 13px;
  font-weight: 700;
  color: #2e7d52;
  padding: 2px 0 4px 2px;
  min-height: 18px;
}

.release-avail-qty {
  color: #2e7d52;
  font-weight: 700;
}

/* ── Bill of Materials ──────────────────────────────────────────────────────── */
.bom-search-input {
  padding: 6px 10px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  font: inherit;
  min-width: 220px;
}

.bom-list-table td, .bom-list-table th { padding: 6px 10px; }

.bom-detail-body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.bom-tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #c8d4e1;
  margin-bottom: 0;
}

.bom-tab-content {
  background: #fff;
  border: 1px solid #c8d4e1;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 0;
}

.bom-section-actions {
  padding: 10px 14px;
  border-bottom: 1px solid #e8f0f5;
  background: #f7fbfc;
  display: flex;
  justify-content: flex-end;
}

.bom-header-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 14px;
  padding: 16px;
  background: #fff;
  border: 1px solid #c8d4e1;
  border-radius: 8px;
}

.bom-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bom-field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.bom-field input {
  padding: 5px 8px;
  border: 1px solid #c6dce5;
  border-radius: 6px;
  font: inherit;
  background: #fff;
}

.bom-field input[readonly] {
  background: #f0f4f7;
  color: #555;
}

.bom-field-wide { grid-column: span 2; }

.bom-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.bom-section {
  background: #fff;
  border: 1px solid #c8d4e1;
  border-radius: 8px;
  overflow: hidden;
}

.bom-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e8f0f5;
  background: #f7fbfc;
}

.bom-section-header h2 {
  margin: 0;
  font-size: 14px;
  color: var(--brand);
  font-weight: 700;
}

.bom-finished-table td,
.bom-finished-table th,
.bom-raw-table td,
.bom-raw-table th {
  padding: 6px 10px;
}

.bom-qty-input { width: 70px; padding: 3px 6px; border: 1px solid #c6dce5; border-radius: 4px; font: inherit; }
.bom-uom-input { width: 70px; padding: 3px 6px; border: 1px solid #c6dce5; border-radius: 4px; font: inherit; }
.bom-remarks-input { width: 140px; padding: 3px 6px; border: 1px solid #c6dce5; border-radius: 4px; font: inherit; }

.bom-select-panel {
  max-width: 480px;
  width: 90%;
}

.bom-select-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.bom-select-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid #c6dce5;
  border-radius: 8px;
  background: #f7fbfc;
  cursor: pointer;
  font: inherit;
}

.bom-select-item:hover { background: #eaf3fb; border-color: var(--brand); }
.bom-select-item strong { color: var(--brand); font-size: 14px; }
.bom-select-item span { color: var(--muted); font-size: 12px; }

.packing-avail-inline {
  font-size: 13px;
  font-weight: 700;
  color: #2e7d52;
  padding: 2px 0 4px 2px;
  min-height: 18px;
}

.release-avail-qty {
  color: #2e7d52;
  font-weight: 700;
}

/* ===== Delivery Maintenance action animations (Release / Return / Pack) ===== */
#packingReleaseNowButton,
#packingReturnButton,
#packingPackButton {
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#packingReleaseNowButton:active:not(:disabled),
#packingReturnButton:active:not(:disabled),
#packingPackButton:active:not(:disabled) {
  transform: scale(0.95);
}

.button-loading {
  pointer-events: none;
  opacity: 0.85;
}

.button-loading::after {
  content: "\21BB";
  display: inline-block;
  margin-left: 6px;
  animation: packing-spin-ccw 0.8s linear infinite;
  will-change: transform;
}

.packing-action-busy {
  pointer-events: none;
  opacity: 0.85;
}

.packing-action-busy::after {
  display: inline-block;
  margin-left: 6px;
  will-change: transform;
}

#packingReleaseNowButton.packing-action-busy::after {
  content: "\279C";
  animation: packing-slide-right 0.7s ease-in-out infinite;
}

#packingReturnButton.packing-action-busy::after {
  content: "\21BA";
  animation: packing-spin-ccw 0.8s linear infinite;
}

#packingPackButton.packing-action-busy::after {
  content: "\25A2";
  animation: packing-box-pulse 0.7s ease-in-out infinite;
}

@keyframes packing-slide-right {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(6px); opacity: 0.2; }
}

@keyframes packing-spin-ccw {
  to { transform: rotate(-360deg); }
}

@keyframes packing-box-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* Success splash shown after a confirmed release / return / pack */
.packing-success-splash {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 40, 60, 0.35);
}

.packing-success-splash[hidden] {
  display: none;
}

.packing-success-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 26px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: packing-pop-in 0.25s ease-out;
}

.packing-success-text {
  font-weight: 600;
  color: #0f5132;
  font-size: 15px;
}

.packing-success-card svg {
  width: 56px;
  height: 56px;
}

.packing-success-card svg .draw {
  stroke-dasharray: 80;
  stroke-dashoffset: 80;
  animation: packing-draw 0.5s ease-out 0.1s forwards;
}

@keyframes packing-pop-in {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes packing-draw {
  to { stroke-dashoffset: 0; }
}

.release-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 40, 60, 0.35);
}

.release-popup-overlay[hidden] {
  display: none;
}

.release-popup {
  background: #ffffff;
  border-radius: 14px;
  padding: 26px 40px;
  min-width: 280px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: packing-pop-in 0.25s ease-out;
  text-align: center;
}

.release-popup-icon[hidden] {
  display: none;
}

.release-popup-icon-sending {
  position: relative;
  width: 56px;
  height: 56px;
}

.release-popup-spinner {
  position: absolute;
  inset: 0;
  border: 4px solid #d6e7f5;
  border-top-color: #1d6fb8;
  border-radius: 50%;
  animation: release-popup-spin 0.9s linear infinite;
}

.release-popup-envelope {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #1d6fb8;
  animation: release-popup-bob 1.2s ease-in-out infinite;
}

.release-popup-check {
  width: 56px;
  height: 56px;
}

.release-popup-check-circle {
  stroke: #198754;
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: packing-draw 0.5s ease-out forwards;
}

.release-popup-check-mark {
  stroke: #198754;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 80;
  stroke-dashoffset: 80;
  animation: packing-draw 0.45s ease-out 0.35s forwards;
}

.release-popup-icon-warning {
  font-size: 44px;
  color: #b45309;
  animation: packing-pop-in 0.3s ease-out;
}

.release-popup-title {
  font-weight: 600;
  font-size: 16px;
  color: #1c3d5a;
}

.release-popup-message {
  font-size: 13.5px;
  color: #44586c;
}

.release-popup-actions[hidden],
.release-popup-actions:empty {
  display: none;
}

@keyframes release-popup-spin {
  to { transform: rotate(360deg); }
}

@keyframes release-popup-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* ===== Delivery Maintenance: Item row info button + catalogue details popup ===== */
.packing-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.packing-item-row strong {
  flex: 1;
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #d3e1e8;
  border-radius: 6px;
  background: #f8fbfd;
}

.packing-item-info-button {
  flex: none;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.item-info-panel {
  width: min(760px, 96vw);
}

.item-info-fields {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 6px 10px;
  align-items: center;
  margin: 10px 0;
}

.item-info-fields label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.item-info-fields strong,
.item-info-fields span {
  min-height: 26px;
  font-size: 12px;
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid #d3e1e8;
  border-radius: 6px;
  background: #f8fbfd;
}

.item-info-gallery {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-info-stage {
  position: relative;
  flex: 1;
  height: min(58vh, 520px);
  border: 1px solid #d3e1e8;
  border-radius: 8px;
  background: #f4f8fb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.item-info-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.12s ease;
  cursor: zoom-in;
}

.item-info-no-photo {
  color: var(--muted);
  font-size: 13px;
}

.item-info-nav {
  flex: none;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
}

.item-info-zoom-toolbar {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
}

.item-info-zoom-toolbar button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #b9d8e1;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.item-info-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 10px;
  min-height: 8px;
}

.item-info-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4d6de;
}

.item-info-dot.active {
  background: var(--brand);
}

/* ------------------------------------------------------------------ */
/* Order Flow Monitor                                                  */
/* ------------------------------------------------------------------ */
#order-flow-monitor.screen,
#order-flow-detail.screen {
  width: min(100%, 1320px);
  box-sizing: border-box;
  padding: 0 16px;
}

.order-flow-header {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.order-flow-table {
  width: 100%;
}

#order-flow-monitor .grid-wrap {
  padding-right: 4px;
}

.order-flow-table th:last-child,
.order-flow-table td:last-child {
  width: 56px;
  padding-right: 12px;
  text-align: center;
}

.flow-po {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.flow-po-yes { background: #e3f4e4; color: #2e7d32; }
.flow-po-no { background: #f1f3f7; color: #94a0b6; }
.flow-po-part { background: #fff3e0; color: #b9690e; }
.flow-po-complete { background: #e4eefc; color: #1c4fa0; }

/* Neutral "No workshop" marker: order has no workshop-made items (ready/stock
   only). Muted so it reads as not-applicable, never as pending/failed work. */
.flow-na-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #f1f3f7;
  color: #94a0b6;
}

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}

.kpi-card {
  background: #fff;
  border: 1px solid #d6deea;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(15, 31, 60, 0.06);
}

.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #061f9e;
  line-height: 1.1;
}

.kpi-card .kpi-label {
  margin-top: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6b85;
}

.order-flow-table td,
.order-flow-table th {
  vertical-align: middle;
}

/* Progress bar cell */
.flow-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.flow-progress .flow-bar {
  flex: 1;
  height: 8px;
  border-radius: 6px;
  background: #e6ebf3;
  overflow: hidden;
}

.flow-progress .flow-bar > span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: #2e7d32;
}

.flow-progress.flow-red .flow-bar > span { background: #d32f2f; }
.flow-progress.flow-orange .flow-bar > span { background: #ef8c00; }
.flow-progress.flow-green .flow-bar > span { background: #2e7d32; }

.flow-progress .flow-pct {
  font-size: 12px;
  font-weight: 600;
  color: #34425c;
  min-width: 34px;
  text-align: right;
}

.flow-progress.flow-na .flow-pct { color: #9aa6bb; }

/* Status pill */
.flow-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #eef1f6;
  color: #4a5874;
}

.flow-status.s-delivered,
.flow-status.s-closed { background: #e3f4e4; color: #2e7d32; }
.flow-status.s-partially-delivered { background: #fff2dd; color: #b86a00; }
.flow-status.s-workshop { background: #e3edfb; color: #1b5fc4; }
.flow-status.s-packing { background: #f1e9fb; color: #6a3fb0; }
.flow-status.s-procurement { background: #fdeef0; color: #c0445a; }
.flow-status.s-not-started { background: #eef1f6; color: #6b7895; }

.flow-open {
  border: none;
  background: #061f9e;
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
}

.flow-open:hover { background: #0a2bd0; }

/* Detail panel */
.order-flow-detail-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 4px 24px;
}

.order-flow-detail-body table {
  width: 100%;
  border-collapse: collapse;
}

.order-flow-detail-body th,
.order-flow-detail-body td {
  padding: 8px 12px;
  text-align: left;
}

.flow-detail-section {
  padding: 0 4px;
}

.flow-detail-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 4px;
  margin-top: -8px;
}

.flow-detail-toolbar .small-button {
  min-width: 118px;
}

.order-flow-status-table th,
.order-flow-status-table td {
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.order-flow-status-table .flow-measure {
  margin-top: 2px;
  font-size: 11px;
  font-style: italic;
  color: #64748b;
  white-space: normal;
}

.order-flow-status-table .flow-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.flow-open-ws { background: #b86a00; }
.flow-open-ws:hover { background: #d27c00; }
.flow-open-dlv { background: #061f9e; }
.flow-open-dlv:hover { background: #0a2bd0; }

.flow-actions-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #5b6b85;
  margin: 0 0 8px;
}

.flow-actions-legend .flow-open {
  padding: 1px 7px;
  font-size: 11px;
  cursor: default;
}

.flow-detail-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  background: #fff;
  border: 1px solid #d6deea;
  border-radius: 12px;
  padding: 16px;
}

.flow-detail-info .field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7895;
}

.flow-detail-info .field-value {
  font-size: 15px;
  font-weight: 600;
  color: #1f2c46;
  margin-top: 2px;
}

.flow-timeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.flow-timeline .flow-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.flow-timeline .flow-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c4cedd;
}

.flow-timeline .flow-step.done .flow-dot { background: #2e7d32; }
.flow-timeline .flow-step.active .flow-dot { background: #ef8c00; }
.flow-timeline .flow-step.done { color: #2e7d32; }
.flow-timeline .flow-step.active { color: #b86a00; }
.flow-timeline .flow-step.pending { color: #9aa6bb; }

.flow-timeline .flow-arrow { color: #b3bdce; }

.flow-detail-section h2 {
  font-size: 15px;
  color: #061f9e;
  margin: 0 0 8px;
}

.flow-detail-section .flow-empty {
  color: #8b97ad;
  font-size: 13px;
  padding: 6px 0;
}

/* ===== Custom Order (Suit/Set + Shirt) ===== */
#custom-orders .utility-actions.customer-actions {
  grid-template-columns: auto 40px;
  gap: 10px;
}
#newCustomOrderButton {
  padding: 4px 12px;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
}
.custom-order-no { font-size: 14px; color: #3656a8; font-weight: 600; }
.custom-order-status { font-size: 13px; color: #8b6b1f; font-weight: 600; margin-top: 4px; }
.custom-order-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.55fr) minmax(360px, 1.2fr) minmax(430px, 1.4fr);
  gap: 14px;
  align-items: start;
}
.custom-order-grid > .custom-order-panel:nth-child(1) { order: 2; }
.custom-order-grid > .custom-order-panel:nth-child(2) { order: 1; }
.custom-order-grid > .custom-order-panel:nth-child(3) { order: 3; }
@media (max-width: 1100px) {
  .custom-order-grid { grid-template-columns: 1fr; }
  .custom-order-grid > .custom-order-panel:nth-child(1),
  .custom-order-grid > .custom-order-panel:nth-child(2),
  .custom-order-grid > .custom-order-panel:nth-child(3) { order: initial; }
}
.custom-order-panel {
  background: #fff;
  border: 1px solid #e2e6ee;
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 0;
}
.custom-order-field input, .custom-order-field textarea, .custom-order-field select { box-sizing: border-box; min-width: 0; }
.custom-order-h3 {
  margin: 14px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #5a6478;
}
.custom-order-h3:first-child { margin-top: 0; }
.custom-order-field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.custom-order-field label { font-size: 11px; color: #6b7484; }
.custom-order-field input, .custom-order-field textarea, .custom-order-field select {
  padding: 6px 8px; border: 1px solid #cdd4e0; border-radius: 6px; font-size: 13px; width: 100%;
}
.custom-order-field-row { display: flex; gap: 10px; }
.custom-order-field-row .custom-order-field { flex: 1; }
.custom-measure-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.custom-measure-field { display: flex; flex-direction: column; gap: 2px; }
.custom-measure-field label { font-size: 11px; color: #6b7484; }
.custom-measure-field input { padding: 5px 7px; border: 1px solid #cdd4e0; border-radius: 6px; font-size: 13px; }
.custom-items-block { display: flex; gap: 14px; }
.custom-items-col { flex: 1; }
.custom-items-title { font-weight: 600; font-size: 12px; margin-bottom: 6px; color: #3656a8; }
.custom-item-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.custom-item-name { flex: 1; font-size: 13px; }
.custom-item-qty { width: 52px; padding: 3px 5px; border: 1px solid #cdd4e0; border-radius: 5px; font-size: 12px; }
.custom-item-empty { font-size: 12px; color: #98a0b0; }

/* Smaller measurement boxes in a narrow panel */
.custom-measure-grid-sm {
  grid-template-columns: repeat(2, minmax(0, 72px));
  justify-content: center;
  gap: 6px 8px;
}
.custom-measure-grid-sm .custom-measure-field { min-width: 0; }
.custom-measure-grid-sm .custom-measure-field label { font-size: 10px; }
.custom-measure-grid-sm .custom-measure-field input {
  width: 72px;
  min-width: 0;
  box-sizing: border-box;
  padding: 3px 4px;
  font-size: 12px;
}

/* Add-item row + items table */
.custom-additem-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.custom-additem-row select { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid #cdd4e0; border-radius: 6px; font-size: 13px; }
.custom-additem-row .ts-wrapper { flex: 1; min-width: 0; }
.custom-additem-row input { width: 70px; padding: 6px 6px; border: 1px solid #cdd4e0; border-radius: 6px; font-size: 13px; }
.custom-item-type-pill { float: right; color: #3656a8; font-size: 11px; font-weight: 600; margin-left: 10px; }
.custom-items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.custom-items-table th { text-align: left; font-size: 12px; color: #6b7484; border-bottom: 1px solid #e2e6ee; padding: 3px 5px; }
.custom-items-table td { padding: 3px 5px; border-bottom: 1px solid #f0f2f6; }
.custom-items-table td:nth-child(3), .custom-items-table td:nth-child(4), .custom-items-table td:nth-child(5) { text-align: right; }
.custom-item-remove { color: #b42318; }
.custom-goto-draw-row { margin-top: 12px; display: flex; justify-content: flex-end; }
.item-master-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.item-group-bg-thumb {
  display: inline-flex;
  width: 34px;
  height: 34px;
  border: 1px solid #c6dce5;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.item-group-bg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#custom-order-preparation .custom-workshop-table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}
#custom-order-preparation .custom-workshop-table th,
#custom-order-preparation .custom-workshop-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#custom-order-preparation .custom-workshop-table th:last-child,
#custom-order-preparation .custom-workshop-table td:last-child {
  width: 42px;
  text-align: center;
}

.custom-prep-draw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.custom-prep-draw-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.custom-prep-draw-tools .draw-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #687790;
}
.custom-prep-draw-tools .small-button[aria-pressed="true"] {
  background: #1f6f8b;
  color: #fff;
}
/* Compact toolbar so all buttons fit one row on a tablet (drawing unchanged). */
.custom-prep-draw-tools { gap: 5px; }
.custom-prep-draw-tools .small-button {
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
}
.custom-prep-draw-tools .draw-tool { font-size: 11px; gap: 3px; }
.custom-prep-draw-tools input[type="range"] { width: 90px; }
.custom-prep-drawing-stage {
  position: relative;
  margin: 8px auto 0;
  border: 1px solid #e2e6ee;
  border-radius: 6px;
  background: #fff;
  /* Match Standard Size > Drawing Parts: full-width canvas with the drawing
     background's own aspect ratio, set in JS after the image loads. */
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1000 / 700;  /* landscape fallback before the image loads */
  overflow: hidden;
  touch-action: none;
}
.custom-prep-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}
.custom-prep-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.custom-prep-overlay path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.custom-prep-drawing-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8a93a3;
  font-size: 13px;
  padding: 24px;
  text-align: center;
}
.custom-prep-drawing-empty[hidden] {
  display: none;
}

.custom-workshop-panel { margin-top: 16px; width: 100%; min-width: 0; }
.custom-workshop-wrap { max-height: 260px; overflow: auto; }
.custom-workshop-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.custom-workshop-table th {
  text-align: left;
  color: #6b7484;
  border-bottom: 1px solid #e2e6ee;
  padding: 4px 6px;
}
.custom-workshop-table td {
  border-bottom: 1px solid #f0f2f6;
  padding: 4px 6px;
}
/* Custom Order workshop list (cols: actions, Job No, Garment, Size, Qty, Status).
   Scoped to this panel so it doesn't affect the preparation page's table. */
#customWorkshopPanel .custom-workshop-table th:first-child,
#customWorkshopPanel .custom-workshop-table td:first-child {
  width: 72px;
  text-align: left;
  white-space: nowrap;
}
#customWorkshopPanel .custom-workshop-table .custom-workshop-actions {
  text-align: left;
  white-space: nowrap;
}
#customWorkshopPanel .custom-workshop-table th:nth-child(2),
#customWorkshopPanel .custom-workshop-table td:nth-child(2) {
  width: 70px;
}
#customWorkshopPanel .custom-workshop-table th:nth-child(3),
#customWorkshopPanel .custom-workshop-table td:nth-child(3) {
  width: 70px;
}
#customWorkshopPanel .custom-workshop-table th:nth-child(4),
#customWorkshopPanel .custom-workshop-table td:nth-child(4) {
  width: 56px;
}
#customWorkshopPanel .custom-workshop-table th:nth-child(5),
#customWorkshopPanel .custom-workshop-table td:nth-child(5) {
  width: 34px;
  text-align: center;
}

.custom-items-wrap {
  max-height: 260px;
  border: 0;
  overflow: auto;
}

.custom-workshop-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}
.custom-workshop-prep-button {
  min-width: 32px;
  width: auto;
  height: 26px;
  padding: 2px 8px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d2a000;
  border-radius: 6px;
  background: #ffd75a;
  color: #473200;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.custom-workshop-prep-button:hover,
.custom-workshop-prep-button:focus {
  background: #ffc928;
}

@media (max-width: 1024px), (pointer: coarse) {
  .custom-workshop-prep-button {
    min-width: 44px;
    height: 36px;
    padding: 6px 14px;
    font-size: 15px;
    border-radius: 8px;
  }
}
.custom-prep-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

/* Preparation page: Customer spans the full top row; Measurements (left) and
   Workshop Record + Drawing (right) sit below so the drawing gets more space.
   Selectors mirror the generic .custom-order-grid nth-child rules so they win
   on specificity (defined later in the file). */
.custom-prep-grid {
  grid-template-columns: minmax(240px, 0.55fr) minmax(430px, 1.6fr);
  gap: 8px;
}
.custom-prep-grid > .custom-order-panel:nth-child(1) {
  grid-column: 1 / -1;
  order: 0;
}
.custom-prep-grid > .custom-order-panel:nth-child(2) { order: 1; }
.custom-prep-grid > .custom-order-panel:nth-child(3) { order: 2; }
.custom-prep-customer-panel .custom-prep-info {
  /* One compact row: 6 fields + a slightly wider Notes. */
  grid-template-columns: repeat(6, minmax(0, 1fr)) 1.5fr;
  gap: 6px;
}
.custom-prep-customer-panel .custom-prep-notes-field {
  grid-column: auto;
}
/* Smaller borders/text so the whole header fits one row on a tablet. */
.custom-prep-customer-panel .custom-prep-info div { padding: 3px 7px; }
.custom-prep-customer-panel .custom-prep-info span { font-size: 9px; }
.custom-prep-customer-panel .custom-prep-info strong { font-size: 11px; min-height: 13px; }
/* Hide the section headings on the prep page (Customer / Measurements /
   Workshop Record / Drawing) to claw back vertical space. */
.custom-prep-grid .custom-order-h3 {
  display: none;
}
/* Trim the gap between the header and the customer fields on the prep page. */
#custom-order-preparation .customer-header {
  padding: 6px 18px;
}
#custom-order-preparation .custom-prep-grid {
  margin-top: 8px;
}
#custom-order-preparation .custom-prep-customer-panel {
  padding-top: 8px;
}
/* First workshop panel no longer needs a top margin once its heading is gone. */
.custom-prep-grid > .custom-order-panel:nth-child(3) .custom-workshop-panel:first-child {
  margin-top: 0;
}

/* Compact measurements so the whole page fits one screen / one A4 sheet. */
.custom-prep-grid .custom-measure-grid-sm {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.custom-prep-grid .custom-prep-measure {
  padding: 3px 6px;
}
.custom-prep-grid .custom-prep-measure span { font-size: 10px; }
.custom-prep-grid .custom-prep-measure input { font-size: 12px; padding: 1px 4px; }
@media (max-width: 1100px) {
  .custom-prep-grid { grid-template-columns: 1fr; }
  .custom-prep-grid > .custom-order-panel:nth-child(1),
  .custom-prep-grid > .custom-order-panel:nth-child(2),
  .custom-prep-grid > .custom-order-panel:nth-child(3) { order: initial; }
  .custom-prep-customer-panel .custom-prep-info { grid-template-columns: repeat(6, minmax(0, 1fr)) 1.5fr; }
}
.custom-prep-info div,
.custom-prep-measure,
.custom-prep-notes {
  border: 1px solid #d9e7ee;
  background: #f9fcfd;
  border-radius: 6px;
  padding: 6px 8px;
}
.custom-prep-info span,
.custom-prep-measure span {
  display: block;
  color: #4c6280;
  font-size: 11px;
}
.custom-prep-info strong,
.custom-prep-measure strong {
  display: block;
  min-height: 18px;
  color: #002f45;
  font-size: 13px;
}
.custom-prep-measure-status {
  font-size: 11px;
  color: #4c6280;
  font-style: italic;
}
.custom-prep-measure input {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 2px 4px;
  border: 1px solid #c4d8e2;
  border-radius: 4px;
  color: #002f45;
  font-size: 13px;
}
.custom-prep-notes {
  min-height: 52px;
  white-space: pre-wrap;
}
.custom-prep-screen {
  display: none;
}
.custom-prep-screen:target {
  display: block;
}
body:has(.custom-prep-screen:target) .custom-prep-screen:target {
  display: block;
}

.custom-items-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.custom-items-table th,
.custom-items-table td {
  font-size: 13px;
}

.custom-items-table .supplier-po-col-row {
  width: 28px;
  max-width: 28px;
}

.custom-items-table .custom-pair-item-cell {
  width: auto;
  min-width: 0;
}

.custom-items-table .supplier-po-col-qty {
  width: 36px;
  max-width: 36px;
  text-align: center;
}

.custom-items-table .supplier-po-col-total {
  width: 50px;
  max-width: 50px;
  text-align: center;
}

.custom-items-table .supplier-po-delete-cell {
  width: 24px;
  max-width: 24px;
}

.custom-items-table .supplier-po-delete-row {
  min-width: 20px;
  min-height: 18px;
  padding: 0 3px;
  line-height: 1;
}

.custom-items-table .supplier-control {
  width: 100%;
  min-height: 24px;
  box-sizing: border-box;
  text-align: center;
}

.custom-items-table .ts-wrapper {
  width: 100%;
  min-width: 0;
}

.custom-items-table .ts-control {
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  background: transparent;
  box-shadow: none;
}

.custom-items-table .ts-control:focus-within {
  border-color: #8ba9df;
  background: #fff;
}

.custom-items-table .ts-dropdown {
  z-index: 9999;
  min-width: 320px;
}

.custom-items-table th:nth-child(1),
.custom-items-table td:nth-child(1) {
  width: 30px !important;
  max-width: 30px !important;
  text-align: center;
}

.custom-items-table th:nth-child(2),
.custom-items-table td:nth-child(2) {
  width: 40% !important;
  min-width: 0;
}

.custom-items-table th:nth-child(3),
.custom-items-table td:nth-child(3) {
  width: 58px !important;
  max-width: 58px !important;
  text-align: center;
}

.custom-items-table th:nth-child(4),
.custom-items-table td:nth-child(4) {
  width: 72px !important;
  max-width: 72px !important;
  text-align: center;
}

.custom-items-table th:nth-child(5),
.custom-items-table td:nth-child(5) {
  width: 72px !important;
  max-width: 72px !important;
  text-align: center;
}

.custom-items-table th:nth-child(6),
.custom-items-table td:nth-child(6) {
  width: 26px !important;
  max-width: 26px !important;
  text-align: center;
}

/* ----- My Account modal ----- */
.account-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 4px 4px;
}
.account-form label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
.account-form input {
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
}
.account-form input[readonly] {
  background: #f1f5f9;
  color: #64748b;
}
.account-section {
  margin: 10px 0 2px;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
  font-weight: 600;
  color: #475569;
}
.account-success {
  color: #15803d;
  font-size: 13px;
  min-height: 16px;
}
.account-actions {
  margin-top: 12px;
}
.account-actions .action-button {
  width: 100%;
}

#forgotPasswordResetFields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#forgotPasswordResetFields[hidden] {
  display: none !important;
}

/* ----- Top-right user menu (gear) ----- */
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
}
.topbar-right .current-user-summary {
  margin-left: 0;
}
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.user-menu[hidden] {
  display: none !important;
}

.user-menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.user-menu-button:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: 48px;
  min-width: 168px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  overflow: hidden;
  z-index: 1200;
}
.user-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
}
.user-menu-dropdown button:hover {
  background: #f1f5f9;
}
.user-menu-dropdown button.logout {
  color: #b91c1c;
  border-top: 1px solid #f1f5f9;
}

body.compact-header .topbar-right {
  gap: 8px;
}

body.compact-header .user-menu-button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

body.compact-header .user-menu-button svg {
  width: 16px;
  height: 16px;
}

body.compact-header .user-menu-dropdown {
  top: 36px;
}

/* Product Development */
.product-development-screen,
.product-development-detail-screen {
  width: min(100%, 1280px);
  display: none;
}

.pd-topbar,
.pd-detail-head,
.pd-actions,
.pd-filters,
.pd-markup-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pd-topbar,
.pd-detail-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.pd-topbar .customer-actions {
  margin-left: auto;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}

.pd-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(120px, 1fr));
  margin-bottom: 10px;
}

.pd-filters input,
.pd-filters select,
.pd-project-form input,
.pd-project-form select,
.pd-project-form textarea,
.pd-project-form .ts-control,
.pd-version-form input,
.pd-version-form select,
.pd-version-form textarea {
  width: 100%;
  min-height: 32px;
  border: 1px solid #9fb9c5;
  border-radius: 4px;
  background: #ffffff;
  padding: 6px 8px;
  color: #111827;
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.pd-project-form .ts-wrapper {
  width: 100%;
}

.pd-project-form .ts-control {
  min-height: 32px;
}

.pd-project-form .ts-control input {
  border: 0;
  box-shadow: none;
  min-height: 20px;
  padding: 0;
}

.pd-filters input:focus,
.pd-filters select:focus,
.pd-project-form input:focus,
.pd-project-form select:focus,
.pd-project-form textarea:focus,
.pd-project-form .ts-wrapper.focus .ts-control,
.pd-version-form input:focus,
.pd-version-form select:focus,
.pd-version-form textarea:focus {
  border-color: #17436c;
  outline: 2px solid rgba(23, 67, 108, 0.18);
  outline-offset: 1px;
}

.pd-panel {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
}

.pd-grid-wrap {
  max-height: 280px;
  overflow: auto;
}

.pd-table {
  min-width: 1120px;
}

.pd-table th,
.pd-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.pd-project-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 6px 8px;
  margin-bottom: 12px;
}

.pd-project-form label,
.pd-version-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pd-wide {
  grid-column: span 2;
}

.pd-workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 10px;
}

.pd-pages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pd-page-card {
  display: grid;
  grid-template-columns: minmax(0, 540px) minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
  align-items: start;
}

.pd-page-photo canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid #d4dde2;
  border-radius: 4px;
  display: block;
  cursor: zoom-in;
}

.pd-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.pd-zoom-overlay[hidden] {
  display: none;
}

.pd-zoom-overlay canvas {
  max-width: 96vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.pd-zoom-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.pd-page-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  border: 1px dashed #b6c6cf;
  border-radius: 4px;
  color: var(--muted);
  background: #f7fafb;
}

.pd-page-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pd-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pd-page-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pd-page-remarks {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pd-page-remarks textarea {
  width: 100%;
  border: 1px solid #9fb9c5;
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  color: #111827;
}

@media (max-width: 900px) {
  .pd-page-card {
    grid-template-columns: 1fr;
  }
}

.pd-item-list {
  border-right: 1px solid var(--border);
  padding-right: 10px;
}

.pd-item-list h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.pd-item-button,
.pd-version-tab {
  width: 100%;
  min-height: 34px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f8fafc;
  color: #20324a;
  text-align: left;
  padding: 6px 8px;
  cursor: pointer;
}

.pd-item-button.active,
.pd-version-tab.active {
  border-color: #17436c;
  background: #e8f0fb;
  font-weight: 700;
}

.pd-content-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  border-bottom: 1px solid #c9dbe4;
}

.pd-content-tab {
  min-height: 34px;
  border: 1px solid #9fb9c5;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #f3f8fb;
  color: #20324a;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}

.pd-content-tab.active {
  background: #ffffff;
  border-color: #17436c;
  color: #0d344f;
  font-weight: 700;
}

.pd-tab-panel {
  display: none;
}

.pd-tab-panel.active {
  display: block;
}

.pd-drawing-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.pd-drawing-toolbar .small-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pd-tab-hint {
  color: var(--muted);
  font-size: 12px;
}

.pd-drawing-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.pd-drawing-card {
  border: 1px solid #9fb9c5;
  border-radius: 4px;
  padding: 8px;
  background: #fbfcfe;
}

.pd-drawing-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid #c9dbe4;
  border-radius: 4px;
  background: #f3f6fa;
  margin-bottom: 8px;
}

.pd-version-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.pd-version-tab {
  width: auto;
  min-width: 92px;
}

.pd-version-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.pd-version-form label:nth-child(n+3) {
  grid-column: span 2;
}

.pd-files,
.pd-comments {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.pd-file-card,
.pd-comment-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  background: #fbfcfe;
}

.pd-file-card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.pd-file-card img {
  width: 84px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f3f6fa;
}

.pd-file-meta strong,
.pd-comment-card strong {
  display: block;
  color: #1f2f46;
}

.pd-file-meta small,
.pd-comment-card small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.pd-markup-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(18, 24, 32, 0.72);
  display: grid;
  place-items: center;
  padding: 18px;
}

.pd-markup-overlay[hidden] {
  display: none !important;
}

.pd-markup-panel {
  width: min(1100px, 96vw);
  height: min(760px, 92vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
  border-radius: 4px;
  border: 1px solid #d7dee8;
}

.pd-markup-toolbar {
  flex-wrap: wrap;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.pd-canvas-wrap {
  overflow: auto;
  display: grid;
  place-items: center;
  background: #eef2f7;
}

#pdMarkupCanvas {
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  cursor: crosshair;
}

@media (max-width: 900px) {
  .pd-filters,
  .pd-project-form,
  .pd-version-form,
  .pd-workspace {
    grid-template-columns: 1fr;
  }
  .pd-wide,
  .pd-version-form label:nth-child(n+3) {
    grid-column: auto;
  }
  .pd-item-list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 10px;
  }
  .pd-topbar,
  .pd-detail-head {
    align-items: stretch;
    flex-direction: column;
  }
  .pd-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  body.compact-header .topbar {
    flex-wrap: nowrap !important;
    gap: 8px;
    overflow: visible;
  }

  body.compact-header .topbar-right {
    min-width: 0;
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  body.compact-header .current-user-summary {
    width: auto;
    order: 0;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
  }

  body.compact-header .current-user-summary div {
    min-width: 0;
    max-width: 96px;
    padding-inline: 6px;
  }

  body.compact-header .current-user-summary div:not(:first-child) {
    display: none;
  }
}

/* --- Standard Size > Drawing Parts (master parts library) ---------------- */
.drawing-parts-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  background: rgba(0, 23, 38, 0.45);
  padding: 18px;
}
.drawing-parts-overlay[hidden] { display: none; }
.drawing-parts-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 40, 55, 0.25);
  overflow: hidden;
}
.drawing-parts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--brand);
  color: #fff;
}
.drawing-parts-header h2 { margin: 0; font-size: 18px; }
.drawing-parts-header-actions { display: flex; gap: 8px; align-items: center; }
.drawing-parts-header-divider {
  width: 1px;
  align-self: stretch;
  margin: 2px 4px;
  background: rgba(26, 49, 84, 0.18);
}
.drawing-parts-body {
  flex: 1;
  display: grid;
  grid-template-columns: 250px 1fr 280px;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
.drawing-parts-library,
.drawing-parts-props {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.drawing-parts-library-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
}
.drawing-parts-library-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 6px;
}
.drawing-parts-library-actions .small-button {
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  flex: 0 1 auto;
}
.drawing-parts-library-head h3,
.drawing-parts-props h3 { margin: 0 0 8px; font-size: 14px; color: var(--brand); }
.drawing-parts-props-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.drawing-parts-props-head h3 { margin: 0; }
.drawing-parts-props-head .small-button {
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}
.drawing-parts-props-actions .small-button,
.drawing-parts-header-actions .small-button:not(.exit-button) {
  padding: 3px 6px;
  font-size: 10px;
  white-space: nowrap;
  min-width: 0;
}
#drawingPartsSearch {
  width: 100%;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.drawing-parts-list { overflow: auto; flex: 1; }
.drawing-parts-cat { font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 8px 0 4px; }
.drawing-parts-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  background: #fff;
}
.drawing-parts-item:hover { background: var(--page); }
.drawing-parts-item.selected { border-color: var(--button-border); background: var(--button); }
.drawing-parts-item.inactive { opacity: 0.5; }
.drawing-parts-item-check {
  flex: none;
  margin: 0;
}
.drawing-parts-item img {
  width: 34px; height: 34px; object-fit: contain;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; flex: none;
}
.drawing-parts-item-text { min-width: 0; }
.drawing-parts-item-name { font-size: 13px; font-weight: 600; }
.drawing-parts-item-code,
.drawing-parts-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawing-parts-item-code { font-size: 11px; color: var(--muted); }
.drawing-parts-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  min-height: 0;
}
.drawing-parts-canvas {
  position: relative;
  width: min(100%, 840px);
  max-width: 100%;
  max-height: 100%;
  /* Landscape default; JS overrides this to the Drawing BG's real ratio. */
  aspect-ratio: 4 / 3;
  background: #fdfdfd;
  background-image: linear-gradient(45deg, #f0f3f8 25%, transparent 25%), linear-gradient(-45deg, #f0f3f8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f3f8 75%), linear-gradient(-45deg, transparent 75%, #f0f3f8 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
#drawingPartsBg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.drawing-parts-canvas-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); font-size: 13px; text-align: center; padding: 16px;
  pointer-events: none;
}
.drawing-parts-canvas-empty[hidden] { display: none; }
.drawing-parts-stage { position: absolute; inset: 0; }
.dp-placed {
  position: absolute;
  border: 1px dashed transparent;
  box-sizing: border-box;
  cursor: move;
  pointer-events: none;
}
.dp-placed.selected { pointer-events: auto; }
.dp-placed img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.dp-placed.selected { border-color: #6b7484; background: transparent; }
.dp-handle {
  position: absolute;
  width: 12px; height: 12px;
  background: var(--brand);
  border: 2px solid #fff;
  border-radius: 50%;
  display: none;
}
.dp-placed.selected .dp-handle { display: block; }
.dp-handle.resize { right: -7px; bottom: -7px; cursor: nwse-resize; }
.dp-handle.rotate { left: 50%; top: -22px; transform: translateX(-50%); cursor: grab; background: #2a8c4a; }
.drawing-parts-props-form { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.drawing-parts-props-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.drawing-parts-props-form input,
.drawing-parts-props-form select { font-size: 13px; }
.drawing-parts-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drawing-parts-check { flex-direction: row !important; align-items: center; gap: 6px !important; color: var(--text) !important; font-size: 12px; }
.drawing-parts-props-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.drawing-parts-props-empty,
.drawing-parts-canvas-empty { font-size: 12px; }
.small-button.delete-text { background: #f7d6d6; border-color: #df8b8b; }
@media (max-width: 900px) {
  .drawing-parts-body { grid-template-columns: 1fr; grid-auto-rows: minmax(160px, auto); }
}

/* --- Custom Order drawing: master parts layer + version tools ------------- */
.custom-prep-master-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.custom-prep-master-note {
  font-size: 11px;
  color: #8a5a00;
  background: #fff7e6;
  border: 1px solid #ffe2a8;
  border-radius: 6px;
  padding: 3px 8px;
}
.custom-prep-parts {
  position: absolute;
  inset: 0;
  pointer-events: none;  /* empty areas fall through to the freehand SVG */
}
.cop-part {
  position: absolute;
  pointer-events: none;  /* locked: only the selected part is interactive */
  box-sizing: border-box;
  border: 1px dashed transparent;
  cursor: move;
}
.cop-part.selected { pointer-events: auto; }
.cop-part img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.cop-part.selected { border-color: #2f6fb0; background: transparent; }
.cop-handle {
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  display: none;
  padding: 0;
}
.cop-part.selected .cop-handle { display: block; }
.cop-handle.resize { right: -8px; bottom: -8px; background: #2f6fb0; cursor: nwse-resize; }
.cop-handle.rotate { left: 50%; top: -26px; transform: translateX(-50%); background: #2a8c4a; cursor: grab; }
.cop-handle.remove {
  right: -8px; top: -8px; background: #c0392b; color: #fff;
  font-size: 11px; line-height: 1; border-radius: 50%; cursor: pointer;
}
.cop-addpart-overlay {
  position: fixed; inset: 0; z-index: 45;
  display: grid; place-items: center;
  background: rgba(0, 23, 38, 0.35);
}
.cop-addpart-overlay[hidden] { display: none; }
.cop-addpart-panel {
  width: min(520px, 94vw); max-height: 80vh; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 40, 55, 0.2); padding: 14px;
}
.cop-addpart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cop-addpart-list { display: block; }
.cop-addpart-cat {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); margin: 12px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--line);
}
.cop-addpart-cat:first-child { margin-top: 0; }
.cop-addpart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.cop-addpart-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer;
  font-size: 12px; text-align: center;
}
.cop-addpart-item:hover { background: var(--page); border-color: var(--button-border); }
.cop-addpart-item img { width: 48px; height: 48px; object-fit: contain; }
.cop-addpart-empty { color: var(--muted); font-size: 13px; padding: 8px; }
/* A part already placed on the drawing: greyed out and not clickable until it
   is deleted from the drawing (which unlocks it here). */
.cop-addpart-item.locked {
  cursor: not-allowed; opacity: 0.55; background: var(--page);
  border-style: dashed;
}
.cop-addpart-item.locked:hover { background: var(--page); border-color: var(--line); }
.cop-addpart-lock { font-size: 11px; color: var(--muted); font-weight: 600; }

/* Custom Order: row of added-part chips (click a name to select/move it) */
.custom-prep-parts-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  min-height: 26px;
}
.cop-chip-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.cop-chip-empty { font-size: 12px; color: var(--muted); }
.cop-chip {
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid var(--button-border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.cop-chip:hover { background: var(--page); }
.cop-chip.selected { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Part type shown inside a Custom Order part chip */
.cop-chip-type {
  font-size: 10px;
  opacity: 0.7;
  border-left: 1px solid currentColor;
  padding-left: 5px;
  margin-left: 3px;
}

/* ===================== Workshop KPI Dashboard ===================== */
#workshop-kpi .customer-header { align-items: flex-start; }
#workshop-kpi .customer-header > .utility-actions.customer-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  position: static;
  width: auto;
  min-width: 0;
  margin: 0;
  align-self: flex-start;
}
#workshop-kpi .utility-actions.customer-actions .small-button {
  white-space: nowrap;
  height: fit-content;
}
.kpi-filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 12px; align-items: end; }
.kpi-filters label { display: flex; flex-direction: column; font-size: 11px; gap: 3px; color: var(--muted, #555); min-width: 0; }
.kpi-filters input, .kpi-filters select { width: 100%; min-width: 0; box-sizing: border-box; }

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.kpi-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 9px;
  min-width: 0;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  cursor: default;
}
.kpi-card-drill { cursor: pointer; }
.kpi-card-drill:hover { border-color: var(--brand, #1565c0); box-shadow: 0 2px 8px rgba(0,0,0,0.10); }
.kpi-card-value { font-size: 19px; font-weight: 700; color: var(--text, #1a1a1a); line-height: 1.1; }
.kpi-card-label { font-size: 10px; color: var(--muted, #666); text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.15; }
.kpi-card-warn .kpi-card-value { color: #c62828; }

.kpi-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi-chart-card {
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
}
.kpi-chart-card h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--text, #222); }
.kpi-svg { width: 100%; height: auto; overflow: visible; }
.kpi-axis { stroke: #d0d0d0; stroke-width: 1; }
.kpi-chart-val { font-size: 10px; fill: #555; text-anchor: middle; }
.kpi-chart-lbl { font-size: 10px; fill: #777; text-anchor: middle; }
.kpi-donut-center { font-size: 20px; font-weight: 700; fill: var(--text, #222); text-anchor: middle; }
.kpi-legend text { font-size: 11px; fill: #555; }
.kpi-chart-empty { color: #999; font-size: 12px; padding: 30px 0; text-align: center; }

.kpi-ps-list { width: 100%; }
.kpi-ps-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; border-bottom: 1px solid var(--border, #eee);
  font-size: 13px; cursor: pointer;
}
.kpi-ps-row:hover { background: var(--page, #f4f7fb); }
.kpi-ps-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
.kpi-ps-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-ps-qty { flex: 0 0 auto; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-ps-total { margin-top: 10px; padding-top: 8px; border-top: 2px solid var(--border, #e0e0e0); font-size: 13px; }
.kpi-ps-total strong { font-size: 16px; color: var(--text, #1a1a1a); }

/* Today's Production panel */
.kpi-tp-sub { font-size: 10px; font-weight: 500; color: var(--muted, #888); text-transform: none; letter-spacing: 0; }
.kpi-tp-list { width: 100%; }
.kpi-tp-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--border, #eee); font-size: 13px; }
.kpi-tp-clickable { cursor: pointer; }
.kpi-tp-clickable:hover { background: var(--page, #f4f7fb); }
.kpi-tp-clickable .kpi-tp-name { color: var(--brand, #1565c0); }
.kpi-tp-icon { flex: 0 0 auto; width: 18px; text-align: center; }
.kpi-tp-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted, #555); }
.kpi-tp-val { flex: 0 0 auto; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text, #1a1a1a); }
.kpi-tp-good { color: #1b5e20; }
.kpi-tp-warn { color: #c62828; }
.kpi-tp-eff { padding: 1px 8px; border-radius: 10px; }

.kpi-tabs { margin-bottom: 8px; }
.kpi-drill-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--brand, #1565c0); text-decoration: underline; font: inherit;
}
.kpi-perf { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.kpi-perf-green { background: #e6f4ea; color: #1b5e20; }
.kpi-perf-blue { background: #e3f0fb; color: #0d47a1; }
.kpi-perf-yellow { background: #fdf3d7; color: #8a6d00; }
.kpi-perf-red { background: #fde5e5; color: #b71c1c; }

@media print {
  body:has(#workshop-kpi:target) * { visibility: hidden; }
  body:has(#workshop-kpi:target) #workshop-kpi,
  body:has(#workshop-kpi:target) #workshop-kpi * { visibility: visible; }
  body:has(#workshop-kpi:target) #workshop-kpi { position: absolute; left: 0; top: 0; width: 100%; }
  .kpi-filters, .utility-actions, .kpi-tabs { display: none !important; }
  .kpi-card-drill { cursor: default; }
}

/* ── System Health & Recovery (Admin monitoring page) ─────────────────────── */
.system-health-body { padding: 12px 18px 24px; max-width: 1180px; margin: 0 auto; }
.system-health-loading { color: #667; padding: 18px 4px; }
.sh-overall { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 10px; margin-bottom: 14px; border: 1px solid #d8dee6; background: #f7f9fb; }
.sh-overall .sh-dot { width: 16px; height: 16px; }
.sh-overall-status { font-size: 1.05rem; font-weight: 700; }
.sh-overall-sub { font-size: 0.8rem; color: #667; }
.sh-overall-ok { border-color: #bfe3c6; background: #f2faf3; }
.sh-overall-warn { border-color: #f0dfae; background: #fdf9ec; }
.sh-overall-bad { border-color: #f0b9b9; background: #fdf1f1; }
.sh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.sh-card { border: 1px solid #d8dee6; border-radius: 10px; background: #fff; padding: 12px 14px; }
.sh-card h3 { margin: 0 0 8px; font-size: 0.92rem; border-bottom: 1px solid #eef1f5; padding-bottom: 6px; }
.sh-row { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 0.84rem; }
.sh-label { color: #556; flex: 0 0 46%; }
.sh-value { font-weight: 600; word-break: break-word; }
.sh-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; align-self: center; background: #b8c0cb; }
.sh-ok { background: #2e9e44; }
.sh-warn { background: #e0a800; }
.sh-bad { background: #d64545; }
.sh-unknown { background: #b8c0cb; }

/* ---- Workshop Capacity & Schedule Planner ---- */
.ws-schedule-filters { flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.ws-schedule-filters label { display: flex; flex-direction: column; font-size: 12px; color: #103f52; gap: 2px; }
.ws-schedule-filters input, .ws-schedule-filters select { min-height: 30px; }

.ws-capacity-editor { display: inline-flex; align-items: flex-end; gap: 6px; margin-right: 10px; }
.ws-capacity-editor label { display: flex; flex-direction: column; font-size: 12px; color: #103f52; gap: 2px; }
.ws-capacity-editor input { width: 90px; min-height: 30px; }

.ws-schedule-legend { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.ws-badge { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }

.ws-status-available { background: #d9f2df; color: #1c6b31; }
.ws-status-nearfull { background: #fdf3d1; color: #8a6d00; }
.ws-status-overloaded { background: #fadcdc; color: #a02323; }
.ws-status-atrisk { background: #ecdcf7; color: #6b2f91; }
.ws-status-nocapacity { background: #e6e9ee; color: #4a5561; }

tr.ws-row-available td { background: #f2fbf4; }
tr.ws-row-nearfull td { background: #fffbe8; }
tr.ws-row-overloaded td { background: #fdf0f0; }
tr.ws-row-clickable { cursor: pointer; }
tr.ws-row-clickable:hover td { filter: brightness(0.96); }

.ws-schedule-detail { margin-top: 14px; border-top: 2px solid #b9d7e4; padding-top: 10px; }
.ws-schedule-detail-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ws-schedule-detail-header h2 { margin: 0; color: #103f52; font-size: 18px; }

.ws-transfer-card {
    width: 860px; max-width: 94vw; max-height: 88vh; overflow: auto;
    background: #ffffff; border: 1px solid #b9d7e4; border-radius: 12px;
    padding: 16px 18px 18px; box-shadow: 0 18px 45px rgba(23, 67, 108, 0.25);
}
.ws-transfer-card h2 { margin: 0 0 8px; color: #103f52; }
.ws-transfer-card h3 { margin: 12px 0 6px; color: #103f52; font-size: 14px; }
.ws-transfer-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }
.ws-transfer-actions label { display: flex; flex-direction: column; font-size: 12px; color: #103f52; gap: 2px; }
.ws-transfer-dates, .ws-transfer-moves, .ws-transfer-buckets { max-height: 240px; overflow: auto; }
.ws-warning-line { background: #fdf3d1; border-left: 4px solid #e0a800; padding: 6px 10px; margin: 4px 0; font-size: 13px; color: #5c4a00; }
.ws-warning-line.ws-warning-bad { background: #fadcdc; border-left-color: #d64545; color: #7a1c1c; }

.ws-back-button { white-space: nowrap; align-self: flex-start; }
.ws-schedule-toolbar { display: flex; justify-content: flex-end; align-items: flex-end; gap: 8px; margin: 6px 0 2px; }
.ws-schedule-toolbar .ws-capacity-editor { margin-right: 0; }

/* --- Bulk Item Delivery (Customer PO delivery data) --- */
#poBulkDeliverySection { margin-top: 6px; }
#poBulkDeliverySection .bulk-delivery-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
#poBulkDeliverySection .bulk-delivery-status { min-height: 18px; font-size: 12.5px; margin: 2px 0 6px; }
#poBulkDeliverySection { min-width: 0; max-width: 100%; }
#poBulkDeliverySection table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 12.5px; }
#poBulkDeliverySection th, #poBulkDeliverySection td { border: 1px solid #c6ccd4; padding: 3px 6px; text-align: left; }
#poBulkDeliverySection th { background: #eef1f5; font-weight: 600; }
#poBulkDeliverySection .bulk-delivery-draft { max-height: 260px; overflow: auto; }
#poBulkDeliverySection .bulk-delivery-notes { max-height: 180px; overflow: auto; }
#poBulkDeliverySection input, #poBulkDeliverySection select { font: inherit; }
#po-delivery.bulk-fulfillment .delivery-left { display: contents; }
#po-delivery.bulk-fulfillment .delivery-left-top { grid-column: 1; }
#po-delivery.bulk-fulfillment #poBulkDeliverySection { grid-column: 1 / -1; }
#po-delivery.bulk-fulfillment .delivery-right { grid-column: 2; grid-row: 1; }
#po-delivery.bulk-fulfillment .uniform-panel { display: none; }
.delivery-popup-panel {
  width: min(760px, 96vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.delivery-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.delivery-popup-head h2 {
  margin: 0;
}
.delivery-popup-head .exit-button {
  align-self: flex-start;
  margin-top: -8px;
}
.delivery-popup-panel .bulk-delivery-notes {
  overflow: auto;
}
.delivery-popup-panel .bulk-delivery-notes table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.delivery-popup-panel .bulk-delivery-notes th,
.delivery-popup-panel .bulk-delivery-notes td {
  border: 1px solid #c6ccd4;
  padding: 4px 6px;
  text-align: left;
}
.delivery-popup-panel .bulk-delivery-notes th {
  background: #eef1f5;
  font-weight: 600;
}
.remaining-po-popup-panel {
  width: min(560px, 94vw);
}
.remaining-po-popup-panel .remaining-po-grid {
  max-height: 62vh;
  overflow: auto;
}
.bulk-print-mode-panel {
  width: min(360px, 92vw);
}
.bulk-print-mode-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 14px;
}
.bulk-print-mode-actions .small-button {
  min-height: 42px;
  font-weight: 700;
}

/* Keep the PO delivery left column from growing past its grid track:
   without an explicit column, the implicit auto track sizes to the widest
   child's max-content and overlaps the right column. */
.delivery-left { grid-template-columns: minmax(0, 1fr); }
.delivery-left-top { max-width: 100%; }
