A common framework for fermion mass hierarchy, leptogenesis and dark matter