/* ==========================================================================
   Compact Step 4: Profit / Loss (Supplier / Purchase Costing)
   ========================================================================== */

/* Main Cost Section Card */
.cost-section-card,
.cost-summary-card {
  margin: 18px 0 16px;
  border: 1px solid #dfe5ef;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(16, 24, 40, 0.03);
  overflow: hidden;
}

.cost-section-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
  padding: 12px 18px !important;
  background: #f8fafd !important;
  border-bottom: 1px solid #e7edf6 !important;
  margin: 0 !important;
  border-radius: 14px 14px 0 0 !important;
}

.cost-heading-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cost-heading-wrap h3 {
  margin: 0;
  font: 700 15px/1.3 Manrope, Inter, sans-serif;
  color: #0a1f44;
}

.cost-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: #3563e9;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Empty State */
.cost-empty-state {
  padding: 26px 16px;
  text-align: center;
  background: #fafcff;
}

.cost-empty-state p {
  margin: 0 0 12px;
  color: #667085;
  font-size: 13.5px;
}

.cost-add-btn {
  padding: 7px 15px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
}

/* Table Container */
.cost-table-container {
  overflow-x: auto;
  background: #fff;
}

/* Header Labels */
.cost-table-labels {
  display: grid;
  grid-template-columns: 32px minmax(130px, 1.2fr) minmax(170px, 1.8fr) 75px 115px 120px 36px;
  gap: 8px;
  align-items: center;
  padding: 8px 14px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  color: #556582;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cs-col-num { text-align: center; }
.cs-col-service { padding-left: 2px; }
.cs-col-desc { padding-left: 2px; }
.cs-col-qty { text-align: center; }
.cs-col-unit { text-align: right; }
.cs-col-subtotal { text-align: right; }
.cs-col-action { text-align: center; }

/* Table Rows */
.cost-row {
  display: grid;
  grid-template-columns: 32px minmax(130px, 1.2fr) minmax(170px, 1.8fr) 75px 115px 120px 36px;
  gap: 8px;
  align-items: center;
  padding: 6px 14px;
  border-bottom: 1px solid #edf2f7;
  transition: background-color 0.15s ease;
}

.cost-row:nth-child(even) {
  background: #fafbfd;
}

.cost-row:hover {
  background: #f0f6ff;
}

/* Cells & Inputs */
.cs-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eef2f6;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.cs-cell input {
  width: 100% !important;
  box-sizing: border-box !important;
  height: 33px !important;
  padding: 5px 9px !important;
  border: 1px solid #d0d7e2 !important;
  border-radius: 7px !important;
  background: #fff !important;
  color: #101828 !important;
  font-size: 13px !important;
  font-family: inherit !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.cs-cell input:focus {
  outline: none !important;
  border-color: #3563e9 !important;
  box-shadow: 0 0 0 3px rgba(53, 99, 233, 0.15) !important;
}

.cs-cell.cs-qty input {
  text-align: center;
}

.cs-cell.cs-unit input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Line Total badge */
.cost-line-total {
  display: inline-block;
  width: 100%;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: #101828;
  font-variant-numeric: tabular-nums;
  padding-right: 4px;
}

/* Remove button */
.cost-row-del {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 6px !important;
  background: transparent !important;
  color: #98a2b3 !important;
  font-size: 16px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.cost-row-del:hover {
  background: #fee4e2 !important;
  color: #d92d20 !important;
}

/* Table Footer */
.cost-table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: #f8fafc;
  border-top: 1px solid #e7edf6;
}

.cost-quick-add {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  padding: 6px 13px !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: 7px !important;
  background: #fff !important;
  color: #2454da !important;
  border: 1px dashed #b1c7f8 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.cost-quick-add:hover {
  background: #edf3ff !important;
  border-color: #3563e9 !important;
}

.cost-tab-hint {
  font-size: 11px;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cost-tab-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  font-family: inherit;
  color: #475467;
  background: #eaecf0;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
}

/* Financial Summary Card */
.cost-summary-card {
  padding: 16px 20px;
  background: #fff;
  border: 1px solid #dfe5ef;
}

.cost-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf0f5;
}

.cost-summary-head h4 {
  margin: 0;
  font: 700 15px Manrope, Inter, sans-serif;
  color: #0f172a;
}

.cost-margin-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.cost-margin-pill.profit {
  background: #eefaf3;
  color: #027a48;
  border: 1px solid #b7ecd0;
}

.cost-margin-pill.loss {
  background: #fef3f2;
  color: #b42318;
  border: 1px solid #fecdca;
}

/* Summary KPI Grid */
.cost-totals-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 12px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

.cost-totals-grid .total {
  padding: 14px 16px !important;
  border-radius: 11px !important;
  border: 1px solid #e2e8f0 !important;
  background: #f8fafc !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 4px !important;
}

.cost-totals-grid .total small {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
}

.cost-totals-grid .total strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.cost-totals-grid .cost-kpi-sale {
  border-left: 4px solid #3563e9 !important;
}

.cost-totals-grid .cost-kpi-purchase {
  border-left: 4px solid #f79009 !important;
}

.cost-totals-grid .cost-kpi-profit.profit {
  border-left: 4px solid #12b76a !important;
  background: #f3faf6 !important;
}

.cost-totals-grid .cost-kpi-profit.profit strong {
  color: #027a48;
}

.cost-totals-grid .cost-kpi-profit.loss {
  border-left: 4px solid #f04438 !important;
  background: #fff8f7 !important;
}

.cost-totals-grid .cost-kpi-profit.loss strong {
  color: #b42318;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .cost-table-labels,
  .cost-row {
    grid-template-columns: 28px minmax(110px, 1fr) minmax(130px, 1fr) 60px 85px 95px 30px;
    gap: 6px;
    padding: 6px 8px;
  }
  .cost-totals-grid {
    grid-template-columns: 1fr !important;
  }
}
