/* Reset i prymitywy układu stron, szkielet aplikacji (pasek boczny, treść). */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 14px; line-height: 1.4; }
body { font-family: var(--font-body); color: var(--color-text); background: var(--color-bg); }
h1, h2, h3 { font-family: var(--font-heading); }
h1 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -0.01em; font-weight: 700; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
a { color: var(--color-accent); }
a:hover { color: var(--color-accent-strong); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.page-header { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; justify-content: space-between; }
.page-header__text { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.page-header__crumbs, .page-header__meta { font-size: 13px; color: var(--color-muted); min-width: 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; position: relative; }
.table-wrap > table { min-width: 720px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

[hidden] { display: none !important; }

/* Szkielet aplikacji: pasek boczny + treść */
.app { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--color-sidebar); color: var(--color-sidebar-text); padding: var(--space-5) var(--space-4); border: 0; display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; overflow: auto; position: sticky; top: 0; height: 100vh; }
.sidebar a { color: var(--color-sidebar-text); text-decoration: none; }
.brand { display: flex; align-items: center; min-height: var(--touch-min); gap: 10px; padding: 0 var(--space-2); font-family: var(--font-heading); font-weight: 700; font-size: 18px; color: var(--color-white); }
.sidebar .brand { color: var(--color-white); }
.sidebar__nav { display: flex; flex-direction: column; gap: var(--space-1); }
.sidebar__nav a { display: flex; align-items: center; min-height: var(--touch-min); padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; }
.sidebar__nav a:hover, .tree__node:hover { background: var(--color-sidebar-raised); }
.sidebar__nav a[aria-current='page'] { background: var(--color-sidebar-selected); color: var(--color-white); }
.sidebar__label { padding: 0 var(--space-2); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-sidebar-muted); }
.sidebar__error { color: var(--color-sidebar-bad); font-size: 13px; }
.sidebar-filters { display: grid; gap: var(--space-3); }
.sidebar-filters label { display: grid; gap: var(--space-1); color: var(--color-sidebar-muted); font-size: 12px; }
.sidebar-filters select, .sidebar-filters input { min-height: var(--touch-min); padding: 0 var(--space-3); border-radius: var(--radius-md); border: 0; background: var(--color-sidebar-raised); color: var(--color-white); font: inherit; font-size: 14px; color-scheme: dark; }
.sidebar-filters button { min-height: var(--touch-min); border-radius: var(--radius-md); border: 1px solid var(--color-sidebar-line); background: transparent; color: var(--color-sidebar-text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.sidebar-filters button:hover { background: var(--color-sidebar-raised); }

.tree, .tree ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.tree ul { margin: 2px 0 6px var(--space-3); padding-left: var(--space-3); border-left: 1px solid var(--color-sidebar-line); }
.tree__node { display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch-min); padding: 0 var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.tree__toggle { width: var(--touch-min); height: var(--touch-min); margin: 0 -10px 0 -14px; display: inline-flex; align-items: center; justify-content: center; color: var(--color-sidebar-muted); border: 0; background: transparent; font: inherit; cursor: pointer; flex: none; }
.tree__label { flex: 1; min-width: 0; overflow-wrap: break-word; color: inherit; align-self: stretch; display: flex; align-items: center; }
.tree__count { color: var(--color-sidebar-muted); font-size: 12px; white-space: nowrap; }
.sidebar a.tree__label { color: inherit; }
.tree__node--selected, .tree__node--selected:hover { background: var(--color-sidebar-selected); color: var(--color-white); }
.tree__node--selected[data-route^='order/'], .tree__node--selected[data-route^='order/']:hover { background: var(--color-sidebar-active-bg); color: var(--color-sidebar-active-text); font-weight: 600; }
.tree__node--selected[data-route^='order/'] .tree__count, .tree__node--selected[data-route^='order/'] .tree__toggle { color: var(--color-sidebar-active-text); }
.tree__node--warn { color: var(--color-sidebar-warn); }
.tree__status { font-size: 12px; white-space: nowrap; }
.tree__status--ok { color: var(--color-sidebar-ok); }
.tree__status--warn { color: var(--color-sidebar-warn); }
.tree__status--bad { color: var(--color-sidebar-bad); }
.tree__node--selected[data-route^='order/'] .tree__status { color: var(--color-sidebar-active-text); }
.tree__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--color-sidebar-ok); }
.tree__dot--warn { background: var(--color-sidebar-warn); }
.tree__dot--bad { background: var(--color-sidebar-bad); }
.tree__note { padding: var(--space-2) var(--space-3); color: var(--color-sidebar-muted); font-size: 13px; }
.tree__note--bad { color: var(--color-sidebar-bad); }

.model-block { margin-top: auto; padding: var(--space-3); border-radius: var(--radius-xl); background: var(--color-sidebar-raised); font-size: 13px; display: flex; flex-direction: column; gap: var(--space-2); }
.model-block__label { color: var(--color-sidebar-muted); }
.model-block select { min-height: var(--touch-min); padding: 0 var(--space-2); border-radius: var(--radius-sm); border: 1px solid var(--color-sidebar-line); background: var(--color-sidebar); color: var(--color-white); font-family: var(--font-mono); font-size: 13px; width: 100%; }
.model-block a { color: var(--color-sidebar-accent); font-weight: 600; display: inline-flex; align-items: center; min-height: var(--touch-min); }
.active-model-note { color: var(--color-sidebar-muted); }

.app > main { overflow-wrap: break-word; padding: var(--space-6) var(--space-7); overflow: visible; display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; align-self: start; }
.app > main:focus { outline: none; }
.menu-toggle { display: none; }

@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--touch-min); width: 100%; padding: 0 var(--space-4); border: 0; background: var(--color-sidebar); color: var(--color-white); font: inherit; font-weight: 600; cursor: pointer; }
  .sidebar { display: none; position: static; height: auto; }
  .sidebar.is-open { display: flex; }
  .app > main { padding: var(--space-5) var(--space-4); }
  h1 { font-size: 28px; }
}

.muted { color: var(--color-muted); }
.nowrap { white-space: nowrap; }
.tone-bad { color: var(--color-bad); font-weight: 600; }
.section-title { margin: 0; font-size: 15px; }

/* Ukryte zamówienia: oznaczone tekstem "Ukryte" i przygaszone kolorem (nie tylko kolorem). */
.sidebar-filters .check { display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch-min); font-size: 14px; color: var(--color-sidebar-text); cursor: pointer; }
.sidebar-filters .check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--color-sidebar-accent); }
.tree__node--hidden { color: var(--color-sidebar-muted); font-style: italic; }
.tree__hidden { font-size: 11px; font-weight: 600; font-style: normal; padding: 1px 6px; border-radius: var(--radius-pill); border: 1px solid var(--color-sidebar-muted); color: var(--color-sidebar-muted); white-space: nowrap; }
.is-hidden-row td { color: var(--color-muted); }
.is-hidden-row td a { color: var(--color-muted); }
