:root {
  --mg-primary: #111827;
  --mg-sale: #15803d;
  --mg-bg: #f8fafc;
  --mg-line: #e6e8ee;
}

#margen-toggle.margen-btn {
  position: fixed;
  left: 20px;
  right: auto;
  bottom: 20px;
  z-index: 40;
  padding: 14px 20px;
  border-radius: 999px;
  background: var(--mg-primary);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(17, 24, 39, .16);
}

#margen-popup.margen-popup {
  position: fixed;
  left: 20px;
  right: auto;
  bottom: 76px;
  z-index: 41;
  width: min(340px, calc(100vw - 40px));
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--mg-line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(17, 24, 39, .12);
}
#margen-popup .mg-step { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--mg-line); }
#margen-popup .mg-b2b { margin-top: 12px; padding: 10px; border-radius: 10px; background: var(--mg-bg); }
#margen-popup .mg-b2b div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13px; }
#margen-popup .mg-b2b strong { font-variant-numeric: tabular-nums; }
#margen-popup .mg-profit-toggle { margin-top: 0; }
#margen-popup[hidden] { display: none; }
#margen-popup label { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 650; }
#margen-popup input[type="number"] {
  width: 100%;
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--mg-bg);
}
#margen-popup .mg-check { font-weight: 500; color: #374151; }
#margen-popup .mg-note { margin: 12px 0; color: #6b7280; font-size: 12px; line-height: 1.4; }
#margen-popup .mg-actions { display: flex; gap: 8px; }
#margen-popup button {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--mg-primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
#margen-popup button.mg-ghost { background: #f3f4f6; color: #111827; }

.mg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-width: 104px;
}
.mg-col__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6b7280;
}
.mg-col__pct {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 2px 8px;
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  background: var(--mg-bg);
  font-weight: 500;
}
.mg-col__input {
  width: 52px;
  border: 0;
  background: transparent;
  text-align: right;
  font-weight: 700;
  padding: 4px 0;
}
.mg-col__sale { color: var(--mg-sale); font-size: 14px; }

.mto-precio-leyenda { display: block; color: #6b7280; font-size: 11px; line-height: 1.3; }
.mto-contador-precio-con-ganancia { font-weight: 750; color: var(--mg-sale); }
