/* Controlled manual authoring for Pallet/Packing and Plastic BOM. */
#modelbom table th,
#modelbom table td {
  text-align: center !important;
  vertical-align: middle !important;
}
#modelbom table th > *,
#modelbom table td > * {
  margin-inline: auto;
}
#modelbom table td.num,
#modelbom table th.num,
#modelbom .money,
#modelbom .server-price,
#modelbom .plastic-master-name,
#modelbom .plastic-master-code {
  text-align: center !important;
}
#modelbom table td .link-btn,
#modelbom table td .action-strip,
#modelbom table td .edit-actions {
  justify-content: center;
}
#modelbom .model-bom-action-zone .create-master-bom-btn {
  order: -1;
}

.bom-master-modal {
  width: min(1580px, calc(100vw - 34px));
  max-height: 94vh;
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.bom-master-modal .modal-head {
  margin: 0;
  padding: 17px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(56,189,248,.1), rgba(45,212,191,.05));
}
.bom-master-modal .modal-head h3 { margin: 3px 0 2px; font-size: 21px; }
.bom-master-modal .modal-head p { margin: 0; font-size: 12px; }
.bom-master-modal .menu-close { flex: 0 0 auto; }
.master-authoring-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(90,120,160,.035);
}
.master-authoring-tabs button {
  min-height: 38px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}
.master-authoring-tabs button.active {
  color: #0d6788;
  background: var(--paper);
  border-color: var(--line);
  box-shadow: inset 0 3px #22b8d1;
}
.master-authoring-body {
  min-height: 0;
  overflow: auto;
  padding: 14px 20px 18px;
}
.master-authoring-panel { display: none; }
.master-authoring-panel.active { display: block; }
.master-authoring-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(56,189,248,.25);
  border-radius: 12px;
  background: rgba(56,189,248,.06);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.45;
}
.master-authoring-note b { color: var(--ink); }
.master-authoring-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(125px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(56,189,248,.035), rgba(45,212,191,.025));
}
.master-authoring-grid label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.master-authoring-grid label.span-2 { grid-column: span 2; }
.master-authoring-grid label.span-3 { grid-column: span 3; }
.master-authoring-grid label.span-6 { grid-column: span 6; }
.master-authoring-grid input,
.master-authoring-grid select,
.master-authoring-grid textarea {
  width: 100%;
  min-width: 0;
  min-height: 37px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  text-transform: none;
  letter-spacing: 0;
}
.master-authoring-grid textarea { min-height: 70px; resize: vertical; }
.master-authoring-grid .check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 37px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}
.master-authoring-grid .check-field input { width: 16px; min-height: 16px; margin: 0; }
.master-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 8px;
}
.master-lines-head h4 { margin: 0; font-size: 15px; }
.master-lines-head small { color: var(--muted); }
.master-lines-table-wrap { max-height: 335px; overflow: auto; }
.master-lines-table { min-width: 1180px; table-layout: fixed; }
.master-lines-table th { position: sticky; top: 0; z-index: 2; }
.master-lines-table input,
.master-lines-table select {
  width: 100%;
  min-width: 0;
  height: 32px;
  text-align: center;
}
.master-lines-table .line-remove {
  width: 29px;
  height: 29px;
  border: 1px solid rgba(244,63,94,.25);
  border-radius: 8px;
  background: rgba(244,63,94,.07);
  color: #be123c;
  font-weight: 950;
  cursor: pointer;
}
.master-authoring-result { margin-top: 10px; }
.master-authoring-preview {
  margin-top: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.master-preview-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0,1fr));
  border-bottom: 1px solid var(--line);
}
.master-preview-metrics > div { padding: 10px; border-right: 1px solid var(--line); text-align: center; }
.master-preview-metrics > div:last-child { border-right: 0; background: rgba(16,185,129,.07); }
.master-preview-metrics span { display: block; color: var(--muted); font-size: 9.5px; font-weight: 850; text-transform: uppercase; }
.master-preview-metrics b { display: block; margin-top: 3px; font-size: 13px; }
.master-preview-warnings { margin: 0; padding: 9px 28px; background: rgba(245,158,11,.07); color: #9a6500; font-size: 11px; }
.bom-master-modal .modal-actions {
  margin: 0;
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.bom-master-modal .modal-actions .action-context { margin-right: auto; align-self: center; color: var(--muted); font-size: 11px; font-weight: 750; }
.bom-master-modal .modal-actions button { min-width: 116px; }

@media (max-width: 1200px) {
  .master-authoring-grid { grid-template-columns: repeat(3, minmax(145px,1fr)); }
  .master-authoring-grid label.span-6 { grid-column: span 3; }
  .master-preview-metrics { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 760px) {
  .bom-master-modal { width: 98vw; max-height: 97vh; }
  .master-authoring-tabs { overflow-x: auto; padding-inline: 10px; }
  .master-authoring-grid { grid-template-columns: 1fr; }
  .master-authoring-grid label.span-2,
  .master-authoring-grid label.span-3,
  .master-authoring-grid label.span-6 { grid-column: span 1; }
  .master-preview-metrics { grid-template-columns: 1fr 1fr; }
  .bom-master-modal .modal-actions { flex-wrap: wrap; }
  .bom-master-modal .modal-actions .action-context { width: 100%; }
}

/* Ver.8.1.4 production authoring controls. */
.production-authoring-modal .master-authoring-body { background: linear-gradient(180deg, rgba(241,248,255,.65), rgba(255,255,255,.96)); }
.authoring-system-strip {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  margin-bottom:12px;
  border:1px solid rgba(37,99,235,.18);
  border-radius:13px;
  overflow:hidden;
  background:linear-gradient(90deg,rgba(219,234,254,.72),rgba(236,254,255,.7));
}
.authoring-system-strip > div { min-width:0; padding:9px 12px; border-right:1px solid rgba(37,99,235,.13); text-align:center; }
.authoring-system-strip > div:last-child { border-right:0; }
.authoring-system-strip span { display:block; color:var(--muted); font-size:9px; font-weight:900; letter-spacing:.55px; text-transform:uppercase; }
.authoring-system-strip b { display:block; margin-top:3px; color:#0b3d72; font-size:11.5px; }
.template-assist-row {
  display:grid;
  grid-template-columns:minmax(340px,1.4fr) auto minmax(240px,1fr);
  align-items:end;
  gap:9px;
  margin-bottom:11px;
  padding:10px 12px;
  border:1px dashed rgba(14,116,144,.28);
  border-radius:13px;
  background:rgba(236,254,255,.55);
}
.template-field { display:grid; gap:5px; color:var(--muted); font-size:10px; font-weight:900; text-transform:uppercase; letter-spacing:.4px; }
.template-field select { min-height:36px; border:1px solid var(--line); border-radius:9px; padding:7px 9px; background:var(--paper); color:var(--ink); font-weight:750; }
.similar-code-hints { display:flex; flex-wrap:wrap; align-items:center; gap:6px; min-height:34px; }
.similar-code-hints:empty::before { content:'Similar-code suggestions appear here'; color:var(--muted); font-size:10px; font-style:italic; }
.similar-code-hints button { border:1px solid rgba(14,165,233,.28); border-radius:999px; padding:5px 9px; background:rgba(14,165,233,.08); color:#03678a; font-size:10px; font-weight:900; cursor:pointer; }
.compact-production-grid { padding:11px; gap:9px; }
.compact-production-grid textarea { min-height:54px; }
.formula-fixed-panel { margin-top:12px; border:1px solid rgba(16,185,129,.2); border-radius:14px; overflow:hidden; background:rgba(236,253,245,.5); }
.formula-fixed-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px 7px; }
.formula-fixed-head h4 { margin:2px 0 0; font-size:14px; }
.formula-fixed-cards { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); border-top:1px solid rgba(16,185,129,.15); }
.formula-fixed-cards > div { padding:10px 8px; border-right:1px solid rgba(16,185,129,.14); text-align:center; }
.formula-fixed-cards > div:last-child { border-right:0; }
.formula-fixed-cards span { display:block; color:var(--muted); font-size:9px; font-weight:900; text-transform:uppercase; letter-spacing:.35px; }
.formula-fixed-cards b { display:block; margin-top:4px; color:#065f46; font-size:12px; }
.production-lines-table { min-width:1420px; }
.production-lines-table th:nth-child(1) { width:48px; }
.production-lines-table th:last-child { width:48px; }
.production-lines-table td { padding:7px 6px; }
.line-sequence { display:inline-grid; place-items:center; min-width:26px; height:26px; border-radius:7px; background:rgba(59,130,246,.08); color:#174b86; font-weight:900; }
.line-auto-value { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--ink); font-size:11px; font-weight:750; text-align:center; }
.line-readonly-input { background:rgba(226,232,240,.45)!important; color:var(--ink)!important; border-style:dashed!important; }
.line-data-status { display:inline-flex; align-items:center; justify-content:center; min-width:62px; min-height:24px; border-radius:999px; padding:3px 8px; font-size:9px; font-weight:900; }
.line-data-status.ok { background:rgba(16,185,129,.1); color:#047857; }
.line-data-status.warn { background:rgba(245,158,11,.12); color:#a16207; }
.bom-lifecycle-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:center; gap:7px; margin-left:auto; }
.bom-lifecycle-actions .danger-outline { border-color:rgba(225,29,72,.28); color:#be123c; background:rgba(244,63,94,.05); }
.authoring-message { padding:9px 11px; border-radius:10px; font-size:11px; font-weight:750; }
.authoring-message.ok { background:rgba(16,185,129,.08); color:#047857; }
.authoring-message.warn { background:rgba(245,158,11,.09); color:#92400e; }
#modelbom .packing-browser-detail-head,
#modelbom .plastic-detail-head { gap:10px; flex-wrap:wrap; }
#modelbom .packing-browser-detail-head > button#packingBackToModelBtn { margin-left:auto; }
#modelbom .plastic-master-table td,
#modelbom .plastic-lines-table td,
#modelbom .plastic-process-cost-table td,
#modelbom #packingBomDetail table td { text-align:center!important; vertical-align:middle!important; }
#modelbom .plastic-master-table td small,
#modelbom .plastic-lines-table td small { display:block; text-align:center; }

@media (max-width:1200px) {
  .authoring-system-strip { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .authoring-system-strip > div:nth-child(2) { border-right:0; }
  .authoring-system-strip > div:nth-child(-n+2) { border-bottom:1px solid rgba(37,99,235,.13); }
  .template-assist-row { grid-template-columns:1fr auto; }
  .similar-code-hints { grid-column:1 / -1; }
  .formula-fixed-cards { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .formula-fixed-cards > div:nth-child(3n) { border-right:0; }
  .formula-fixed-cards > div:nth-child(-n+3) { border-bottom:1px solid rgba(16,185,129,.14); }
}
@media (max-width:760px) {
  .authoring-system-strip { grid-template-columns:1fr; }
  .authoring-system-strip > div { border-right:0; border-bottom:1px solid rgba(37,99,235,.13); }
  .authoring-system-strip > div:last-child { border-bottom:0; }
  .template-assist-row { grid-template-columns:1fr; }
  .formula-fixed-cards { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .formula-fixed-cards > div { border-bottom:1px solid rgba(16,185,129,.14); }
}

.formula-config-required{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 16px;border:1px solid #f0c36d;border-radius:12px;background:#fff8e8;color:#754c00}
.formula-config-required span{font-size:11px;font-weight:900;letter-spacing:.08em;text-transform:uppercase}
.formula-config-required b{font-size:13px;text-align:right}

/* Production lifecycle control lives inside Edit BOM, not in the page toolbar. */
.master-lifecycle-editor {
  display: grid;
  grid-template-columns: minmax(180px, .5fr) minmax(250px, .7fr) minmax(360px, 1.4fr);
  gap: 14px;
  align-items: center;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #c8dfef;
  border-radius: 14px;
  background: linear-gradient(135deg, #f7fcff 0%, #edf8ff 100%);
}
.master-lifecycle-editor > div,
.master-lifecycle-editor label { display: flex; flex-direction: column; gap: 5px; }
.master-lifecycle-editor span,
.master-lifecycle-editor small { color: #5e7392; font-size: 11px; font-weight: 750; }
.master-lifecycle-editor b { color: #092b55; font-size: 14px; }
.master-lifecycle-editor select { width: 100%; min-height: 40px; border: 1px solid #c9ddec; border-radius: 10px; background: #fff; padding: 8px 10px; font: inherit; font-weight: 750; }
.master-lifecycle-editor small { line-height: 1.45; }
.lifecycle-discontinue-mode .master-authoring-grid,
.lifecycle-discontinue-mode .template-assist-row,
.lifecycle-discontinue-mode .master-lines-head,
.lifecycle-discontinue-mode .master-lines-table-wrap,
.lifecycle-discontinue-mode .formula-fixed-panel { opacity: .58; }
.lifecycle-discontinue-mode .master-lifecycle-editor { border-color: #efc777; background: #fff8e9; }
.production-authoring-modal .modal-actions .danger-outline { margin-right: auto; }
@media (max-width: 1100px) { .master-lifecycle-editor { grid-template-columns: 1fr 1fr; } .master-lifecycle-editor small { grid-column: 1 / -1; } }
