.detail-print-bar {
  gap: 9px;
}

.detail-cost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid #f0b45e;
  border-radius: 12px;
  background: #fff8ed;
  color: #b45309;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: 0.2s ease;
}

.detail-cost-btn:hover {
  border-color: #d97706;
  background: #ffedd5;
}

.detail-cost-btn:active {
  transform: scale(0.97);
}

.cost-calculator-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.64);
  isolation: isolate;
}

.cost-calculator-modal {
  position: relative;
  width: min(900px, 96vw);
  max-height: 92vh;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.28);
}

.cost-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  font-size: 22px;
  line-height: 30px;
}

.cost-modal-close:hover {
  background: #f8fafc;
  color: #0f172a;
}

.product-cost-calculator {
  --cost-primary: #d97706;
  --cost-line: #e7eaf0;
  background: #fff;
  border: 1px solid var(--cost-line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.product-cost-calculator.loading {
  pointer-events: none;
  cursor: progress;
}

.cost-calculator-header,
.cost-section-title,
.cost-sku-selector,
.cost-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cost-calculator-header h3 {
  margin: 2px 0 3px;
  color: #172033;
  font-size: 18px;
}

.cost-calculator-header p,
.cost-section-title small {
  margin: 0;
  color: #718096;
  font-size: 12px;
}

.cost-eyebrow {
  color: var(--cost-primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.cost-save-state {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 11px;
  font-weight: 700;
}

.cost-save-state.saved {
  background: #ecfdf5;
  color: #047857;
}

.cost-sku-selector {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
}

.cost-sku-selector span,
.cost-fixed-grid label span,
.cost-notes span {
  color: #475569;
  font-size: 12px;
  font-weight: 650;
}

.cost-sku-selector select {
  min-width: 190px;
  max-width: 65%;
}

.cost-sku-selector select,
.cost-material-row select,
.cost-material-row input,
.cost-fixed-grid input,
.cost-notes textarea {
  border: 1px solid #dce2ea;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  font: inherit;
  outline: none;
}

.cost-sku-selector select,
.cost-material-row select,
.cost-material-row input,
.cost-fixed-grid input {
  height: 36px;
  padding: 0 9px;
}

.cost-sku-selector select:focus,
.cost-material-row select:focus,
.cost-material-row input:focus,
.cost-fixed-grid input:focus,
.cost-notes textarea:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.cost-existing-hint,
.cost-formula {
  padding: 9px 11px;
  border-radius: 9px;
  background: #fffbeb;
  color: #7c5b14;
  font-size: 11px;
  line-height: 1.55;
}

.cost-section-title strong {
  display: block;
  color: #172033;
  font-size: 14px;
}

.cost-section-title button {
  flex: 0 0 auto;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff7ed;
  color: #c2410c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.cost-material-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cost-material-empty {
  border: 1px dashed #d9dee8;
  border-radius: 10px;
  padding: 16px;
  color: #94a3b8;
  text-align: center;
  font-size: 12px;
}

.cost-material-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(190px, 1fr) 86px 30px;
  gap: 7px;
  align-items: center;
  padding: 9px;
  border: 1px solid #edf0f4;
  border-radius: 10px;
  background: #fbfcfe;
}

.cost-material-description {
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cost-material-row strong {
  color: #9a4d08;
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
}

.cost-material-row [data-remove-material] {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #fef2f2;
  color: #dc2626;
  cursor: pointer;
  font-size: 17px;
}

.cost-fixed-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.cost-fixed-grid label,
.cost-notes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cost-rate-input {
  position: relative;
  display: block;
}

.cost-rate-input input {
  width: 100%;
  padding-right: 32px;
}

.cost-rate-input b {
  position: absolute;
  top: 50%;
  right: 11px;
  color: #94a3b8;
  font-size: 12px;
  transform: translateY(-50%);
}

.cost-notes textarea {
  min-height: 60px;
  padding: 9px;
  resize: vertical;
}

.cost-summary {
  align-items: stretch;
}

.cost-summary > div {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
}

.cost-summary span {
  display: block;
  margin-bottom: 5px;
  color: #64748b;
  font-size: 11px;
}

.cost-summary strong {
  color: #172033;
  font-size: 15px;
}

.cost-summary .recommended {
  background: linear-gradient(135deg, #fff7ed, #fffbeb);
  border: 1px solid #fed7aa;
}

.cost-summary .recommended strong {
  color: #c2410c;
}

.cost-save-button {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #d97706, #ea8500);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  box-shadow: 0 8px 18px rgba(217, 119, 6, 0.2);
}

.cost-save-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

@media (max-width: 1100px) {
  .cost-material-row {
    grid-template-columns: 1fr 1fr 80px 30px;
  }
  .cost-material-row strong { text-align: left; }
  .cost-fixed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .cost-calculator-backdrop { padding: 10px; }
  .cost-calculator-modal { width: 100%; max-height: 96vh; }
  .product-cost-calculator { padding: 14px; }
  .cost-sku-selector { align-items: stretch; flex-direction: column; }
  .cost-sku-selector select { max-width: none; width: 100%; }
  .cost-material-row { grid-template-columns: 1fr 32px; }
  .cost-material-row select,
  .cost-material-description { grid-column: 1 / -1; }
  .cost-fixed-grid { grid-template-columns: 1fr 1fr; }
  .cost-summary { display: grid; grid-template-columns: 1fr 1fr; }
  .cost-summary .recommended { grid-column: 1 / -1; }
}
