/* ============================================================
   NEOX DS v2 — klasy komponentow. BUDOWANY PRZYROSTOWO per epik
   (DS-1: powloka). Zrodlo: design-handoff/reference/styles.css
   + v2/styles-v2.css. NIE wklejac calosci na raz — globalne klasy
   (.btn/.badge/.input) wchodza dopiero z podmiana markup (DS-2/3),
   inaczej koliduja z bootstrapem (225 uzyc .btn w repo).
   .stage/.canvas (oprawa makiet) — ZAKAZANE (AGENT-INSTRUCTIONS).
   ============================================================ */

/* ===== DS-1: powloka (styles.css 127-338: .app/topbar/sidebar/main) ===== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "brand topbar"
    "side  main";
  height: 100%;
  overflow: hidden;
}

/* ============================================================
   Topbar
   ============================================================ */
.brandcell {
  grid-area: brand;
  display: flex; align-items: center; gap: 11px;
  padding: 0 18px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.logo {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 62%, #7b3ff0));
  box-shadow: var(--shadow-sm);
  letter-spacing: -.5px;
}
.brandname { font-weight: 700; font-size: 15.5px; letter-spacing: -.2px; }
.brandname b { color: var(--accent-text); }

.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}
.modtabs { display: flex; gap: 2px; }
.modtab {
  display: flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 13px; border-radius: var(--pill);
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 14px; font-weight: 600;
  transition: background .14s, color .14s;
}
.modtab:hover { background: var(--surface-2); color: var(--text); }
.modtab.active { background: var(--accent-soft); color: var(--accent-text); }
.modtab svg { width: 17px; height: 17px; }

.topspacer { flex: 1; }

.util { display: flex; align-items: center; gap: 6px; }
.vline { width: 1px; height: 24px; background: var(--divider); margin: 0 4px; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  color: var(--text-muted); transition: background .14s, color .14s, border-color .14s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.iconbtn svg { width: 19px; height: 19px; }

.ghostlink {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
  border-radius: 9px; color: var(--text-muted); font-size: 13.5px; font-weight: 600;
  background: transparent; border: 0; cursor: pointer; text-decoration: none;
}
.ghostlink:hover { background: var(--surface-2); color: var(--text); }
.ghostlink svg { width: 15px; height: 15px; }

.cochip {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 11px;
  border: 1px solid var(--border); border-radius: var(--pill); cursor: pointer;
  background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 700;
  letter-spacing: .3px;
}
.cochip:hover { border-color: var(--border-strong); }
.cochip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.cochip svg { width: 15px; height: 15px; color: var(--text-faint); }

.userchip {
  display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 6px 0 4px;
  border-radius: var(--pill); cursor: pointer; background: transparent; border: 0;
}
.userchip:hover { background: var(--surface-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .2px;
}
.userchip .who { text-align: left; line-height: 1.2; flex: none; }
.userchip .who .nm { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.userchip .who .em { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  grid-area: side;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 12px 24px;
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--sidebar-bg); }

.modhead {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px; margin-bottom: 6px;
}
.modhead .mi {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: var(--accent-text);
  background: var(--accent-soft);
}
.modhead .mi svg { width: 17px; height: 17px; }
.modhead .mt { font-size: 14.5px; font-weight: 800; letter-spacing: .2px; }
.modhead .ms { font-size: 11px; color: var(--text-faint); font-weight: 600; }

.navgroup { margin-top: 12px; }
.navlabel {
  font-size: 10.5px; font-weight: 700; letter-spacing: .7px;
  text-transform: uppercase; color: var(--text-faint);
  padding: 4px 10px 7px;
}
.navitem {
  display: flex; align-items: center; gap: 11px;
  height: var(--nav-h); padding: 0 10px; border-radius: 9px;
  color: var(--text-muted); font-size: 13.5px; font-weight: 550;
  cursor: pointer; position: relative; border: 0; background: transparent; width: 100%;
  transition: background .13s, color .13s;
}
.navitem:hover { background: var(--surface-2); color: var(--text); }
.navitem > span:not(.nb) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem svg { width: 18px; height: 18px; flex: none; color: var(--text-faint); transition: color .13s; }
.navitem:hover svg { color: var(--text-muted); }
.navitem.active {
  background: var(--accent-soft); color: var(--accent-text); font-weight: 700;
}
.navitem.active svg { color: var(--accent); }
.navitem.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.navitem .nb {
  margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text-faint);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: var(--pill);
}
.navitem.active .nb { color: var(--accent-text); background: var(--surface); border-color: var(--accent-ring); }

/* ============================================================
   Główna treść
   ============================================================ */
.main {
  grid-area: main;
  overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.content {
  flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  padding: 22px 26px 0;
}

/* Page header */
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-faint); font-weight: 600; }
.crumbs a { color: var(--text-faint); text-decoration: none; }
.crumbs a:hover { color: var(--text-muted); }
.crumbs .sep { opacity: .5; }
.crumbs .cur { color: var(--text-muted); }

.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; margin: 10px 0 18px;
}
.pagetitle { font-size: 27px; font-weight: 800; letter-spacing: -.6px; margin: 4px 0 5px; }
.pagesub { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 9px; }
.pagesub .chiplet {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: var(--accent-text);
  font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: var(--pill);
}
.pagesub .chiplet .x { cursor: pointer; opacity: .7; }
.pagesub .chiplet .x:hover { opacity: 1; }

.actions { display: flex; align-items: center; gap: 9px; }

/* Search */
.search {
  display: flex; align-items: center; gap: 8px; height: 38px; width: 250px;
  padding: 0 12px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-muted);
  transition: border-color .14s, box-shadow .14s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search svg { width: 17px; height: 17px; flex: none; }
.search input {
  border: 0; outline: 0; background: transparent; width: 100%;
  font-size: 13.5px; color: var(--text);
}
.search input::placeholder { color: var(--text-faint); }
.search kbd {
  font-family: inherit; font-size: 11px; font-weight: 700; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}

/* Buttons */

/* ===== DS-1: toaster + impbar (styles-v2.css) ===== */
/* ============================================================
   TOAST / NOTYFIKACJA  (NeoxNotification)
   ============================================================ */
.toaster {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px; width: 360px; max-width: calc(100% - 36px);
}
.toast {
  position: relative; display: flex; align-items: flex-start; gap: 11px; overflow: hidden;
  padding: 13px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
  animation: toastin .26s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } }
.toast .t-ic { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.toast .t-ic svg { width: 17px; height: 17px; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-size: 13.5px; font-weight: 700; letter-spacing: -.1px; }
.toast .t-msg { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.toast .t-x { flex: none; width: 26px; height: 26px; border-radius: 7px; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; display: grid; place-items: center; }
.toast .t-x:hover { background: var(--surface-2); color: var(--text); }
.toast .t-prog { position: absolute; left: 0; bottom: 0; height: 2.5px; background: currentColor; opacity: .5; animation: tprog 4s linear forwards; }
@keyframes tprog { from { width: 100%; } to { width: 0%; } }
.toast-ok   { color: var(--ok); }      .toast-ok   .t-ic { background: var(--ok-bg); color: var(--ok); }
.toast-err  { color: var(--danger); }  .toast-err  .t-ic { background: var(--danger-bg); color: var(--danger); }
.toast-info { color: var(--accent-text); } .toast-info .t-ic { background: var(--accent-soft); color: var(--accent-text); }
.toast .t-title, .toast .t-msg { color: var(--text); }
.toast .t-msg { color: var(--text-muted); }

/* ============================================================
   CONFIRM DIALOG  (NeoxConfirmDialog) — mały modal + wariant destrukcyjny
   Używa .overlay/.modal z styles.css.
   ============================================================ */
.modal.modal-confirm { width: 440px; }
.confirm-body { padding: 22px; display: flex; gap: 15px; align-items: flex-start; }
.confirm-ic { width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.confirm-ic svg { width: 21px; height: 21px; }
.confirm-confirm .confirm-ic { background: var(--danger-bg); color: var(--danger); }
.confirm-t { font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
.confirm-s { font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

/* ============================================================
   PASEK IMPERSONACJI  (ImpersonationBanner) — nad topbarem
   ============================================================ */
.impbar {
  height: var(--impbar-h, 34px); flex: none;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: color-mix(in srgb, var(--warn) 22%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 44%, var(--surface));
  color: color-mix(in srgb, var(--warn) 92%, var(--text));
  font-size: 12.5px; font-weight: 650;
}
.impbar svg { width: 15px; height: 15px; flex: none; }
.impbar b { font-weight: 800; }
.impbar .grow { flex: 1; }
.impbar .imp-exit {
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); background: transparent;
  color: inherit; font-weight: 700; font-size: 12px; height: 24px; padding: 0 10px;
  border-radius: var(--pill); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.impbar .imp-exit:hover { background: color-mix(in srgb, var(--warn) 16%, transparent); }
/* gdy aktywny: .app dostaje dodatkowy wiersz nad brand/topbar — patrz PATTERNS-v2.md */
.app.has-impbar { grid-template-rows: var(--impbar-h, 34px) var(--topbar-h) 1fr; grid-template-areas: "imp imp" "brand topbar" "side main"; }
.app.has-impbar .impbar { grid-area: imp; }


/* ===== DS-1: sidebar collapsed (COMPONENTS-v2 "Sidebar — stan collapsed") ===== */
.app.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed, 56px) 1fr; }
.sidebar.collapsed { overflow-x: hidden; }
.sidebar.collapsed .modhead .mt,
.sidebar.collapsed .modhead .ms,
.sidebar.collapsed .navitem > span:not(.nb),
.sidebar.collapsed .nb { display: none; }
.sidebar.collapsed .navitem { justify-content: center; padding-left: 0; padding-right: 0; }
/* DS: wyrownaj WSZYSTKIE ikony railu do wspolnej osi (logo/modhead/items/zwiń-menu).
   Bez tego modhead (padding 10) i sidebar-foot (padding 8) odstawaly w prawo. Zglos. PO. */
.sidebar.collapsed .modhead { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
.sidebar.collapsed .sidebar-foot { padding-left: 0; padding-right: 0; }
.sidebar.collapsed .navlabel {
  font-size: 0; padding: 0; margin: 10px 12px;
  border-top: 1px solid var(--border-color);
}
.sidebar.collapsed .navitem.active { box-shadow: inset 2px 0 0 var(--accent-blue); }
/* Tooltip dla zwinietego sidebara obsluguje budget-tooltip.js (render do body —
   nie obcinany przez .sidebar.collapsed overflow). CSS ::after usuniety. */

/* ===== DS-1: stopka sidebara (toggle collapse — nasz dodatek do spec) ===== */
.sidebar-foot {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--border-color);
}
.sidebar-foot .navitem { width: 100%; }

/* ===== DS-2a: przyciski (.btn/.iconbtn — styles.css 339-356). UWAGA: globalne —
   nadpisuja bootstrapowe .btn w portalu/BUDDY (swiadoma decyzja: spojnosc DS) ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 10px; cursor: pointer;
  font-size: 13.5px; font-weight: 650; border: 1px solid transparent;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-press); }
.btn-ghost { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger-ghost { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
.btn-danger-ghost:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-bg); }
.btn .cnt { background: rgba(255,255,255,.22); border-radius: var(--pill); font-size: 11px; padding: 0 6px; font-weight: 700; }
.btn-ghost .cnt { background: var(--accent-soft); color: var(--accent-text); }


/* ===== DS-2a: badge (styles.css 757-776) + warianty v2 (STATUS-MAPPING) ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--pill);
  border: 1px solid transparent; white-space: nowrap;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok      { color: var(--ok);     background: var(--ok-bg);     border-color: var(--ok-border); }
.badge-info    { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-ring); }
.badge-neutral { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }
.badge-warn    { color: var(--warn);  background: color-mix(in srgb, var(--warn) 13%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 28%, var(--surface)); }
.badge-danger  { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 28%, var(--surface)); }
/* badge źródła (outline, prostokątny) */
.badge-src {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-muted);
}


/* nowe warianty v2 — STATUS-MAPPING.md */
.badge-verified {
  color: #fff;
  background: var(--accent-green);
  border-color: color-mix(in srgb, var(--accent-green) 70%, #000);
}
.badge-archived {
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}
.badge-archived::before {
  content: ""; width: 6px; height: 6px; border-radius: 1px;
  background: var(--text-muted);
}
.badge-cancelled {
  color: var(--accent-red);
  background: transparent;
  border-color: color-mix(in srgb, var(--accent-red) 34%, transparent);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* ===== DS-2b: pasek filtrow + pigulki (styles.css 358-384) ===== */
   Pasek filtrów
   ============================================================ */
.filterbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter {
  display: inline-flex; align-items: center; gap: 8px; height: 36px;
  padding: 0 11px; border-radius: 9px; cursor: pointer; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; color: var(--text); transition: border-color .14s;
}
.filter:hover { border-color: var(--border-strong); }
.filter .fl { color: var(--text-faint); font-weight: 600; }
.filter .fv { font-weight: 650; }
.filter svg { width: 15px; height: 15px; color: var(--text-faint); }
.filter.on { border-color: var(--accent-ring); background: var(--accent-softer); }
.filter.on .fl { color: var(--accent-text); }
.filter.on .fv { color: var(--accent-text); }
.filter .clear { color: var(--text-faint); display: grid; place-items: center; }
.filter .clear:hover { color: var(--text); }
.reset {
  border: 0; background: transparent; cursor: pointer; color: var(--text-muted);
  font-size: 13px; font-weight: 650; padding: 0 8px; height: 36px; border-radius: 8px;
}
.reset:hover { color: var(--accent-text); }


/* ===== DS-2b: filter multi-select popover (styles-v2 27-58) + .cbx (v1 446-453) ===== */
/* ============================================================
   FILTR MULTI-SELECT — pigułka z licznikiem + popover checkboxów
   ============================================================ */
.filter .fcount {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--pill); background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 800;
}
.filter.on .fcount { background: var(--accent); color: #fff; }
.filterpop {
  position: absolute; z-index: 40; margin-top: 6px; width: 256px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.fpop-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--divider); }
.fpop-search {
  flex: 1; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  padding: 0 10px; font-size: 13px; color: var(--text); outline: 0;
}
.fpop-list { max-height: 248px; overflow: auto; padding: 5px; }
.fopt {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text);
}
.fopt:hover { background: var(--surface-2); }
.fopt .cbx { width: 16px; height: 16px; }
.fopt .fo-count { margin-left: auto; font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.fpop-foot { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--divider); }
.fpop-foot .lnk { background: 0; border: 0; cursor: pointer; color: var(--text-muted); font-size: 12.5px; font-weight: 650; padding: 0; }
.fpop-foot .lnk:hover { color: var(--accent-text); }
.fpop-foot .grow { flex: 1; }

.cbx {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong);
  background: var(--surface); cursor: pointer; display: grid; place-items: center;
  transition: background .12s, border-color .12s; flex: none;
}
.cbx svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.cbx.ck { background: var(--accent); border-color: var(--accent); }
.cbx.ck svg { opacity: 1; }

/* .lnk — tekstowy przycisk w stopce popovera */
.lnk { background:none; border:none; color: var(--accent-text); font-size:12.5px; font-weight:650; cursor:pointer; padding:2px 4px; }
.lnk:hover { text-decoration: underline; }

/* ===== DS-2b: skin toastow Radzen na tokenach DS (NeoxNotification = wrapper
   na RadzenNotification/NotificationService w ~15 pages — pelna podmiana na
   wlasny .toast = DS-7/8; tu wyglad zgodny z DS bez ruszania serwisu) ===== */
.rz-notification-message {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-pop) !important;
  font-family: inherit !important;
}
.rz-notification-message.rz-notification-success { border-left: 3px solid var(--accent-green) !important; }
.rz-notification-message.rz-notification-error   { border-left: 3px solid var(--accent-red) !important; }
.rz-notification-message.rz-notification-info    { border-left: 3px solid var(--accent-blue) !important; }
.rz-notification-message.rz-notification-warning { border-left: 3px solid var(--accent-orange) !important; }

/* ===== DS-4a: modal (.overlay/.modal/.formsec — styles.css 511-616) ===== */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, #0a0e16 52%, transparent);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  width: 640px; max-width: 100%; max-height: 808px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop .2s cubic-bezier(.2,.9,.3,1.1);
  /* Neutralizacja bootstrapowego .modal (position:fixed;top/left:0;height:100%;
     display:none) — bootstrap laduje sie PRZED neox-ds, ale definiuje wlasciwosci
     ktorych spec DS nie deklarowal, wiec "przeciekaly": fixed+left:0 wyrywalo modal
     z grid-centering overlaya (lewa krawedz), height:100% dawalo puste powietrze
     (zgloszenie PO 2026-06-12). */
  position: relative;
  top: auto; left: auto;
  height: auto;
  pointer-events: auto;  /* bs5 daje none na .modal */
}
@keyframes pop { from { transform: translateY(10px) scale(.985); } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--divider);
}
.modal-head .mh-ic {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: var(--accent-text); background: var(--accent-soft);
}
.modal-head .mh-ic svg { width: 20px; height: 20px; }
.modal-head .mh-t { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
.modal-head .mh-s { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.modal-head .x {
  margin-left: auto; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; border: 0; background: transparent;
  color: var(--text-faint); cursor: pointer;
}
.modal-head .x:hover { background: var(--surface-2); color: var(--text); }
.modal-head .x svg { width: 19px; height: 19px; }

.modal-body { padding: 6px 22px 8px; overflow-y: auto; }
.formsec { padding: 16px 0; }
.formsec + .formsec { border-top: 1px solid var(--divider); }
.seclabel {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 13px;
}
.seclabel svg { width: 14px; height: 14px; }

.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 650; color: var(--text); }
.field label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 11.5px; color: var(--text-faint); }

.input, .selectbox {
  height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; outline: 0; width: 100%;
  transition: border-color .14s, box-shadow .14s;
}
.input::placeholder { color: var(--text-faint); }
.input:focus, .selectbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.inputwrap { position: relative; display: flex; align-items: center; }
.inputwrap .ia { position: absolute; left: 12px; color: var(--text-faint); display: grid; place-items: center; pointer-events: none; }
.inputwrap .ia svg { width: 17px; height: 17px; }
.inputwrap .input { padding-left: 38px; }

.selectbox {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.selectbox .sv { flex: 1; }
.selectbox .sv.ph { color: var(--text-faint); }
.selectbox svg { width: 17px; height: 17px; color: var(--text-faint); }
.selectbox .savatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; }
.selectbox .clr { color: var(--text-faint); display: grid; place-items: center; }
.selectbox .clr:hover { color: var(--text); }

/* segmented control for status */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.seg button {
  flex: 1; height: 34px; border: 0; border-radius: 8px; cursor: pointer; background: transparent;
  font-size: 13px; font-weight: 650; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button .sd { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button.on.ok { color: var(--ok); }

.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 22px; border-top: 1px solid var(--divider); background: var(--surface-2);
}
.modal-foot .req-note { font-size: 12px; color: var(--text-faint); }
.modal-foot .grow { flex: 1; }

/* error toast (echo of original Blazor error, restyled) */
.errbar {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 11px; margin-bottom: 14px;
  background: var(--danger-bg); border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--surface));
  color: color-mix(in srgb, var(--danger) 88%, var(--text)); font-size: 13px; font-weight: 600;
}
.errbar svg { width: 18px; height: 18px; flex: none; color: var(--danger); }
.errbar .ec { margin-left: auto; cursor: pointer; opacity: .7; display: grid; place-items: center; }
.errbar .ec:hover { opacity: 1; }

/* DS-8: pusty stan strony/pivota z CTA (wycentrowany, ten sam język co ModuleAccessGate) */
.emptyst { display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 24px; gap: 4px; min-height: 240px; }
.emptyst .es-ic { color: var(--text-muted); margin-bottom: 10px; }
.emptyst .es-ic svg { width: 38px; height: 38px; }
.emptyst .es-t { font-size: 15px; font-weight: 650; color: var(--text-primary); }
.emptyst .es-d { font-size: 13px; color: var(--text-secondary); max-width: 380px; }
.emptyst .es-cta { margin-top: 16px; }

/* responsive — kanwa ma stałe 1440px, więc układ nie kolapsuje */


/* ===== DS-4b: lewa kolumna pagehead (tytul + pagesub) — nasz wrapper ===== */
.pagehead-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pagehead .nph-spacer { flex: 1; }

/* ===== DS-4d: tabela natywna table.grid (zrodlo: reference/styles.css 388-507) =====
   .cbx pominiete — juz w sekcji DS-2b. Konsumowane przez NeoxTable (pilot /hr). */
.tablewrap {
  flex: 1; min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex; flex-direction: column;
  margin-bottom: 18px;
}
.tablescroll { overflow: auto; flex: 1; }
.tablescroll::-webkit-scrollbar { width: 11px; height: 11px; }
.tablescroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--surface); }

table.grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  text-align: left; padding: 11px 13px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-faint); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.grid thead th .thc { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
table.grid thead th.sortable .thc { cursor: pointer; }
table.grid thead th .sort { opacity: 0; transition: opacity .12s; color: var(--text-muted); display: inline-flex; }
table.grid thead th.sortable:hover .sort { opacity: 1; }
table.grid thead th svg { width: 13px; height: 13px; }

.colcheck { width: 44px; padding-left: 18px !important; padding-right: 0 !important; }
.colstatus { width: 116px; }
.colact { width: 52px; }

table.grid tbody td {
  padding: var(--cell-py) 13px; height: var(--row-h);
  border-bottom: 1px solid var(--divider);
  font-size: 13.5px; color: var(--text); vertical-align: middle;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr.sel { background: var(--accent-softer); }
table.grid tbody tr.sel:hover { background: var(--accent-soft); }
table.grid tbody tr:last-child td { border-bottom: 0; }

.cellmuted { color: var(--text-muted); }
.celldash { color: var(--text-faint); }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* person cell */
.person { display: flex; align-items: center; gap: 11px; }
.person .avatar { width: 34px; height: 34px; font-size: 12.5px; }
.person .pn { line-height: 1.25; min-width: 0; }
.person .pn .nm { font-weight: 650; letter-spacing: -.1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .pn .em { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tag/pill cells */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.cc {
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  color: var(--text-muted);
}
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 4px 11px 4px 9px; border-radius: var(--pill);
  background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-border);
}
.status .sd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.rowact {
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--text-faint); cursor: pointer; opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
table.grid tbody tr:hover .rowact { opacity: 1; }
.rowact:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.rowact svg { width: 17px; height: 17px; }

/* table footer */
.tablefoot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; color: var(--text-muted);
}
.pager { display: flex; align-items: center; gap: 4px; }
.pgbtn {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  font-size: 12.5px; font-weight: 650; display: grid; place-items: center;
}
.pgbtn:hover { border-color: var(--border-strong); color: var(--text); }
.pgbtn.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.pgbtn svg { width: 15px; height: 15px; }

/* selection bar */
.selbar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 14px; margin-bottom: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent-ring); border-radius: 11px;
  font-size: 13px; color: var(--accent-text); font-weight: 600;
}
.selbar .sgrow { flex: 1; }
.selbar .lnk { background: 0; border: 0; cursor: pointer; color: var(--accent-text); font-weight: 700; font-size: 13px; }
.selbar .lnk:hover { text-decoration: underline; }


/* ===== DS-4e: master-child + karty szczegolow (zrodlo: styles.css 617-755) ===== */
/* ============================================================
   WZORZEC MASTER–CHILD
   ============================================================ */
.mc { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mc-master { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.mc-master .tablewrap { margin-bottom: 0; }

/* uchwyt zmiany proporcji master/child */
.splitter {
  flex: none; height: 16px; display: grid; place-items: center; cursor: row-resize;
}
.splitter::before {
  content: ""; width: 46px; height: 4px; border-radius: 99px;
  background: var(--border-strong); transition: background .14s;
}
.splitter:hover::before { background: var(--accent); }

/* panel child zadokowany pod master */
.child {
  flex: none; height: 380px;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.child-head {
  flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 8px 0 16px; height: 50px;
  border-bottom: 1px solid var(--divider); background: var(--surface);
}
.child-eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text-faint);
}
.child-title { font-size: 14.5px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; }
.child-title .sub { font-weight: 600; color: var(--text-muted); }
.child-head .grow { flex: 1; }
.child-x {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center; border: 0; background: transparent;
  color: var(--text-faint); cursor: pointer;
}
.child-x:hover { background: var(--surface-2); color: var(--text); }
.child-x svg { width: 18px; height: 18px; }

/* linia podsumowania (np. Symbol / NIP / Saldo) */
.child-summary {
  flex: none; display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--divider);
  background: var(--surface-2); font-size: 12.5px; color: var(--text-muted);
}
.child-summary b { color: var(--text); font-weight: 700; }
.child-summary .sm-k { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-faint); margin-right: 6px; }
.child-summary .neg { color: var(--danger); font-weight: 800; }

/* toolbar akcji w nagłówku/sekcji child */
.child-toolbar {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-bottom: 1px solid var(--divider); background: var(--surface);
}
.child-toolbar .ct-title {
  font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--text-faint);
}
.child-toolbar .grow { flex: 1; }

/* ciało child */
.child-body { flex: 1; min-height: 0; overflow: auto; }
.child-body.pad { padding: 16px; background: var(--surface-2); }
.child-body::-webkit-scrollbar { width: 11px; height: 11px; }
.child-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--surface); }

/* taby child (podkreślenie) */
.ctabs { display: flex; align-items: center; gap: 2px; height: 50px; overflow-x: auto; }
.ctab {
  position: relative; height: 50px; padding: 0 13px; border: 0; background: transparent;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.ctab:hover { color: var(--text); }
.ctab.on { color: var(--accent-text); font-weight: 700; }
.ctab.on::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2.5px;
  border-radius: 3px 3px 0 0; background: var(--accent);
}
.ctab .ctb {
  font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: var(--pill);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-faint);
}
.ctab.on .ctb { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent-text); }

/* taby strony (segment-pigułka) */
.ptabs { display: inline-flex; gap: 3px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--pill); }
.ptab {
  height: 30px; padding: 0 14px; border: 0; border-radius: var(--pill); cursor: pointer; background: transparent;
  font-size: 13px; font-weight: 650; color: var(--text-muted);
}
.ptab:hover { color: var(--text); }
.ptab.on { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }

/* ============================================================
   KARTY SZCZEGÓŁÓW (klucz–wartość)
   ============================================================ */
.cardrow { display: grid; gap: 14px; }
.cardrow.c2 { grid-template-columns: 1fr 1fr; }
.cardrow.c3 { grid-template-columns: 1fr 1fr 1fr; }

.dcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px 16px 6px;
}
.dcard-label {
  font-size: 10.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 8px;
}
.dcard.center { text-align: center; padding-top: 18px; }
.dcard .big-avatar {
  width: 64px; height: 64px; border-radius: 50%; margin: 4px auto 10px;
  display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 700;
}
.dcard .big-name { font-size: 16px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 12px; }

.kv {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  padding: 9px 0; border-top: 1px solid var(--divider); font-size: 13px;
}
.kv:first-of-type { border-top: 0; }
.dcard.center .kv { text-align: left; }
.kv .k { color: var(--text-muted); }
.kv .v { font-weight: 650; text-align: right; }
.kv .v.accent { color: var(--accent-text); }
.kv .v a { color: var(--accent-text); text-decoration: none; }

/* miniatura przełożonego */
.mgrline { display: flex; align-items: center; gap: 11px; padding: 6px 0 12px; }
.mgrline .avatar { width: 38px; height: 38px; font-size: 13px; }
.mgrline .ml-n { font-weight: 700; font-size: 13.5px; }
.mgrline .ml-e { font-size: 12px; color: var(--text-faint); }


/* DS-4e helpery: referencja uzywa inline height 34 na przyciskach child-toolbar;
   disabled tylko na btn-ghost w spec — uogolniamy na wszystkie warianty. */
.btn-sm { height: 34px; padding: 0 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Brand: logotyp NEOX v2 (wwwroot/brand/, brand_handoff_neox_logo_v2) =====
   Wordmark v2 zawiera pierscien jako "O" → w topbarze sam wordmark (bez osobnego
   sygnetu — inaczej podwojny pierscien). Dark domyslny (:root = dark), light po
   [data-theme]; collapsed sidebar (56px) → sam sygnet neox-v2-mark.svg (przezroczysty
   pierscien, bez kafelka). */
.brandcell .brand-mark { display: none; width: 26px; height: 26px; }
.brandcell .word-light { display: none; }
[data-theme="light"] .brandcell .word-dark { display: none; }
[data-theme="light"] .brandcell .word-light { display: block; }
.app.sidebar-collapsed .brandcell { padding: 0; justify-content: center; }
.app.sidebar-collapsed .brandcell .brand-word { display: none; }
.app.sidebar-collapsed .brandcell .brand-mark { display: block; }
/* zwiniety rail (56px) → sam sygnet; wersja + "Co nowego" ukryte */
.app.sidebar-collapsed .brandcell .neox-whatsnew { display: none; }

/* DS-7: solidny btn-danger dla destrukcyjnych CTA (potwierdzenie usuniecia w
   NeoxConfirmDialog). Spec ma tylko btn-danger-ghost; solid = mirror btn-primary
   w kolorze danger — czytelny jako akcja niebezpieczna. */
.btn-danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn-danger:disabled { opacity: .5; cursor: not-allowed; }

/* ===== DS-5: W-E macierz/pivot + W-F macierz uprawnien (zrodlo: v2/styles-v2.css 222-305) =====
   table.matrix: frozen L+P, komorka 2-warstwowa .mcell, tfoot sum+subnote, legenda;
   .permcell — zetony poziomow dla /hr/security. */
/* min-width:0 + width:100% w calym lancuchu: bez tego szeroka table.matrix
   (12 mc + frozen) rozpycha kolumne grid/flex zamiast scrollowac wewnatrz
   .matrixscroll — wtedy scrolluje cala strona i sticky frozen-right/tfoot
   "ucieka" (zgloszenie PO: brak suwaka, YTD/Odch i sumy znikaja). */
.matrixwrap { flex: 1; min-height: 0; min-width: 0; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; margin-bottom: 18px; }
.matrixscroll { overflow: auto; flex: 1; min-width: 0; width: 100%; }
.matrixscroll::-webkit-scrollbar { width: 11px; height: 11px; }
.matrixscroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--surface); }

table.matrix { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 100%; }
table.matrix thead th {
  position: sticky; top: 0; z-index: 3; background: var(--surface-2);
  padding: 9px 12px; text-align: right; white-space: nowrap;
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--text-faint);
  border-bottom: 1px solid var(--border); border-left: 1px solid var(--divider);
}
table.matrix col.col-cat  { width: 280px; }
table.matrix col.col-mon  { width: 104px; }
table.matrix col.col-ytd  { width: 132px; }

/* frozen: pierwsza kolumna (kategoria) i ostatnia (YTD) */
table.matrix .frz-l { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; border-left: 0; box-shadow: 1px 0 0 var(--border); }
table.matrix thead .frz-l { z-index: 4; background: var(--surface-2); }
table.matrix .frz-r { position: sticky; right: 0; z-index: 2; background: var(--surface); box-shadow: -1px 0 0 var(--border); }
table.matrix thead .frz-r { z-index: 4; background: var(--surface-2); }
.col-ytd-cell, table.matrix thead th.frz-r { background: var(--accent-softer) !important; }

table.matrix tbody td {
  height: var(--row-h); padding: 4px 12px; text-align: right; vertical-align: middle;
  border-bottom: 1px solid var(--divider); border-left: 1px solid var(--divider);
  font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums;
}
table.matrix tbody tr:hover td { background: var(--surface-2); }
table.matrix tbody tr:hover .frz-l, table.matrix tbody tr:hover .frz-r { background: var(--surface-2); }
table.matrix tbody td.cat { text-align: left; font-weight: 650; }
table.matrix tbody td.cat .sub { font-weight: 500; color: var(--text-faint); font-size: 11.5px; }

/* komórka 2-warstwowa: actual (pełny) nad predicted (wyciszony) */
.mcell { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.15; }
.mcell .m-actual { font-weight: 650; }
.mcell .m-pred   { font-size: 11px; color: var(--text-faint); }
.mcell.over .m-actual { color: var(--danger); }      /* przekroczenie planu */
.mcell.empty { color: var(--text-faint); }

/* footer 2-poziomowy: SUMY + „niezadekretowane FK" */
table.matrix tfoot td {
  position: sticky; bottom: 0; z-index: 2; background: var(--surface-2);
  padding: 8px 12px; text-align: right; font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--border); border-left: 1px solid var(--divider);
}
table.matrix tfoot tr.sum td { font-weight: 800; font-size: 13px; border-top: 2px solid var(--border-strong); }
table.matrix tfoot tr.subnote td { font-weight: 600; font-size: 11.5px; color: var(--text-muted); }
/* Dwurzedowa stopka (budget-execution, sales-actuals): SUMY + subnote oba
   sticky bottom:0 -> nakladaly sie (subnote zaslanial SUMY). Ukladamy w stos:
   subnote na samym dole, SUMY tuz nad nim o wysokosc subnote'a. Jednorzedowe
   stopki (budget-plan/sales-plan/vacations) bez tr.subnote zostaja na bottom:0. */
table.matrix tfoot tr.subnote td { bottom: 0; height: 44px; }
table.matrix tfoot:has(tr.subnote) tr.sum td { bottom: 44px; }
table.matrix tfoot td.frz-l { text-align: left; z-index: 3; }
table.matrix tfoot td.frz-r { z-index: 3; }
table.matrix tfoot tr.sum td.frz-r { background: var(--accent-soft); color: var(--accent-text); }

/* nagłówek miesiąca: nazwa + mały podpis */
.mhdr { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.mhdr .mh-sub { font-size: 9px; font-weight: 600; color: var(--text-faint); letter-spacing: .2px; }

/* legenda actual/predicted */
.matrix-legend { display: flex; align-items: center; gap: 16px; font-size: 11.5px; color: var(--text-muted); }
.matrix-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.matrix-legend .sw { width: 18px; height: 3px; border-radius: 2px; background: var(--text); }
.matrix-legend .sw.pred { background: var(--text-faint); }

/* ============================================================
   WZORZEC W-F — MACIERZ UPRAWNIEŃ (role × encje)
   Reużywa table.matrix (frozen-left + sticky thead). Komórka = żeton poziomu.
   ============================================================ */
table.matrix td.perm { text-align: center; padding: 4px 8px; }
table.matrix col.col-role { width: 128px; }
.permcell {
  display: inline-grid; place-items: center; min-width: 46px; height: 26px; padding: 0 10px;
  border-radius: var(--pill); font-size: 11.5px; font-weight: 800; letter-spacing: .3px;
  border: 1px solid transparent;
}
.permcell.lvl-none { color: var(--text-faint); background: transparent; font-weight: 600; }
.permcell.lvl-r    { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }
.permcell.lvl-rw   { color: var(--accent-text); background: var(--accent-softer); border-color: var(--accent-ring); }
.permcell.lvl-rwd  { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-ring); }
.permcell.lvl-full { color: #fff; background: var(--ok); border-color: color-mix(in srgb, var(--ok) 70%, #000); }
.perm-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); }
.perm-legend .pl { display: inline-flex; align-items: center; gap: 7px; }

/* DS-5 helper (nasz dodatek): druga frozen kolumna od prawej (np. YTD przed Odch.).
   right = szerokosc ostatniej kolumny; sticky right wymaga jawnego offsetu. */
table.matrix .frz-r2 { position: sticky; right: 104px; z-index: 2; background: var(--surface); }
table.matrix thead .frz-r2, table.matrix tfoot .frz-r2 { z-index: 4; background: var(--surface-2); }
/* DS-5 helper: trzecia linia komorki (variance %) — dane z obecnego ekranu, spec ma 2 warstwy */
.mcell .m-var { font-size: 10px; font-weight: 600; }
.mcell .m-var.neg { color: var(--danger); }
.mcell .m-var.pos { color: var(--ok); }

/* DS-5 helper: zaznaczony wiersz macierzy (master-child na /hr/vacations) */
table.matrix tbody tr.sel td { background: var(--accent-softer); }
table.matrix tbody tr.sel:hover td { background: var(--accent-soft); }
