Britain and the European Union agreed terms of a trade deal on Thursday after months of knife-edge negotiations and seven days before transitional arrangements come to an end.