Next.js: global CSS import in wrong component
After adding a new sheet, there is an error regarding the location of the global CSS or the order of styles. The rules for importing global styles depend on Pages Router, App Router and Bundler configuration.
How to identify the source of the problem
Check if the project uses app or pages directory and in which component global import appears. Identify the conflict of two global sheets and the order of their charging after navigation.
Compare the message from the console with the result of the production compilation and the condition after the page has been refreshed.
Repair steps
Move global styles to the right entry point framework or use CSS Modules for single components. If the conflict is due to the order of styles, simplify the dependency and set a coherent import point for the entire site.
How to Test Solution
Build and navigation between subpages do not report CSS error, and appearance does not depend on entry order.
Security and restrictions
Don't turn all styles into !important, because it hides the conflict instead of solving it.