.leather-pieces-section {
  display: grid;
  gap: 14px;
}

.leather-pieces-heading,
.leather-setup-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.leather-pieces-heading h3,
.leather-setup-heading h3 { margin: 0 0 3px; }
.leather-pieces-heading p,
.leather-setup-heading p { color: #7c746c; font-size: 12px; margin: 0; }

.leather-reconcile-badge {
  border: 1px solid #d9d2ca;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .07em;
  padding: 6px 8px;
  white-space: nowrap;
}
.leather-reconcile-badge.matched { background: #f0f6ef; border-color: #bed5b9; color: #42643d; }
.leather-reconcile-badge.mismatch { background: #fff5e8; border-color: #e5c28c; color: #80591f; }

.leather-piece-metrics,
.leather-ledger-targets,
.leather-validation-grid { display: grid; gap: 9px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.leather-piece-metrics > div,
.leather-ledger-targets > div,
.leather-validation-grid > div {
  background: #faf8f5;
  border: 1px solid #e3dbd2;
  border-radius: 11px;
  display: grid;
  gap: 3px;
  padding: 11px 12px;
}
.leather-piece-metrics span,
.leather-ledger-targets span,
.leather-validation-grid span,
.leather-code-preview span { color: #817970; font-size: 9px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.leather-piece-metrics strong,
.leather-ledger-targets strong,
.leather-validation-grid strong { font-size: 13px; }
.leather-ledger-targets small,
.leather-validation-grid small { color: #817970; font-size: 10px; }
.leather-validation-grid .matched { background: #f3f8f2; border-color: #c8ddc4; }
.leather-validation-grid .mismatch { background: #fff9ef; border-color: #e7c995; }

.leather-piece-table table { min-width: 860px; }
.leather-piece-table td,
.leather-piece-table th { vertical-align: middle; }
.leather-piece-status {
  border: 1px solid #ddd5cc;
  border-radius: 999px;
  color: #6f675f;
  display: inline-flex;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .045em;
  padding: 5px 7px;
  text-transform: uppercase;
  white-space: nowrap;
}
.leather-piece-status.available { background: #f0f6ef; border-color: #bfd6bb; color: #41663d; }
.leather-piece-status.in_wip { background: #f0f3f7; border-color: #c8d1dc; color: #526375; }
.leather-piece-status.consumed,
.leather-piece-status.archived { opacity: .65; }

.leather-piece-empty,
.leather-piece-warning,
.leather-piece-callout {
  align-items: center;
  background: #faf8f5;
  border: 1px solid #e2d9d0;
  border-radius: 12px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 14px;
}
.leather-piece-empty strong,
.leather-piece-warning strong,
.leather-piece-callout strong { display: block; font-size: 12px; margin-bottom: 3px; }
.leather-piece-empty p,
.leather-piece-warning span,
.leather-piece-callout span { color: #746c64; font-size: 11px; line-height: 1.45; margin: 0; }
.leather-piece-warning { align-items: flex-start; background: #fff8eb; border-color: #e5c58f; display: grid; gap: 2px; }
.leather-piece-callout { align-items: flex-start; background: #f4f6f2; border-color: #d4ddd0; display: grid; gap: 2px; }

.leather-piece-setup-modal .modal-body { display: grid; gap: 16px; }
.leather-piece-setup-rows { display: grid; gap: 8px; }
.leather-setup-row {
  align-items: end;
  background: #fbfaf8;
  border: 1px solid #e2dad1;
  border-radius: 12px;
  display: grid;
  gap: 9px;
  grid-template-columns: 150px minmax(110px, .7fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
  padding: 10px;
}
.leather-code-preview { align-self: center; display: grid; gap: 3px; padding: 0 4px; }
.leather-code-preview strong { font-size: 13px; }
.leather-validation-ok,
.leather-validation-warning { font-size: 11px; font-weight: 700; margin: 8px 0 0; }
.leather-validation-ok { color: #4b7046; }
.leather-validation-warning { color: #80591f; }
.leather-piece-error { background: #fff0ed; border: 1px solid #e6b8ae; border-radius: 9px; color: #934b3c; font-size: 11px; font-weight: 700; margin-top: 8px; padding: 9px 10px; }

.purchase-line.has-leather-purchase { background: #fcfaf6; border: 1px solid #e2d6c8; border-radius: 12px; padding: 10px; }
.leather-purchase-receipt { background: #fff; border-top: 1px solid #e8ded3; display: grid; gap: 10px; grid-column: 1 / -1; margin: 2px -2px -2px; padding: 12px 2px 2px; }
.leather-purchase-heading,
.leather-purchase-footer { align-items: center; display: flex; gap: 12px; justify-content: space-between; }
.leather-purchase-heading > div:first-child { display: grid; gap: 2px; }
.leather-purchase-heading strong { font-size: 12px; }
.leather-purchase-heading span { color: #766f68; font-size: 10px; }
.leather-purchase-total { border: 1px solid #dfd6cc; border-radius: 9px; display: grid; gap: 1px; padding: 7px 9px; text-align: right; }
.leather-purchase-total small { color: #7f776f; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.leather-purchase-total strong { font-size: 11px; }
.leather-purchase-total.matched { background: #f2f7f1; border-color: #c7dbc3; color: #42673d; }
.leather-purchase-total.mismatch { background: #fff8eb; border-color: #e4c58f; color: #815b22; }
.leather-purchase-piece-list { display: grid; gap: 6px; }
.leather-purchase-piece { align-items: end; background: #faf8f5; border: 1px solid #e6ded5; border-radius: 9px; display: grid; gap: 8px; grid-template-columns: 145px 150px minmax(180px, 1fr) auto; padding: 8px; }
.leather-piece-code { align-self: center; display: grid; gap: 2px; }
.leather-piece-code span { color: #817970; font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.leather-piece-code strong { font-size: 12px; }
.leather-purchase-piece .field { margin: 0; }
.leather-purchase-footer > span { font-size: 10px; font-weight: 800; letter-spacing: .035em; }
.leather-purchase-footer > span.matched { color: #486e43; }
.leather-purchase-footer > span.mismatch { color: #80591f; }

/* Materials Stock stays analytical: summary + optional inline inspection only. */
.leather-stock-inline {
  align-items: center;
  color: #756d65;
  display: flex;
  font-size: 9px;
  font-weight: 700;
  gap: 5px;
  justify-content: flex-end;
  margin-top: 3px;
  white-space: nowrap;
}
.leather-stock-inline.error { color: #985343; white-space: normal; }
.leather-stock-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid #d9d0c6;
  border-radius: 6px;
  color: #5e5750;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  height: 21px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 23px;
}
.leather-stock-toggle:hover { background: #f4efe9; }
.materials-leather-detail-row > td { background: #fbf8f4; padding: 0 !important; }
.materials-leather-inline-panel { border-bottom: 1px solid #e6ddd3; border-top: 1px solid #e6ddd3; padding: 10px 14px 12px; }
.materials-leather-inline-heading { align-items: center; display: flex; gap: 12px; justify-content: space-between; margin-bottom: 8px; }
.materials-leather-inline-heading strong { font-size: 11px; }
.materials-leather-inline-heading span { color: #797169; font-size: 9px; font-weight: 700; }
.materials-leather-inline-panel table { font-size: 10px; min-width: 560px; }
.materials-leather-inline-panel th { font-size: 8px; }
.manage-leather-pieces { margin-right: 4px; }
.leather-manager-modal .modal-body { display: grid; gap: 12px; }

/* Final pre-Sales Item forms: one approved field matrix shared by manual entry and Excel. */
.approved-item-schema { display: grid; gap: 12px; }
.approved-item-schema-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.approved-item-schema-heading h3 { margin: 0; }
.approved-item-schema-heading small { color: #7b736b; font-size: 10px; }
.approved-item-schema-grid,
.approved-opening-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.approved-opening-fields { border-top: 1px solid #e7ded4; padding-top: 12px; }
.import-template-picker { display: grid; gap: 9px; margin-top: 12px; }
.import-template-picker > span { color: #756d65; font-size: 10px; font-weight: 700; }
.import-template-links { display: flex; flex-wrap: wrap; gap: 7px; }
.approved-item-schema .field,
.approved-opening-fields .field { margin: 0; }

@media (max-width: 900px) {
  .leather-piece-metrics,
  .leather-ledger-targets,
  .leather-validation-grid { grid-template-columns: 1fr; }
  .leather-setup-row { align-items: stretch; grid-template-columns: 1fr 1fr; }
  .leather-code-preview { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .leather-pieces-heading,
  .leather-setup-heading,
  .leather-piece-empty,
  .materials-leather-inline-heading { align-items: stretch; flex-direction: column; }
  .leather-reconcile-badge { align-self: flex-start; }
  .leather-setup-row { grid-template-columns: 1fr; }
  .leather-code-preview { grid-column: auto; }
  .leather-stock-inline { justify-content: flex-start; }
  .approved-item-schema-heading { align-items: flex-start; flex-direction: column; }
  .approved-item-schema-grid,
  .approved-opening-grid { grid-template-columns: 1fr; }
}
