Costco Wholesale (NASDAQ:COST) has been on a roll for the past two years, reporting a string of enviable sales gains. This culminated in a stellar 8.5% adjusted comp sales increase for the retail month of November. Sales trends have been even stronger in the U.S., where adjusted comp sales rose 10.1% last month.

However, despite this strong and growing sales momentum, Costco stock has fallen into a rut recently. Prior to the company's recent earnings report, the shares had already fallen significantly from the all-time high of $245.16 reached in September. Costco stock has plummeted another 11% in the two trading days since the earnings release last Thursday.

COST Chart

Costco Wholesale year-to-date stock performance, data by YCharts.

Investors appear to be worried about some modest margin pressure Costco is currently experiencing. However, their concerns are probably unfounded, and the recent pullback represents an attractive opportunity to invest in Costco stock.

The headline numbers for the first quarter

Costco reported a stellar 7.5% adjusted comp sales gain for the first quarter of fiscal 2019. (The adjustments remove the impact of gasoline price fluctuations, exchange-rate volatility, and new revenue recognition rules.)

Meanwhile, earnings per share surged 19% to $1.73. Excluding various one-time tax items and a change in the estimated redemption rate for cash rewards issued in conjunction with Costco's co-branded credit-card program, adjusted EPS rose 18% year over year to $1.61, coming in just shy of the average analyst estimate of $1.62.

Digging into the earnings report

The potentially worrisome news in Costco's earnings report was that its gross margin declined by 50 basis points year over year. (There are 100 basis points in 1 percentage point.) Concerns about margin erosion are the only logical explanation for Costco stock's recent plunge.

The entrance to a Costco warehouse

Costco's gross margin fell last quarter. Image source: Costco Wholesale.

However, half of the deterioration was driven by gasoline price inflation and revenue recognition changes. Most of the remainder can be traced to changes in the company's merchandise mix over the past year. According to CFO Richard Galanti, Costco's core gross margin slipped just 6 basis points year over year when each merchandise category is compared to the same in the year-ago period.

On the cost side, operating expenses kept pace with sales growth, again adjusting for gasoline price inflation and the revenue recognition change. This expense performance was particularly impressive because Costco handed out big wage increases earlier this year.

The net result was that Costco's operating income declined by $2 million (0.2%) on a GAAP basis. Excluding the credit-card rewards accounting adjustment -- which totaled $43 million -- operating income would have risen 4.3% to $992 million.

Keeping members happy is the most important thing

Costco typically generates the vast majority of its operating income from membership fees. Last quarter was no exception, as membership fee income rose 9.5% year over year to $758 million. Costco members are extremely loyal. In the U.S. and Canada (Costco's mature markets), the renewal rate is more than 90%.

Members renew year after year because they trust Costco to offer the lowest possible prices. Costco's long-running $1.50 hot dog plus soda combo and its $4.99 rotisserie chickens are just two examples of the company's commitment to holding down prices. This commitment means that from time to time, the warehouse club giant faces margin pressure as it absorbs cost increases for one product or another.

However, investors shouldn't confuse this with a lack of pricing power. Over a period of decades, Costco has demonstrated that it can raise prices when it needs to do so -- which has led to exceptional stability in its gross margin performance.

COST Gross Profit Margin (TTM) Chart

Costco Wholesale Gross Profit Margin (TTM), data by YCharts. TTM = trailing 12 months.

Costco's strong sales growth, remarkable member loyalty, massive global growth opportunities, and steady profitability all support a premium valuation for Costco stock. After their recent pullback, the shares are more affordable than they have been in quite a while. Costco stock currently trades for about 26 times the company's projected fiscal 2019 EPS.

The recent downtrend in gross margin won't last forever. When it turns around -- and assuming that sales and membership trends remain strong -- Costco stock could rebound quickly.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.