Shell-model description of very neutron-deficient Pd and Cd nuclei