I want to apply CSS to all pages except sidebars. Let me show you an example
.page #buddypress ul.group li
You can override all css for that element by using its ID (css id overrides css class). A possibility would be:
#id{all:unset}
However, this has limited browser support and your specified element should have an ID.
See also: https://stackoverflow.com/a/36892781/9204431
Try this code
div:not(.sidebar) ul.group li {
border: 1px solid red;
}
// Here i have used div, but you can use whatever tag you have used for sidebar
<body class="page">
<div class="sidebar">
<ul class="group">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
<div class="page-section">
<ul class="group">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
</body>