shall be allowed as a credit against the tax imposed by section 3111(a) of the Internal Revenue Code of 1986 for each calendar quarter an amount equal to 100 percent of the qualified public health emergency sick leave wages paid by such employer with respect to such calendar quarter. The preceding sentence shall not apply to any employer for any calendar quarter unless such employer employs an average of fewer than 500 employees on days during such quarter. (b) Limitations and refundability (1) Wages taken into account The amount of qualified public health emergency sick leave wages taken into account under subsection (a) with respect to any individual shall not exceed $511 for any day (or portion thereof) for which the individual is paid qualified sick leave wages. (2) Credit limited to certain employment taxes The credit allowed by subsection (a) with respect to any calendar quarter shall not exceed the tax imposed by section 3111(a) of such Code for such calendar quarter (reduced by any credits allowed under subsections (e) and (f) of section 3111 of such Code for such quarter) on the wages paid with respect to the employment of all employees of the employer. (3) Refundability of excess credit (A) (i) Credit is refundable If the amount of the credit under subsection (a) exceeds the limitation of paragraph (3) for any calendar quarter, such excess shall be treated as an overpayment that shall be refunded under sections 6402(a) and 6413(b) of such Code. (ii) Advancing credit In anticipation of the credit, including the refundable portion under clause (i), the credit may be advanced, according to forms and instructions provided by the Secretary, up to an amount calculated under subsection (a), subject to the limits under subsection (b), both calculated through the end of the most recent payroll period in the quarter. (B) Treatment of payments For purposes of section 1324 of title 31, United States Code, any amounts due to an employer under this paragraph shall be treated in the same manner as a refund due from a