The Ekman Layer
Since the fluid is homogeneous (constant density $\rho$) $$ \frac{\partial}{\partial z}\!\left(\frac{\partial p}{\partial x}\right) = \frac{\partial}{\partial x}\!\left(\frac{\partial p}{\partial z}\right) = \frac{\partial}{\partial y}\!\left(\frac{\partial p}{\partial z}\right) = 0 \Rightarrow \frac{\partial}{\partial z}\left(\frac{\partial p}{\partial x}\right) = \frac{\partial}{\partial z}\left(\frac{\partial p}{\partial y}\right) = 0 $$ This means the horizontal pressure gradient is independent of $z$, so the same $\partial p / \partial x$ and $\partial p / \partial y$ apply throughout the fluid column
At $z \to \infty$, from boundary conditions $ \boxed{ u = U, v = 0, w = 0 (z \to \infty)}$ $$ u \to U, \quad v \to 0 $$ Thus, the $x$- and $y$-momentum balances give $$ 0 = -\frac{1}{\rho}\frac{\partial p}{\partial x}, \qquad fU = -\frac{1}{\rho}\frac{\partial p}{\partial y} $$ The horizontal pressure gradient is set by the geostrophic velocity $U$ far from the boundary
Since the horizontal pressure gradient does not depend on $z$, \(\boxed{0 = -\frac{1}{\rho}\frac{\partial p}{\partial x}, fU = -\frac{1}{\rho}\frac{\partial p}{\partial y}}\) must hold for all $z$, not just at infinity Rewrite the horizontal momentum equations as $$ f \tilde{u} = A_v \frac{d^2 \tilde{v}}{dz^2}, \qquad -f \tilde{v} = A_v \frac{d^2 \tilde{u}}{dz^2} $$
$$ \tilde{u} = u - U, \quad \tilde{v} = v $$ are the departures from geostrophic flow induced by friction and the rigid boundary

1 Pedlosky, J. (1982). Geophysical Fluid Dynamics. Springer study edition. Springer, Berlin, Heidelberg.