.materials-module {
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* RC548: user-defined categories and category-scoped QR printing. */
.material-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.material-category-row .material-category-tabs {
  flex: 1 1 auto;
  min-width: 0;
}

.material-category-create {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.material-category-create input {
  width: 140px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #cfd7e6;
  border-radius: 8px;
}

.material-category-create button {
  min-height: 34px;
  border: 1px solid #2f6fed;
  border-radius: 8px;
  color: #1f5fd6;
  background: #f4f8ff;
  font-weight: 800;
}

.material-qr-category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 2px;
  scrollbar-width: thin;
}

.material-qr-category-tabs button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid #d6deea;
  border-radius: 999px;
  color: #475467;
  background: #fff;
  font-weight: 800;
}

.material-qr-category-tabs button.active {
  border-color: #2f6fed;
  color: #175cd3;
  background: #eef4ff;
}

.material-qr-category-tabs button span {
  margin-left: 3px;
  color: #667085;
  font-size: 11px;
}

@media (max-width: 760px) {
  .material-category-row { align-items: stretch; flex-direction: column; }
  .material-category-create input { flex: 1 1 auto; width: auto; }
  .qr-generate-band form { grid-template-columns: 1fr 1fr; }
}

.materials-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  border: 1px solid #d9e2f1;
  border-radius: 8px;
  padding: 12px 14px;
  background: #eef4ff;
}

.materials-toolbar > div:first-child {
  min-width: 0;
}

.materials-toolbar h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.materials-toolbar p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.materials-view-tabs {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid #cdd9ee;
  border-radius: 8px;
  padding: 3px;
  background: #fff;
}

.materials-view-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  border-color: transparent;
  padding: 0 12px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.materials-view-tabs button.active {
  border-color: #bfd0ff;
  color: #1746aa;
  background: #e9f0ff;
}

.materials-view-tabs button span {
  min-width: 20px;
  border-radius: 8px;
  padding: 2px 5px;
  color: #344054;
  background: #edf1f7;
  font-size: 11px;
}

.material-qr-view-tabs {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 5px;
  max-width: 100%;
  border: 1px solid #d7e0ef;
  border-radius: 8px;
  padding: 4px;
  background: #fff;
}

.material-qr-view-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 112px;
  min-height: 34px;
  border-color: transparent;
  padding: 0 12px;
  background: transparent;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.material-qr-view-tabs button.active {
  border-color: #bfd0ff;
  color: #1746aa;
  background: #e9f0ff;
}

.material-qr-view-tabs button span {
  min-width: 20px;
  border-radius: 8px;
  padding: 2px 5px;
  color: #344054;
  background: #edf1f7;
  font-size: 11px;
}

.materials-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.materials-metrics > div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  min-height: 72px;
  border-left: 3px solid #2563eb;
  padding: 13px 14px;
}

.materials-metrics > div:nth-child(2) {
  border-left-color: #ea580c;
}

.materials-metrics > div:nth-child(3) {
  border-left-color: #087f5b;
}

.materials-metrics > div:nth-child(4) {
  border-left-color: #667085;
}

.materials-metrics > div:nth-child(5) {
  border-left-color: #b54708;
}

.materials-metrics > div:nth-child(6) {
  border-left-color: #7a5af8;
}

.materials-metrics span {
  margin-right: auto;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.materials-metrics strong {
  font-size: 23px;
  line-height: 1;
}

.materials-metrics small {
  color: var(--muted);
  font-size: 11px;
}

.materials-notice {
  border: 1px solid #a6f4c5;
  border-left: 4px solid var(--success);
  border-radius: 8px;
  padding: 10px 12px;
  color: #05603a;
  background: #ecfdf3;
  font-size: 13px;
  font-weight: 700;
}

.materials-notice.error {
  border-color: #fecdca;
  border-left-color: var(--danger);
  color: #b42318;
  background: #fef3f2;
}

.materials-content {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.finished-product-create-band {
  display: grid;
  gap: 10px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 2px 0 12px;
}

.finished-product-create-band > header,
.recipe-config-section > header,
.recipe-completion-section > header,
.deduction-history > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.finished-product-create-band h3,
.recipe-config-section h4,
.recipe-completion-section h4,
.deduction-history h4 {
  margin: 0;
  color: #27364d;
  font-size: 15px;
}

.finished-product-create-band header span,
.recipe-config-section header span,
.recipe-completion-section header span {
  color: var(--muted);
  font-size: 11px;
}

.finished-product-create-band form {
  display: grid;
  grid-template-columns: minmax(160px, .65fr) minmax(210px, 1fr) minmax(280px, 1.45fr) auto;
  align-items: end;
  gap: 9px;
}

.finished-product-create-band label,
.recipe-create-form label,
.recipe-completion-form label,
.recipe-material-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.finished-product-create-band input,
.finished-product-create-band select,
.recipe-create-form input,
.recipe-create-form select,
.recipe-completion-form input,
.recipe-material-row input {
  min-height: 38px;
  font-size: 13px;
}

.finished-product-create-band button,
.recipe-create-form > button,
.recipe-completion-form > button {
  min-height: 38px;
  white-space: nowrap;
}

.finished-product-filterbar {
  display: grid;
  grid-template-columns: minmax(300px, 1.6fr) minmax(170px, .7fr) minmax(170px, .7fr) auto auto;
  align-items: end;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #dbe3ef;
  border-radius: 7px;
  background: #f8fafc;
}

.finished-product-filterbar label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.finished-product-filterbar input,
.finished-product-filterbar select,
.finished-product-filterbar button {
  width: 100%;
  min-height: 38px;
  font-size: 13px;
}

.finished-product-filterbar button {
  width: auto;
  min-width: 68px;
}

.finished-product-result-count {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 8px;
  color: #475467;
  font-size: 12px;
  white-space: nowrap;
}

.recipe-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  min-width: 0;
  height: clamp(520px, calc(100vh - 270px), 760px);
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: var(--surface);
}

.finished-product-list {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 9px;
  background: #f7f9fc;
}

.finished-product-list button {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 76px;
  border-color: transparent;
  padding: 8px;
  background: transparent;
  text-align: left;
}

.finished-product-list button:hover {
  border-color: #d6e0ef;
  background: #fff;
}

.finished-product-list button.active {
  border-color: #a9c1f6;
  color: #1746aa;
  background: #eaf1ff;
}

.finished-product-thumbnail {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 1px solid #e1e7ef;
  border-radius: 6px;
  color: #98a2b3;
  background: #fff;
  font-size: 10px;
}

.finished-product-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.finished-product-thumbnail.large {
  flex: 0 0 68px;
  width: 68px;
  height: 68px;
}

.finished-product-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.finished-product-copy strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finished-product-copy > span,
.finished-product-copy small {
  min-width: 0;
  overflow: hidden;
  color: #667085;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finished-product-copy small {
  color: #7b879b;
  font-size: 10px;
}

.finished-product-recipe-count {
  align-self: center;
  color: #7b879b;
  font-size: 10px;
  white-space: nowrap;
}

.recipe-detail {
  display: grid;
  align-content: start;
  min-width: 0;
  overflow-y: auto;
}

.recipe-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfe;
}

.recipe-product-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.recipe-product-identity > div {
  min-width: 0;
}

.recipe-product-identity > div > span {
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
}

.recipe-product-identity > div > small {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
}

.recipe-detail-header h3 {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.finished-product-link-control {
  display: grid;
  flex: 1 1 320px;
  gap: 5px;
  max-width: 460px;
  min-width: 240px;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.finished-product-link-control select {
  width: 100%;
  min-height: 38px;
  font-size: 12px;
}

.recipe-output-count {
  display: flex;
  align-items: baseline;
  flex: 0 0 auto;
  gap: 5px;
  color: #475467;
}

.recipe-output-count span,
.recipe-output-count small {
  font-size: 10px;
}

.recipe-output-count strong {
  color: #087f5b;
  font-size: 22px;
}

.recipe-config-section,
.recipe-completion-section,
.deduction-history {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.recipe-create-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(150px, .7fr) auto;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d9e4f5;
  border-radius: 6px;
  background: #f5f8fd;
}

.recipe-material-list {
  display: grid;
  min-width: 0;
  border: 1px solid #e1e7ef;
  border-radius: 6px;
}

.recipe-material-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.25fr) minmax(90px, .65fr) minmax(120px, .8fr) minmax(95px, .7fr) auto;
  align-items: end;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border-bottom: 1px solid #e7ebf1;
}

.recipe-material-row:last-child {
  border-bottom: 0;
}

.recipe-material-name,
.recipe-material-row > div:not(.recipe-row-actions) {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 38px;
}

.recipe-material-name strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-material-name span,
.recipe-material-row > div > span {
  color: var(--muted);
  font-size: 10px;
}

.recipe-material-row > div > strong {
  color: #344054;
  font-size: 13px;
}

.recipe-row-actions {
  display: flex;
  gap: 5px;
}

.recipe-row-actions button {
  min-height: 38px;
  padding: 0 9px;
  font-size: 11px;
}

.recipe-row-actions .danger-text {
  border-color: #fecdca;
  color: #b42318;
  background: #fff;
}

.recipe-empty-row {
  padding: 24px 16px;
  color: #7b879b;
  font-size: 12px;
  text-align: center;
}

.recipe-empty-row.compact {
  padding: 14px;
}

.recipe-completion-section {
  background: #fffaf3;
}

.recipe-completion-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, .7fr) auto;
  align-items: end;
  gap: 8px;
}

.completion-button {
  border-color: #ea580c;
  color: #fff;
  background: #ea580c;
  font-weight: 700;
}

.completion-button:hover {
  background: #c94b08;
}

.deduction-history {
  border-bottom: 0;
}

.deduction-history > div {
  display: grid;
  min-width: 0;
  border: 1px solid #e1e7ef;
  border-radius: 6px;
}

.material-deduction-row {
  display: grid;
  grid-template-columns: minmax(160px, .9fr) minmax(90px, .45fr) minmax(220px, 1.65fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border-bottom: 1px solid #e7ebf1;
}

.material-deduction-row:last-child {
  border-bottom: 0;
}

.material-deduction-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.material-deduction-row strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-deduction-row span {
  color: #667085;
  font-size: 10px;
}

.deduction-materials {
  display: flex !important;
  flex-wrap: wrap;
  gap: 5px !important;
}

.deduction-materials span {
  border: 1px solid #cfe8dc;
  border-radius: 6px;
  padding: 3px 6px;
  color: #176b49;
  background: #f0faf5;
  font-size: 10px;
  font-weight: 700;
}

.deduction-materials .deduction-flow {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.deduction-flow strong {
  color: #344054;
}

.deduction-flow em {
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
  font-style: normal;
  white-space: nowrap;
}

.deduction-flow .inbound {
  color: #9a3412;
  background: #ffedd5;
}

.deduction-flow .outbound {
  color: #155e75;
  background: #cffafe;
}

.materials-filter-band,
.qr-generate-band {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 2px 0 12px;
}

.material-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.material-category-tabs button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 700;
}

.material-category-tabs button.active {
  border-color: #2563eb;
  color: #1746aa;
  background: #eef4ff;
}

.materials-filter-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex: 0 1 520px;
  gap: 8px;
  min-width: 0;
}

.materials-search,
.materials-sort {
  display: grid;
  gap: 4px;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.materials-search {
  flex: 1 1 280px;
  min-width: 220px;
}

.materials-sort {
  flex: 0 0 168px;
  min-width: 0;
}

.materials-search input,
.materials-sort select {
  min-height: 36px;
  font-size: 13px;
}

.material-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.material-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  min-height: 112px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: var(--surface);
}

.material-image {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 110px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #f6f8fb;
  place-items: center;
}

.material-image img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
}

.material-image-preview-button {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
  place-items: center;
}

.material-image-preview-button:hover {
  background: #eef4ff;
}

.material-image-preview-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .28);
  outline-offset: -3px;
}

.material-image-preview-button img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.material-card-body {
  display: grid;
  grid-template-columns: minmax(135px, 0.65fr) minmax(165px, 0.8fr) minmax(300px, 1.6fr) auto;
  grid-template-areas: "material-created material-title material-details material-actions";
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 10px 12px;
}

.material-card-created {
  grid-area: material-created;
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  border-right: 1px solid var(--line);
  padding-right: 12px;
}

.material-card-created span {
  color: var(--muted);
  font-size: 11px;
}

.material-card-created strong {
  overflow-wrap: anywhere;
  color: #667085;
  font-size: 12px;
  font-weight: 500;
}

.material-card-body header {
  grid-area: material-title;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.material-card-body header > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.material-card-body header strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

.material-card-body header span:not(.material-qr-state) {
  color: var(--muted);
  font-size: 11px;
}

.material-qr-state,
.material-success-badge {
  flex: 0 0 auto;
  border: 1px solid #a6f4c5;
  border-radius: 8px;
  padding: 3px 7px;
  color: #067647;
  background: #ecfdf3;
  font-size: 11px;
  font-weight: 700;
}

.material-card dl,
.bound-material-summary dl {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
}

.material-card dl {
  grid-area: material-details;
  grid-template-columns: repeat(4, minmax(84px, 1fr));
  align-items: stretch;
  gap: 0;
}

.material-card dl > div,
.bound-material-summary dl > div {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.material-card dl > div {
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 4px;
  border-left: 1px solid var(--line);
  padding: 2px 12px;
}

.material-card dt,
.bound-material-summary dt {
  color: var(--muted);
  font-size: 11px;
}

.material-card dd,
.bound-material-summary dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-card dl > .material-card-emphasis dt {
  color: #475467;
  font-size: 12px;
}

.material-card dl > .material-card-emphasis dd {
  color: #172033;
  font-size: 14px;
}

.material-card dl > .material-card-emphasis dd.material-stock-quantity {
  color: var(--success);
}

.material-card dl > .material-card-emphasis dd.material-stock-quantity.low,
.material-card dl > .material-card-emphasis dd.material-stock-limit.low {
  color: #d92d20;
}

.material-card dl > .material-card-emphasis dd.material-stock-quantity.high,
.material-card dl > .material-card-emphasis dd.material-stock-limit.high {
  color: #b54708;
}

.material-card dl > .material-card-emphasis dd.material-stock-limit {
  color: #0f766e;
  font-size: 13px;
}

.material-card dl > .material-card-emphasis dd.material-shelf-location {
  color: var(--danger);
}

.material-card dl > .material-card-muted dt,
.material-card dl > .material-card-muted dd {
  color: var(--muted);
}

.material-card dl > .material-card-muted dd {
  font-weight: 500;
}

.material-card-products dd {
  overflow: visible;
}

.material-product-count-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 30px;
  border-color: #b9d2ff;
  padding: 0 10px;
  color: #175cd3;
  background: #eff6ff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.material-product-count-button:hover:not(:disabled) {
  border-color: #84adff;
  background: #dbeafe;
}

.material-product-count-button:disabled {
  border-color: #e4e7ec;
  color: #98a2b3;
  background: #f9fafb;
  cursor: default;
  opacity: 1;
}

.material-card footer,
.material-entry-form footer,
.material-page-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.material-card footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 78px;
  min-height: 36px;
  padding: 0 9px;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.material-card footer {
  grid-area: material-actions;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
}

.material-card footer button.danger {
  border-color: #fda29b;
  color: #b42318;
  background: #fff5f4;
}

.materials-empty,
.material-state-panel {
  display: grid;
  gap: 7px;
  min-height: 180px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  background: #fbfcfe;
  text-align: center;
  place-content: center;
}

.materials-empty strong,
.material-state-panel strong {
  color: #344054;
  font-size: 15px;
}

.materials-empty span,
.material-state-panel p {
  margin: 0;
  font-size: 12px;
}

.material-state-panel.error {
  border-color: #fda29b;
  color: #b42318;
  background: #fff7f6;
}

.material-state-panel button {
  justify-self: center;
  margin-top: 8px;
}

.qr-generate-band {
  align-items: flex-end;
}

.qr-list-heading {
  display: grid;
  gap: 3px;
}

.qr-list-heading strong {
  font-size: 15px;
}

.qr-list-heading span {
  color: var(--muted);
  font-size: 11px;
}

.qr-generate-band form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.qr-generate-band label {
  display: grid;
  gap: 4px;
  width: 150px;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.qr-generate-band input,
.qr-generate-band button {
  min-height: 38px;
}

.qr-batch-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-width: 0;
}

.qr-batch-actions > label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-height: 38px;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  padding: 0 10px;
  color: #344054;
  background: #fff;
  cursor: pointer;
}

.qr-batch-actions input,
.qr-card-selector input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: #2563eb;
}

.qr-batch-actions > span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.material-qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
  min-width: 0;
}

.material-qr-card {
  position: relative;
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 11px;
  background: var(--surface);
  text-align: center;
}

.qr-card-selector {
  position: absolute;
  z-index: 1;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 4px 6px;
  color: #344054;
  background: rgba(255, 255, 255, .96);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.qr-card-visuals {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.qr-svg,
.dialog-qr-svg {
  display: grid;
  width: min(100%, 180px);
  aspect-ratio: 1;
  margin: 0 auto 4px;
  place-items: center;
}

.qr-card-visuals .qr-svg {
  flex: 0 1 180px;
  min-width: 0;
}

.bound-qr-material-image {
  position: relative;
  display: grid;
  flex: 0 1 150px;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  place-items: center;
}

.bound-qr-material-image img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
}

.qr-svg svg,
.dialog-qr-svg svg {
  display: block;
  width: 100%;
  height: 100%;
}

.material-qr-card > strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.material-qr-card > span {
  justify-self: center;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 2px 7px;
  color: #c2410c;
  background: #fff7ed;
  font-size: 10px;
  font-weight: 700;
}

.material-qr-card > span.downloaded {
  border-color: #bfdbfe;
  color: #1d4ed8;
  background: #eff6ff;
}

.material-qr-card > span.bound {
  border-color: #a6f4c5;
  color: #067647;
  background: #ecfdf3;
}

.material-qr-card > small {
  color: var(--muted);
  font-size: 10px;
}

.qr-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 5px;
}

.qr-card-actions button {
  min-width: 0;
  min-height: 32px;
  padding: 0 6px;
  font-size: 11px;
}

.qr-card-actions button:first-child {
  grid-column: 1 / -1;
  border-color: #bfd0ff;
  color: #1746aa;
  background: #eef4ff;
  font-weight: 700;
}

.material-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.material-pagination span {
  color: var(--muted);
  font-size: 12px;
}

.materials-module button:disabled {
  cursor: not-allowed;
}

.material-form-page {
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: var(--surface);
}

.material-form-page > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  background: #f7f9fc;
}

.material-form-page > header div {
  min-width: 0;
}

.material-form-page > header span {
  color: var(--muted);
  font-size: 11px;
}

.material-form-page h3 {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.material-entry-form {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px 12px;
  max-width: none;
  padding: 18px;
}

.material-entry-form > label,
.material-limit-pair label {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.material-entry-form > label {
  flex: 0 0 220px;
}

.material-limit-pair {
  display: grid;
  flex: 0 0 250px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.material-entry-form > label > span small,
.material-limit-pair label > span small {
  margin-left: 6px;
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}

.material-entry-form input,
.material-entry-form select,
.material-limit-pair input {
  min-height: 40px;
  font-size: 13px;
}

.material-entry-form input[readonly] {
  color: #475467;
  background: #f2f4f7;
}

.material-photo-field {
  flex: 0 0 260px;
  width: 260px;
}

.material-photo-dropzone {
  position: relative;
  display: grid;
  height: 160px;
  overflow: hidden;
  border: 1px dashed #98a2b3;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  place-items: center;
}

.material-photo-dropzone.dragging {
  border-color: #2563eb;
  background: #eef4ff;
}

.material-photo-dropzone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.material-photo-preview {
  position: absolute;
  inset: 0;
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #475467;
  text-align: center;
}

.material-photo-preview strong {
  font-size: 13px;
}

.material-photo-preview small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.material-photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
}

.material-entry-form footer {
  flex: 0 0 100%;
  justify-content: flex-start;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.bound-material-summary {
  display: grid;
  grid-template-columns: minmax(220px, 34%) minmax(0, 1fr);
  gap: 20px;
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}

.bound-material-image {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  place-items: center;
}

.bound-material-image img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
}

.bound-material-summary > div:last-child {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.bound-material-summary h3 {
  margin: 0;
  font-size: 24px;
}

.material-success-badge {
  justify-self: start;
}

.material-page-actions {
  justify-content: flex-start;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.material-qr-dialog,
.material-products-dialog,
.material-edit-dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(16, 24, 40, .2);
}

.material-products-dialog {
  width: min(720px, calc(100vw - 28px));
}

.material-qr-dialog::backdrop,
.material-products-dialog::backdrop,
.material-edit-dialog::backdrop {
  background: rgba(16, 24, 40, .45);
}

.material-qr-dialog-body {
  display: grid;
  gap: 12px;
  padding: 18px;
  text-align: center;
}

.material-qr-dialog-body > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  text-align: left;
}

.material-qr-dialog-body header span,
.material-qr-dialog-body > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.material-qr-dialog-body h3 {
  margin: 3px 0 0;
  font-size: 19px;
}

.material-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  font-family: Arial, sans-serif;
  font-size: 22px;
  line-height: 1;
}

.dialog-qr-svg {
  width: min(100%, 260px);
}

.material-qr-dialog-body > strong {
  font-size: 16px;
}

.material-qr-dialog-body > footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.material-edit-dialog {
  width: min(690px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
}

.material-edit-dialog-body {
  display: grid;
  gap: 14px;
  max-height: calc(100dvh - 30px);
  padding: 18px;
  overflow: auto;
}

.material-edit-dialog-body > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.material-edit-dialog-body > header span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.material-edit-dialog-body h3 {
  margin: 3px 0 0;
  font-size: 19px;
}

.material-edit-dialog .material-entry-form {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 0 0;
}

.material-edit-dialog .material-photo-field {
  width: 220px;
  flex-basis: 220px;
}

.material-edit-dialog .material-edit-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 126px));
  align-content: start;
  gap: 18px 8px;
  min-width: 0;
}

.material-edit-dialog .material-edit-fields > label,
.material-edit-dialog .material-edit-fields .material-limit-pair {
  align-self: start;
  flex: initial;
  min-width: 0;
}

.material-edit-dialog .material-edit-fields > label > span,
.material-edit-dialog .material-edit-fields .material-limit-combined > span {
  display: flex;
  align-items: center;
  min-height: 18px;
  line-height: 18px;
}

.material-edit-dialog .material-edit-fields > label input {
  min-height: 36px;
  height: 36px;
}

.material-edit-dialog .material-edit-fields .material-limit-pair {
  display: grid;
  grid-column: span 2;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.material-edit-dialog .material-edit-fields .material-limit-combined {
  align-content: start;
  grid-template-columns: 1fr;
  gap: 6px;
  width: min(100%, 244px);
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.material-edit-dialog .material-edit-fields .material-limit-combined > span small {
  margin-left: 6px;
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}

.material-edit-dialog .material-edit-fields .material-limit-combined-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.material-edit-dialog .material-edit-fields .material-limit-combined-control input {
  width: 100%;
  min-height: 36px;
  height: 36px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.material-edit-dialog .material-edit-fields .material-limit-combined-control i {
  display: block;
  width: 1px;
  height: 22px;
  background: #dbe3ef;
}

.material-edit-dialog .material-edit-fields footer {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.material-current-stock {
  display: block;
  color: #16a34a !important;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
}

.material-edit-footer-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.material-products-dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.material-products-dialog-body > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.material-products-dialog-body > header span,
.material-products-dialog-body > header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.material-products-dialog-body h3 {
  margin: 3px 0;
  font-size: 19px;
}

.material-linked-products {
  display: grid;
  gap: 9px;
  max-height: min(60vh, 520px);
  overflow: auto;
}

.material-linked-product {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(320px, 2fr);
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.material-linked-product > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.material-linked-product strong,
.material-linked-product span,
.material-linked-product dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-linked-product span,
.material-linked-product dt {
  color: var(--muted);
  font-size: 11px;
}

.material-linked-product dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  margin: 0;
}

.material-linked-product dl > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.material-linked-product dd {
  margin: 0;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.material-linked-products-empty {
  display: grid;
  min-height: 120px;
  color: var(--muted);
  text-align: center;
  place-content: center;
}

@media (max-width: 900px) {
  .materials-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .material-entry-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recipe-material-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recipe-material-name {
    grid-column: 1 / -1;
  }

  .recipe-row-actions {
    align-self: end;
  }

  .recipe-create-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recipe-create-form > button {
    grid-column: 1 / -1;
  }

  .recipe-workspace {
    grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  .materials-filter-band {
    align-items: stretch;
    flex-direction: column;
  }

  .materials-filter-actions {
    flex-basis: auto;
    width: 100%;
  }

  .finished-product-create-band form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finished-product-create-band form button {
    grid-column: 1 / -1;
  }

  .finished-product-filterbar {
    grid-template-columns: minmax(260px, 1fr) minmax(150px, .65fr) minmax(150px, .65fr) auto;
  }

  .finished-product-result-count {
    grid-column: 1 / -1;
    justify-content: flex-end;
    min-height: 24px;
    padding: 0;
  }

  .recipe-detail-header {
    flex-wrap: wrap;
  }

  .material-card {
    grid-template-columns: 104px minmax(0, 1fr);
    min-height: 104px;
  }

  .material-image {
    min-height: 102px;
  }

  .material-card-body {
    grid-template-columns: minmax(125px, 0.65fr) minmax(140px, 0.8fr) minmax(0, 2fr);
    grid-template-areas:
      "material-created material-title material-details"
      "material-created material-title material-actions";
    grid-template-rows: auto auto;
    gap: 8px 12px;
    padding: 9px 11px;
  }

  .material-card-body header {
    grid-area: material-title;
    align-self: center;
  }

  .material-card-body dl {
    grid-area: material-details;
  }

  .material-card-body footer {
    grid-area: material-actions;
    justify-content: flex-end;
  }
}

@media (max-width: 700px) {
  .materials-toolbar,
  .materials-filter-band,
  .qr-generate-band {
    align-items: stretch;
    flex-direction: column;
  }

  .materials-view-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .material-qr-view-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .material-qr-view-tabs button {
    min-width: 0;
  }

  .materials-view-tabs button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
    font-size: 11px;
  }

  .materials-search {
    flex-basis: auto;
    width: 100%;
    min-width: 0;
  }

  .materials-filter-actions {
    justify-content: stretch;
    flex-basis: auto;
    width: 100%;
  }

  .qr-generate-band form {
    align-items: stretch;
    width: 100%;
  }

  .qr-generate-band label {
    flex: 1 1 auto;
    width: auto;
  }

  .qr-batch-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
  }

  .material-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .material-card {
    grid-template-columns: 88px minmax(0, 1fr);
    min-height: 150px;
  }

  .material-image {
    min-height: 148px;
  }

  .material-card-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "material-created"
      "material-title"
      "material-details"
      "material-actions";
    grid-template-rows: auto auto auto auto;
    gap: 9px;
    padding: 10px;
  }

  .material-card-body header {
    align-self: auto;
    flex-wrap: wrap;
  }

  .material-card-created {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 7px;
  }

  .material-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 8px;
  }

  .material-card dl > div {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 7px 4px 0;
  }

  .material-card-body footer {
    justify-content: stretch;
  }

  .material-card footer button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 5px;
    font-size: 11px;
  }

  .bound-material-summary {
    grid-template-columns: 1fr;
  }

  .finished-product-filterbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finished-product-search,
  .finished-product-result-count {
    grid-column: 1 / -1;
  }

  .finished-product-create-band form,
  .recipe-create-form,
  .recipe-completion-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finished-product-create-band form button,
  .recipe-create-form > button,
  .recipe-completion-form > button {
    grid-column: 1 / -1;
  }

  .recipe-workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .finished-product-list {
    display: flex;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .finished-product-list button {
    flex: 0 0 270px;
  }

  .recipe-detail {
    overflow: visible;
  }
}

.material-product-count-button {
  border-color: #bfd0ee;
  color: #1d4ed8;
  background: #f7faff;
  cursor: pointer;
}

.material-product-count-button:hover {
  border-color: #7da4ea;
  background: #edf4ff;
}

.material-products-dialog {
  width: min(1380px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
}

.material-products-dialog-body {
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: calc(100dvh - 30px);
  overflow: hidden;
}

.material-binding-filterbar {
  padding: 0 0 12px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
}

.material-fnsku-binding-filterbar {
  grid-template-columns: minmax(320px, 560px) auto minmax(70px, 1fr);
}

.material-fnsku-binding-filterbar .finished-product-result-count {
  justify-self: start;
}

.material-products-dialog-content {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(480px, .9fr);
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.material-linked-products-section,
.material-product-binding-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.material-linked-products-section > header,
.material-product-binding-area > header {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
}

.material-linked-products-section h4,
.material-product-binding-area h4 {
  margin: 0 0 3px;
  font-size: 14px;
}

.material-linked-products-section header span,
.material-product-binding-area header span {
  color: var(--muted);
  font-size: 11px;
}

.material-linked-products-section .material-linked-products {
  padding: 9px;
}

.material-linked-product-detail {
  grid-template-columns: minmax(210px, 1.2fr) minmax(250px, 1fr) auto;
  gap: 10px;
  padding: 9px;
}

.material-linked-product-identity {
  display: grid !important;
  grid-template-columns: 50px minmax(0, 1fr);
  align-items: center;
  gap: 9px !important;
}

.material-linked-product-identity .finished-product-thumbnail {
  width: 50px;
  height: 50px;
}

.material-linked-product-detail dl {
  grid-template-columns: repeat(3, minmax(74px, 1fr));
}

.material-linked-product-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.material-linked-product-actions > button {
  min-height: 34px;
  padding-inline: 10px;
  white-space: nowrap;
}

.material-linked-product-actions > .danger {
  color: #dc2626;
  border-color: #fecaca;
  background: #fff7f7;
}

.material-monthly-usage {
  color: #dc2626 !important;
  font-size: 14px !important;
}

.material-product-binding-area .material-product-binding-single,
.material-product-binding-area .material-fnsku-search-state {
  min-height: 0;
  border: 0;
  border-radius: 0;
}

.material-product-binding-single {
  min-height: 430px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 900px) {
  .material-products-dialog-content {
    grid-template-columns: minmax(0, 1fr);
    overflow: auto;
  }

  .material-linked-products-section,
  .material-product-binding-area {
    overflow: visible;
  }

  .material-linked-product-detail {
    grid-template-columns: minmax(0, 1fr);
  }
}

.material-fnsku-search-state {
  min-height: 430px;
  border: 1px dashed #c9d5e7;
  border-radius: 8px;
  background: #f9fbfe;
}

.material-product-binding-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  min-height: 430px;
  max-height: min(68vh, 660px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.material-binding-product-list {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 8px;
  background: #f7f9fc;
}

.material-binding-product-list > button {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 68px;
  padding: 7px;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.material-binding-product-list > button:hover {
  border-color: #d6e0ef;
  background: #fff;
}

.material-binding-product-list > button.active {
  border-color: #9ab9f3;
  color: #1746aa;
  background: #eaf1ff;
}

.material-binding-product-list .finished-product-thumbnail {
  width: 50px;
  height: 50px;
}

.material-binding-product-list .finished-product-recipe-count.bound {
  color: #067647;
  font-weight: 800;
}

.material-product-binding-editor {
  display: grid;
  align-content: start;
  min-width: 0;
  overflow: auto;
}

.material-binding-product-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfe;
}

.material-binding-product-header h3 {
  margin: 3px 0 0;
  font-size: 18px;
}

.material-binding-state {
  flex: 0 0 auto;
  padding: 4px 9px;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  color: #667085;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.material-binding-state.bound {
  border-color: #abefc6;
  color: #067647;
  background: #ecfdf3;
}

.material-binding-target {
  display: grid;
  grid-template-columns: minmax(150px, .75fr) minmax(0, 1.25fr);
  align-items: end;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.material-binding-target > div {
  display: grid;
  gap: 4px;
}

.material-binding-target > div span,
.material-binding-target > div small,
.material-binding-target label span {
  color: var(--muted);
  font-size: 11px;
}

.material-binding-target > div strong {
  color: #101828;
  font-size: 18px;
}

#materialProductBindingForm {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto auto;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

#materialProductBindingForm label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

#materialProductBindingForm input,
#materialProductBindingForm button {
  min-height: 38px;
}

.material-product-recipe-overview {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.material-product-recipe-overview > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.material-product-recipe-overview h4 {
  margin: 0;
  font-size: 14px;
}

.material-product-recipe-overview header span,
.material-product-recipe-overview p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.material-product-recipe-overview > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.material-product-recipe-overview > div > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #dbe3ef;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 11px;
}

.material-product-recipe-overview > div > span.current {
  border-color: #9ab9f3;
  color: #1746aa;
  background: #edf4ff;
}

.material-product-recipe-overview em {
  color: #667085;
  font-style: normal;
}

@media (max-width: 800px) {
  .material-products-dialog-body {
    overflow: auto;
  }

  .material-product-binding-workspace {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
  }

  .material-binding-product-list {
    display: flex;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .material-binding-product-list > button {
    flex: 0 0 280px;
  }

  .material-binding-target {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .material-fnsku-binding-filterbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .material-fnsku-binding-filterbar .finished-product-result-count {
    display: none;
  }

  #materialProductBindingForm {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .materials-filter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .materials-sort {
    flex-basis: auto;
    width: 100%;
  }

  .materials-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .materials-metrics > div {
    min-height: 58px;
  }

  .materials-metrics > div:last-child {
    grid-column: 1 / -1;
  }

  .materials-view-tabs button {
    gap: 4px;
    padding: 0 5px;
    font-size: 10px;
    white-space: nowrap;
  }

  .materials-view-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .material-qr-view-tabs button {
    gap: 4px;
    padding: 0 5px;
    font-size: 10px;
    white-space: nowrap;
  }

  .material-grid,
  .material-entry-form {
    grid-template-columns: 1fr;
  }

  .finished-product-filterbar {
    grid-template-columns: 1fr;
  }

  .finished-product-search,
  .finished-product-result-count {
    grid-column: 1;
  }

  .finished-product-filterbar button {
    width: 100%;
  }

  .material-entry-form {
    padding: 14px;
  }

  .material-photo-field,
  .material-limit-pair,
  .material-entry-form footer {
    grid-column: 1;
  }

  .material-photo-field {
    width: 100%;
  }

  .material-grid {
    grid-template-columns: 1fr;
  }

  .finished-product-create-band form,
  .recipe-create-form,
  .recipe-completion-form,
  .recipe-material-row,
  .material-deduction-row {
    grid-template-columns: 1fr;
  }

  .finished-product-create-band form button,
  .recipe-create-form > button,
  .recipe-completion-form > button,
  .recipe-material-name {
    grid-column: 1;
  }

  .recipe-detail-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .finished-product-link-control {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .recipe-output-count {
    width: 100%;
  }

  .recipe-output-count span {
    margin-right: auto;
  }

  .recipe-row-actions button {
    flex: 1 1 0;
  }

  .material-qr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qr-svg {
    width: min(100%, 150px);
  }

  .qr-generate-band form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .qr-batch-actions > button {
    flex: 1 1 150px;
  }

  .material-pagination {
    flex-wrap: wrap;
  }

  .material-form-page > header {
    align-items: flex-start;
  }

  .material-qr-dialog-body > footer,
  .material-page-actions {
    flex-wrap: wrap;
  }

  .material-linked-product {
    grid-template-columns: 1fr;
  }

  .material-linked-product dl {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .material-linked-product dl {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .material-qr-grid {
    grid-template-columns: 1fr;
  }

  .material-category-tabs button {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 82px;
  }

  .qr-generate-band form {
    grid-template-columns: 1fr;
  }

  .qr-card-visuals:has(.bound-qr-material-image) {
    flex-direction: column;
  }

  .bound-qr-material-image {
    width: min(100%, 180px);
  }
}

/* Reuse the formal ERP surface, control and card hierarchy. */
.materials-module {
  gap: 16px;
}

.materials-toolbar {
  border-color: var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.materials-toolbar h2 {
  font-size: 18px;
}

.materials-toolbar p {
  font-size: 13px;
}

.materials-view-tabs,
.material-qr-view-tabs {
  border-radius: var(--radius-md);
}

.materials-view-tabs button,
.material-qr-view-tabs button {
  border-radius: var(--radius-sm);
}

.materials-view-tabs button span,
.material-qr-view-tabs button span,
.material-qr-state,
.material-success-badge,
.material-qr-card > span {
  border-radius: 999px;
}

.materials-filter-band,
.qr-generate-band {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.material-category-tabs button.active {
  border-color: #bfdbfe;
  color: var(--primary);
  background: var(--primary-soft);
}

.recipe-workspace,
.material-form-page,
.bound-material-summary,
.material-qr-card,
.materials-empty,
.material-state-panel {
  border-radius: var(--radius-lg);
}

.material-card {
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.material-card:hover {
  border-color: #c8d7ef;
  box-shadow: 0 4px 12px rgba(16, 24, 40, .055);
}

.material-card dl > .material-card-muted dd {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.recipe-create-form,
.recipe-material-list,
.deduction-card,
.material-photo-field,
.bound-qr-material-image,
.qr-batch-actions > label {
  border-radius: var(--radius-md);
}

.deduction-materials span,
.qr-card-selector {
  border-radius: var(--radius-sm);
}

.material-qr-dialog,
.material-products-dialog,
.material-edit-dialog {
  border-radius: var(--radius-xl);
}

@media (max-width: 700px) {
  .materials-module {
    gap: 12px;
  }

  .materials-toolbar,
  .materials-filter-band,
  .qr-generate-band {
    padding: 12px;
  }

  .materials-toolbar,
  .materials-filter-band,
  .qr-generate-band,
  .recipe-workspace,
  .material-form-page,
  .materials-empty,
  .material-state-panel {
    border-radius: var(--radius-md);
  }
}
