Look at this simple circuit modeled in LTSpice. The top plot pane shows three voltages V(x), Y(y), and (V(x)-V(y)), and the current in the circuit I(R1), {same as I(C1) and -I(V1)}.
Y(y) is in phase with I(R1); you would expect lots of power to be dissipated in R1. On the other hand, look at the phase relationship between (V(x)-V(y)) and I(R1). Notice that they are in phase quadrature, so you would expect the capacitor power to be zero.
The lower plot pane shows the a plot of the Power=E*I (as found using the thermometer gimmick) of the source V1, the capacitor C1, and the resistor R1. Remember that -I(V1) = I(C1) = I(R1)!
Using the CTRL-left-mouse-click on the Power waveforms gets us these three integrals:
Note that the source supplies 236.7uW, the capacitor power is 6.6uW and the resistor dissipates 230uW. So how can the capacitor take real power of 6.6uW? Note the start-up transient; it takes a bit for the waves to stabilize, during which the capacitor charges. It takes power to charge the capacitor which it might eventually give back. However, I specified the integration interval to be only three cycles, so it took 6.6uW to charge the capacitor....
LTSpice does the right thing; we just have to be smart enough to appreciate that...