Finding a book that marries a truly dark fantasy world with a detective's procedural grind can be a tough ask, but it's so rewarding when you find one. I'm not talking about a cozy mystery with a wizard sidekick, but something where the setting itself is a character that bleeds into the investigation. Ben Aaronovitch's 'Rivers of London' series often gets recommended, and while it's fun, it's more of a police procedural with magical elements—the London setting isn't fundamentally broken or grim. For a darker, more integrated feel, I'd point you towards China Miéville's 'Perdido Street Station'. The detective element is there with Isaac's investigation into the slake-moth attacks, but the investigation is as much about navigating the grotesque, oppressive reality of New Crobuzon as it is about solving a crime. The world feels alive and sick, and the stakes are visceral and horrifying.
Another one that comes to mind is 'The City & the City' by the same author. It's less traditional fantasy and more speculative fiction, but the central premise—two cities occupying the same physical space, with citizens trained to 'unsee' the other—creates a uniquely tense and paranoid investigative atmosphere. The darkness here is bureaucratic, psychological, and deeply ingrained in the society itself. The detective, Borlú, has to navigate not just a murder but the fundamental rules of reality as his people understand them. It's a slower, more cerebral burn than monster-hunting, but the sense of unease it builds is masterful.