/* =========================================================================
   MedicalBot — app.css
   Single source of truth dla design systemu.
   Wdrożenie: projekt Blazor, .NET 8. Statyczny zasób, linkowany z _Host.cshtml.
   Struktura pliku:
     1. :root — design tokens (kolory, spacing, radius, typo, z-index, breakpointy)
     2. Reset + base styles
     3. Layout primitives (shell, sidebar, content)
     4. Components (buttons, inputs, selects, tables, badges, alerts, cards, modal)
     5. Module-specific (chat, access matrix)
   Zasada: komponenty NIE używają hard-codowanych wartości — tylko zmienne z :root.
   ========================================================================= */


/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root {
  /* --- Color · Brand (granat ZARYS) ------------------------- */
  --color-brand-50:  #eef2f8;
  --color-brand-100: #d9e2ef;
  --color-brand-200: #b4c3db;
  --color-brand-300: #7e97bd;
  --color-brand-400: #4c6a97;
  --color-brand-500: #1e3358;
  --color-brand-600: #172845;
  --color-brand-700: #0f1d36;  /* sidebar bg */
  --color-brand-800: #0a1528;
  --color-brand-900: #050a18;

  /* Aliasy semantyczne — używaj ich w komponentach */
  --color-brand:         var(--color-brand-700);
  --color-brand-hover:   var(--color-brand-600);
  --color-brand-active:  var(--color-brand-800);
  --color-brand-accent:  #79b4ff;   /* niebieski akcent dla active state w sidebarze */

  /* --- Color · Neutral (warm slate) ------------------------- */
  --color-neutral-0:   #ffffff;
  --color-neutral-50:  #f6f7f9;   /* background app */
  --color-neutral-100: #eef0f4;   /* background sub (sidebar rozmów w chacie) */
  --color-neutral-200: #e3e6eb;   /* borders subtle */
  --color-neutral-300: #ced2da;   /* borders default */
  --color-neutral-400: #9aa0ad;   /* muted text, placeholders */
  --color-neutral-500: #6b7180;   /* secondary text */
  --color-neutral-600: #4a4f5c;
  --color-neutral-700: #2e323c;
  --color-neutral-800: #1d2027;   /* primary text */
  --color-neutral-900: #0d0f14;

  /* --- Color · State --------------------------------------- */
  --color-success-50:  #edf8f1;
  --color-success-100: #d1ecdb;
  --color-success-500: #1f9254;
  --color-success-700: #155d37;

  --color-warning-50:  #fdf6e4;
  --color-warning-100: #f8e7b0;
  --color-warning-500: #a77905;
  --color-warning-700: #6b4d02;

  --color-danger-50:   #fdeceb;
  --color-danger-100:  #f8cfcc;
  --color-danger-500:  #c42b1c;
  --color-danger-700:  #8a1c11;

  --color-info-50:     #eaf3fb;
  --color-info-100:    #c9e0f5;
  --color-info-500:    #1572cb;
  --color-info-700:    #0f548f;

  /* --- Color · Semantic aliases (używaj w komponentach) ----- */
  --color-bg:             var(--color-neutral-50);
  --color-bg-sub:         var(--color-neutral-100);
  --color-surface:        var(--color-neutral-0);
  --color-surface-raised: var(--color-neutral-0);

  --color-text-primary:   var(--color-neutral-800);
  --color-text-secondary: var(--color-neutral-500);
  --color-text-muted:     var(--color-neutral-400);
  --color-text-inverse:   var(--color-neutral-0);
  --color-text-brand:     var(--color-brand-700);
  --color-text-link:      var(--color-brand-600);
  --color-text-danger:    var(--color-danger-500);

  --color-border:         var(--color-neutral-200);
  --color-border-strong:  var(--color-neutral-300);
  --color-border-focus:   var(--color-brand-500);

  /* --- Spacing (skala 4px) --------------------------------- */
  --space-2xs: 2px;
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  12px;
  --space-lg:  16px;
  --space-xl:  24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 64px;

  /* --- Radius --------------------------------------------- */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* --- Typography ----------------------------------------- */
  --font-sans: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Code", monospace;

  --font-size-2xs:  10px;   /* captions, labels mono, counts */
  --font-size-xs:   11px;   /* metadata, timestamps */
  --font-size-sm:   12px;   /* small body, table cells dense */
  --font-size-base: 13px;   /* default UI text */
  --font-size-md:   14px;   /* body copy, primary text */
  --font-size-lg:   15px;   /* lede, card titles */
  --font-size-xl:   17px;   /* section headings */
  --font-size-2xl:  24px;   /* page H2 */
  --font-size-3xl:  32px;   /* page H1 */
  --font-size-4xl:  40px;

  --font-weight-regular:  400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;

  --line-height-tight:   1.2;    /* headings */
  --line-height-snug:    1.35;   /* UI elements, buttons */
  --line-height-normal:  1.5;    /* body */
  --line-height-relaxed: 1.65;   /* long-form (odpowiedzi chatu) */

  --letter-spacing-tight:  -0.02em;   /* duże nagłówki */
  --letter-spacing-snug:   -0.01em;   /* średnie nagłówki */
  --letter-spacing-normal: 0;
  --letter-spacing-wide:   0.04em;
  --letter-spacing-wider:  0.08em;    /* uppercase labels */
  --letter-spacing-widest: 0.12em;    /* uppercase eyebrow labels */

  /* --- Elevation ----------------------------------------- */
  --shadow-xs: 0 1px 2px rgba(15, 29, 54, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 29, 54, 0.06), 0 1px 3px rgba(15, 29, 54, 0.04);
  --shadow-md: 0 4px 8px rgba(15, 29, 54, 0.06), 0 2px 4px rgba(15, 29, 54, 0.04);
  --shadow-lg: 0 8px 20px rgba(15, 29, 54, 0.08), 0 4px 8px rgba(15, 29, 54, 0.04);
  --shadow-xl: 0 20px 40px rgba(15, 29, 54, 0.12), 0 8px 16px rgba(15, 29, 54, 0.06);

  /* --- Focus ring --------------------------------------- */
  --focus-ring-width: 3px;
  --focus-ring-color: rgba(30, 51, 88, 0.25);
  --focus-ring:       0 0 0 var(--focus-ring-width) var(--focus-ring-color);

  /* --- Motion ------------------------------------------- */
  --ease-out:    cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast:   120ms;
  --duration-normal: 200ms;
  --duration-slow:   320ms;

  /* --- Layout dimensions -------------------------------- */
  --shell-sidebar-width:      248px;
  --shell-content-max-width:  1360px;
  --shell-topnav-max-width:   1360px;
  --chat-convo-sidebar-width: 260px;
  --chat-message-max-width:   780px;
  --login-card-max-width:     420px;

  /* --- Breakpoints (do użycia w @media) ------------------ */
  /* uwaga: CSS nie wspiera var() w @media — te stałe są tylko referencją dla dev */
  /* --breakpoint-sm: 640px; --breakpoint-md: 768px; --breakpoint-lg: 1024px; --breakpoint-xl: 1280px; */

  /* --- Z-index scale ------------------------------------ */
  --z-base:     0;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  800;
  --z-modal:    900;
  --z-toast:    1000;
  --z-tooltip:  1100;
}


/* ============================================================
   2. RESET + BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

h1, h2, h3, h4, h5, h6, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; padding: 0; cursor: pointer; }
a { color: var(--color-text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: var(--focus-ring-width) solid var(--color-border-focus); outline-offset: 2px; border-radius: var(--radius-xs); }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}


/* ============================================================
   3. LAYOUT — SHELL
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--color-bg);
}

/* --- Topnav (granatowy pasek główny) -------------------- */
.app-topnav {
  background: var(--color-brand-700);
  flex-shrink: 0;
  z-index: var(--z-sticky);
}
.app-topnav__inner {
  max-width: var(--shell-topnav-max-width);
  margin: 0 auto;
  height: 52px;
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  gap: 28px;
}
.app-topnav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}
.app-topnav__logo {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--color-neutral-0);
  color: var(--color-brand-700);
  display: grid; place-items: center;
  font-weight: var(--font-weight-bold);
  font-size: 14px;
  flex-shrink: 0;
}
.app-topnav__brand-name {
  color: var(--color-neutral-0);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.005em;
}
.app-topnav__version {
  font-size: var(--font-size-2xs);
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: var(--letter-spacing-wider);
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
}
.app-topnav__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.app-topnav__sep {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.14);
  margin: 0 10px;
  flex-shrink: 0;
}
.app-topnav__label {
  display: inline-grid;
}
.app-topnav__label > * {
  grid-area: 1 / 1;
}
.app-topnav__label-ghost {
  font-weight: var(--font-weight-semibold);
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}
.app-topnav__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.app-topnav__link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--color-neutral-0);
  text-decoration: none;
}
.app-topnav__link.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-neutral-0);
  font-weight: var(--font-weight-semibold);
}
.app-topnav__link:focus-visible {
  outline: 2px solid var(--color-brand-accent);
  outline-offset: -2px;
}
.app-topnav__right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* --- Subnav (biały pasek modułu) ------------------------ */
.app-subnav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.app-subnav__inner {
  max-width: var(--shell-topnav-max-width);
  margin: 0 auto;
  height: 44px;
  padding: 0 var(--space-xl);
  display: flex;
  align-items: stretch;
}
.app-subnav__inner nav {
  display: flex;
  align-items: stretch;
}
/* Linki w subnavie — override stylów ciemnego sidebara */
.app-subnav__inner .app-nav__link--sub {
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  padding: 0 14px;
  border-radius: 0;
  margin: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  transition: color var(--duration-fast) var(--ease-out);
}
.app-subnav__inner .app-nav__link--sub:hover {
  background: transparent;
  color: var(--color-text-primary);
}
.app-subnav__inner .app-nav__link--sub[aria-current="page"] {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
  background: transparent;
  border-bottom: 2px solid var(--color-brand-700);
}
.app-subnav__inner .app-nav__link--sub[aria-current="page"]::before {
  display: none;
}
.app-subnav__inner .app-nav__link--sub[aria-disabled="true"] {
  color: var(--color-text-muted);
  cursor: not-allowed;
  pointer-events: none;
}
.app-subnav__inner .app-nav__count {
  background: var(--color-neutral-100);
  color: var(--color-text-muted);
}

/* --- Nav links (subnav modułów) -------------------------- */
.app-nav__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: var(--space-sm) 10px;
  margin: 1px 0;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.app-nav__link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-neutral-0);
  text-decoration: none;
}
.app-nav__link:focus-visible {
  outline: 2px solid var(--color-brand-accent);
  outline-offset: -2px;
}
.app-nav__link[aria-current="page"],
.app-nav__link.is-active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--color-neutral-0);
  font-weight: var(--font-weight-medium);
}
.app-nav__link[aria-current="page"]::before,
.app-nav__link.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--color-brand-accent);
  border-radius: 2px;
}
.app-nav__link[aria-disabled="true"] {
  color: rgba(255, 255, 255, 0.28);
  cursor: not-allowed;
  pointer-events: none;
}

.app-nav__link--sub {
  color: rgba(255, 255, 255, 0.66);
  font-size: var(--font-size-sm);
  padding-left: var(--space-md);
}
.app-nav__link--sub:hover { color: rgba(255, 255, 255, 0.92); }


.app-env {
  display: flex; align-items: center; gap: 7px;
  font-size: var(--font-size-2xs);
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
  padding: 0 var(--space-xs);
}
.app-env__pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45);
  animation: env-pulse 2s var(--ease-out) infinite;
}
@keyframes env-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45); }
  100% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
}

.app-user {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-sm) var(--space-sm) 10px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.app-user:hover { background: rgba(255, 255, 255, 0.07); }
.app-user:focus-visible { outline: 2px solid var(--color-brand-accent); outline-offset: 2px; }
.app-user__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-brand-accent), var(--color-brand-500));
  color: var(--color-neutral-0);
  display: grid; place-items: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}
.app-user__meta { min-width: 0; }
.app-user__name {
  color: var(--color-neutral-0);
  font-size: 12.5px;
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-snug);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-user__role {
  color: rgba(255, 255, 255, 0.5);
  font-size: 10.5px;
  font-family: var(--font-mono);
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-user__menu-btn {
  color: rgba(255, 255, 255, 0.5);
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
}
.app-user__menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-neutral-0);
}

/* --- Main (content) ------------------------------------ */
.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}
.app-main__scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.app-main__inner {
  max-width: var(--shell-content-max-width);
  margin: 0 auto;
  width: 100%;
}
.app-main__inner--fill {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.app-page {
  padding: 40px var(--space-3xl);
  max-width: var(--shell-content-max-width);
}

/* --- Page header ---------------------------------------- */
.page-crumbs {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-sm);
  letter-spacing: var(--letter-spacing-wide);
}
.page-crumbs__current { color: var(--color-text-primary); }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 28px;
}
.page-header__actions {
  display: flex; gap: var(--space-sm);
  align-items: center;
  flex-shrink: 0;
}

.page-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-tight);
  line-height: var(--line-height-tight);
  max-width: 720px;
}
.page-lede {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  max-width: 620px;
  margin-top: 10px;
  line-height: 1.55;
}
/* Wariant kompaktowy — rozmiarowo zgodny z nagłówkami stron DataQuality (cat/st/ob-head: 2xl/md). */
.page-header--compact .page-title { font-size: var(--font-size-2xl); letter-spacing: var(--letter-spacing-snug); }
.page-header--compact .page-lede { font-size: var(--font-size-md); }

/* --- KPI strip ----------------------------------------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 20px 0;
  margin: var(--space-2xl) 0;
}
.kpi {
  padding: 0 var(--space-xl);
  border-right: 1px solid var(--color-border);
}
.kpi:last-child { border-right: none; }
.kpi:first-child { padding-left: 0; }
.kpi__label {
  font-size: var(--font-size-2xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-semibold);
}
.kpi__value {
  font-size: 30px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-tight);
  margin-top: 6px;
  line-height: 1;
  font-feature-settings: "tnum";
}
.kpi__delta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 6px;
  font-family: var(--font-mono);
}


/* ============================================================
   4. COMPONENTS
   ============================================================ */

/* --- Button --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-snug);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn[disabled], .btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.btn--sm { height: 28px; padding: 0 10px; font-size: var(--font-size-sm); }
.btn--lg { height: 40px; padding: 0 18px; font-size: var(--font-size-md); }

/* variants */
.btn--primary {
  background: var(--color-brand);
  color: var(--color-text-inverse);
  border-color: var(--color-brand);
}
.btn--primary:hover:not(:disabled) { background: var(--color-brand-hover); border-color: var(--color-brand-hover); }
.btn--primary:active:not(:disabled) { background: var(--color-brand-active); border-color: var(--color-brand-active); }

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}
.btn--secondary:hover:not(:disabled) { background: var(--color-neutral-50); border-color: var(--color-neutral-400); }
.btn--secondary:active:not(:disabled) { background: var(--color-neutral-100); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn--ghost:hover:not(:disabled) { background: var(--color-neutral-100); color: var(--color-text-primary); }
.btn--ghost:active:not(:disabled) { background: var(--color-neutral-200); }

.btn--danger {
  background: var(--color-danger-500);
  color: var(--color-text-inverse);
  border-color: var(--color-danger-500);
}
.btn--danger:hover:not(:disabled) { background: var(--color-danger-700); border-color: var(--color-danger-700); }

.btn--icon {
  width: 34px; padding: 0;
}
.btn--icon.btn--sm { width: 28px; }

/* loading state */
.btn--loading { position: relative; color: transparent !important; pointer-events: none; }
.btn--loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  color: var(--color-text-inverse);
  animation: btn-spin 0.7s linear infinite;
}
.btn--secondary.btn--loading::after,
.btn--ghost.btn--loading::after { color: var(--color-text-primary); }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* --- Icon button (naked) ------------------------------- */
.icon-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.icon-btn[disabled] { opacity: 0.4; cursor: not-allowed; }


/* --- Input / Textarea / Select ------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field__label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.field__label--required::after {
  content: "*";
  color: var(--color-danger-500);
  font-weight: var(--font-weight-regular);
}
.field__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: var(--line-height-snug);
}
.field__error {
  font-size: var(--font-size-xs);
  color: var(--color-danger-500);
  line-height: var(--line-height-snug);
  display: flex; align-items: center; gap: 5px;
}

.input,
.textarea,
.select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); }

.input:hover:not(:disabled):not([readonly]),
.textarea:hover:not(:disabled):not([readonly]),
.select:hover:not(:disabled) { border-color: var(--color-neutral-400); }

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
}

.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--color-neutral-100);
  color: var(--color-text-muted);
  cursor: not-allowed;
}
.input[readonly], .textarea[readonly] {
  background: var(--color-neutral-50);
  color: var(--color-text-secondary);
  cursor: default;
}

.input.is-error,
.textarea.is-error,
.select.is-error {
  border-color: var(--color-danger-500);
}
.input.is-error:focus,
.textarea.is-error:focus,
.select.is-error:focus {
  box-shadow: 0 0 0 var(--focus-ring-width) rgba(196, 43, 28, 0.2);
}

.textarea { height: auto; min-height: 80px; padding: var(--space-sm) 10px; line-height: var(--line-height-normal); resize: vertical; }

.select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

/* Search input (with icon slot) */
.input--search {
  padding-left: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat;
  background-position: 10px center;
}

/* Checkbox / Radio */
.checkbox, .radio {
  width: 16px; height: 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  appearance: none;
  flex-shrink: 0;
}
.radio { border-radius: 50%; }
.checkbox:hover, .radio:hover { border-color: var(--color-neutral-400); }
.checkbox:focus-visible, .radio:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.checkbox:checked, .radio:checked {
  background: var(--color-brand);
  border-color: var(--color-brand);
}
.checkbox:checked::after {
  content: "";
  width: 9px; height: 5px;
  border: 2px solid var(--color-neutral-0);
  border-top: none; border-right: none;
  transform: translateY(-1px) rotate(-45deg);
}
.radio:checked::after {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-neutral-0);
}
.checkbox:disabled, .radio:disabled { opacity: 0.5; cursor: not-allowed; }


/* --- Badge / Chip ------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 20px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.badge--neutral { background: var(--color-neutral-100); color: var(--color-text-secondary); }
.badge--brand   { background: var(--color-brand-50);  color: var(--color-brand-700); }
.badge--success { background: var(--color-success-50); color: var(--color-success-700); }
.badge--warning { background: var(--color-warning-50); color: var(--color-warning-700); }
.badge--danger  { background: var(--color-danger-50);  color: var(--color-danger-700); }
.badge--info    { background: var(--color-info-50);    color: var(--color-info-700); }

/* Permission chip (None / Read / Write / Admin) */
.perm-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
}
.perm-chip--none  { background: var(--color-neutral-100); color: var(--color-text-muted); }
.perm-chip--user  { background: var(--color-primary-50);  color: var(--color-primary-700); }
.perm-chip--admin { background: var(--color-success-50);  color: var(--color-success-700); }


/* --- Alert ----------------------------------------------- */
.alert {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  align-items: start;
}
.alert__icon { color: var(--color-text-muted); flex-shrink: 0; margin-top: 2px; }
.alert__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin-bottom: 3px;
}
.alert__body {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-normal);
}
.alert--info    { background: var(--color-info-50);    border-color: var(--color-info-100);    }
.alert--info .alert__icon { color: var(--color-info-500); }
.alert--success { background: var(--color-success-50); border-color: var(--color-success-100); }
.alert--success .alert__icon { color: var(--color-success-500); }
.alert--warning { background: var(--color-warning-50); border-color: var(--color-warning-100); }
.alert--warning .alert__icon { color: var(--color-warning-500); }
.alert--danger  { background: var(--color-danger-50);  border-color: var(--color-danger-100);  }
.alert--danger .alert__icon { color: var(--color-danger-500); }


/* --- Card ----------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
}
.card--link {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.card--link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
  text-decoration: none;
}
.card--link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--color-border-focus); }

.card__icon {
  width: 40px; height: 40px;
  border-radius: 9px;
  background: var(--color-brand-50);
  color: var(--color-brand-700);
  display: grid; place-items: center;
  margin-bottom: 14px;
}
.card__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
}
.card__body {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin-top: 6px;
}
.card__foot {
  margin-top: auto;
  padding-top: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-neutral-100);
}
.card__foot-cta { color: var(--color-text-link); font-weight: var(--font-weight-medium); }


/* --- Table ----------------------------------------------- */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-base);
}
.table th, .table td {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.table th {
  background: var(--color-neutral-50);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  white-space: nowrap;
}
.table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}
.table tbody tr:hover { background: var(--color-neutral-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.is-selected { background: var(--color-brand-50); }
.table tbody tr.is-selected:hover { background: var(--color-brand-100); }

/* wiersz z niezapisanymi zmianami */
.table tbody tr.is-dirty {
  background: var(--color-warning-50);
  position: relative;
}
.table tbody tr.is-dirty td:first-child {
  box-shadow: inset 3px 0 0 var(--color-warning-500);
}
.table tbody tr.is-dirty:hover { background: var(--color-warning-100); }

.table__empty {
  padding: var(--space-4xl) var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
}


/* --- Modal ----------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 29, 54, 0.4);
  display: grid;
  place-items: center;
  z-index: var(--z-modal);
  padding: var(--space-xl);
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal__head {
  padding: var(--space-xl) var(--space-xl) var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--space-md);
}
.modal__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
}
.modal__body {
  padding: 0 var(--space-xl) var(--space-xl);
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  overflow-y: auto;
}
.modal__foot {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}


/* --- Auth / Login (split) ------------------------------- */
.auth-layout {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-columns: 50% 50%;
  grid-template-rows: 100%;
  background: var(--color-bg);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.auth-layout > * { min-width: 0; min-height: 0; height: 100%; }

/* --- LEFT: hero with grid pattern, bottom-aligned content -- */
.auth-hero {
  position: relative;
  overflow: hidden;
  color: var(--color-neutral-0);
  background-color: #0a1628;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 64px;
}
.auth-hero__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.15);
  transform-origin: center;
}
.auth-hero__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.auth-hero__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: rgba(255,255,255,.6);
  margin-bottom: var(--space-md);
}
.auth-hero__eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #9ef0c8; box-shadow: 0 0 0 3px rgba(158,240,200,.22);
}
.auth-hero__brand {
  display: flex; align-items: center; gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.auth-hero__logo {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.24);
  display: grid; place-items: center;
  font-weight: var(--font-weight-bold); font-size: var(--font-size-md);
  color: var(--color-neutral-0);
}
.auth-hero__brand-name { font-weight: var(--font-weight-semibold); font-size: var(--font-size-md); }
.auth-hero__brand-meta { color: rgba(255,255,255,.56); font-size: var(--font-size-sm); }
.auth-hero__title {
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: var(--letter-spacing-tight);
  font-weight: var(--font-weight-semibold);
  text-wrap: pretty;
  max-width: 520px;
  margin-bottom: var(--space-lg);
}
.auth-hero__lede {
  font-size: var(--font-size-md);
  color: rgba(255,255,255,.66);
  line-height: var(--line-height-relaxed);
  max-width: 440px;
  margin-bottom: var(--space-2xl);
}
.auth-hero__modules {
  display: flex; flex-direction: column; gap: var(--space-sm);
  max-width: 420px;
}
.auth-hero__module {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--font-size-sm);
  color: rgba(255,255,255,.82);
}
.auth-hero__module-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--letter-spacing-wider);
  text-transform: uppercase;
  color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  text-align: center;
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  justify-self: start;
}

/* --- RIGHT: form panel ------------------- */
.auth-pane {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-3xl) var(--space-2xl);
  background: var(--color-neutral-0);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.auth-card__brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}
.auth-card__logo {
  width: 36px; height: 36px;
  border-radius: var(--radius-lg);
  background: var(--color-brand-700);
  color: var(--color-neutral-0);
  display: grid; place-items: center;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-lg);
}
.auth-card__title {
  font-size: 28px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
  margin-bottom: 6px;
}
.auth-card__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2xl);
}
.auth-form { display: flex; flex-direction: column; gap: var(--space-lg); }

@media (max-width: 767px) {
  .auth-layout {
    display: block;
    position: relative;
  }
  .auth-hero {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
  }
  .auth-hero__content {
    display: none;
  }
  .auth-pane {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    background: transparent;
    padding: var(--space-2xl) var(--space-lg);
  }
  .auth-card {
    background: var(--color-neutral-0);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl) var(--space-xl);
    box-shadow: 0 8px 40px rgba(0,0,0,0.35);
    max-width: 400px;
  }
}


/* ============================================================
   5. MODULE: CHAT
   ============================================================ */
/* Main chat area */
.chat-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px var(--space-2xl);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* Composer */
.composer-wrap {
  padding: var(--space-lg) var(--space-2xl) var(--space-xl);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.composer {
  max-width: var(--chat-message-max-width);
  margin: 0 auto;
  border: 1px solid var(--color-border-strong);
  border-radius: 14px;
  background: var(--color-surface);
  padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-lg);
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: var(--space-sm);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.composer:focus-within {
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
}
.composer__textarea {
  flex: 1;
  font-size: 14.5px;
  color: var(--color-text-primary);
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  line-height: var(--line-height-normal);
  field-sizing: content;
  min-height: 22px;
  max-height: 66px;
  overflow-y: auto;
  padding: 6px 0;
}
.composer__send {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: var(--color-brand);
  color: white;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--duration-fast);
}
.composer__send:hover    { background: var(--color-brand-hover); }
.composer__send:disabled { opacity: 0.4; cursor: not-allowed; }


/* ============================================================
   6. MODULE: ACCESS MATRIX
   ============================================================ */
.access-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.access-toolbar__search { flex: 1; max-width: 320px; }

.access-save-bar {
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  z-index: var(--z-sticky);
}
.access-save-bar__summary {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.access-save-bar__summary strong { color: var(--color-warning-700); font-weight: var(--font-weight-semibold); }
.access-save-bar__actions { display: flex; gap: var(--space-sm); }



/* ============================================================
   7. MODULE: DATAQUALITY
   ============================================================ */

/* --- Status colors (4 states of (leaf, attribute) pair) --- */
:root {
  --dq-global:         var(--color-success-500);
  --dq-global-bg:      var(--color-success-50);
  --dq-global-border:  var(--color-success-100);
  --dq-diff:           var(--color-info-500);
  --dq-diff-bg:        var(--color-info-50);
  --dq-diff-border:    var(--color-info-100);
  --dq-partial:        var(--color-warning-500);
  --dq-partial-bg:     var(--color-warning-50);
  --dq-partial-border: var(--color-warning-100);
  --dq-missing:        var(--color-neutral-400);
  --dq-missing-bg:     var(--color-neutral-100);
  --dq-missing-border: var(--color-neutral-200);
  --dq-optional:        #7c5cf2;
  --dq-optional-bg:     #f1edfd;
  --dq-optional-border: #dccff9;
  --dq-optional-text:   #4f2db4;

  /* --- Katalog liści: paleta paska 6 stanów (4 aliasy + 2 nowe) --- */
  --cat-shared:   var(--dq-global);            /* zieleń   — Wspólne */
  --cat-diff:     var(--dq-diff);              /* błękit   — Różnicujące */
  --cat-partial:  var(--dq-partial);           /* bursztyn — Częściowe */
  --cat-missing:  #c25a4e;                     /* stonowana czerwień — Brakujące (do triażu) */
  --cat-missing-bg:     #f9eceb;               /* tło badge Missing (czerwonawe) */
  --cat-missing-text:   #8a392f;               /* tekst badge Missing */
  --cat-missing-border: #f1d3cf;               /* obwódka badge Missing */
  --cat-skipped:  var(--color-neutral-400);    /* szary    — Pominięte */
  --cat-ignored:  var(--color-neutral-400);    /* szary    — Ignorowane (warsztat liścia) */
  --cat-optional: #a9b6cd;                     /* jasny szaroniebieski — Opcjonalne */
}

/* ============================================================
   7a. KATALOG LIŚCI — płaska, przewijana lista kafelków
   (handoff: docs/design_handoff_catalog_leaves)
   ============================================================ */

/* --- Wspólny kontener treści --- */
/* Szerokość i centrowanie daje już .app-main__inner (max-width: --shell-content-max-width = 1360px).
   .cat-wrap dokłada TYLKO poziomy padding. Bez własnego max-width/margin:auto — inaczej jako
   flex-item z auto-marginesami .cat-wrap kurczy się do szerokości treści (rozjazd: nagłówek/lista
   wąskie, a pasek filtrów na pełną szerokość). */
.cat-wrap { padding: 0 var(--space-3xl); }

/* --- Nagłówek strony --- */
.cat-head { padding: 26px 0 20px; }
.cat-head__crumbs {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
  margin-bottom: var(--space-sm);
}
.cat-head__crumbs strong { color: var(--color-text-primary); font-weight: var(--font-weight-medium); }
.cat-head__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
  line-height: 1.15;
}
.cat-head__lede {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  max-width: 680px;
  margin-top: 8px;
  line-height: 1.55;
}

/* --- Pasek filtrów — sticky --- */
.cat-filterbar {
  position: sticky;
  top: 0;
  z-index: 20;
  /* Nieprzezroczyste tło = pasem koloru strony chowamy listę przewijaną pod spód
     (inaczej treść prześwituje w szczelinie nad panelem i wokół zaokrągleń). */
  background: var(--color-bg);
  padding: var(--space-md) 0 var(--space-sm);
}
.cat-filterbar__panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0 var(--space-lg);
}
.cat-filterbar__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  padding: 12px 0;
}

/* Segmentowany przełącznik statusu (główna oś) */
.seg-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  flex-shrink: 0;
}
.seg-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: none;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.seg-toggle__btn:last-child { border-right: none; }
.seg-toggle__btn:hover:not(.is-active) { background: var(--color-neutral-50); color: var(--color-text-primary); }
.seg-toggle__btn.is-active {
  background: var(--color-brand-700);
  color: var(--color-neutral-0);
  /* Bez zmiany font-weight — pogrubienie poszerzało aktywny przycisk i przesuwało resztę filtrów.
     Aktywny stan wyróżnia już granatowe tło + biały tekst. */
}
.seg-toggle__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.seg-toggle__dot--ready { background: var(--cat-shared); }
.seg-toggle__dot--attention { background: var(--cat-partial); }
.seg-toggle__btn.is-active .seg-toggle__dot--ready { box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.seg-toggle__count {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

.cat-filterbar .select { height: 34px; width: auto; min-width: 132px; flex-shrink: 0; }
.cat-filterbar .select:disabled { opacity: .55; }
.cat-filterbar__search { position: relative; flex: 1; min-width: 200px; }
.cat-filterbar__search .input--search { height: 34px; }

.cat-filterbar__divider { width: 1px; height: 24px; background: var(--color-border); flex-shrink: 0; }

/* Prawa strona: licznik + sort */
.cat-filterbar__right {
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  margin-left: auto;
  flex-shrink: 0;
}
.cat-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.cat-count strong {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.cat-sort {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}
.cat-sort .select { height: 30px; min-width: 0; font-size: var(--font-size-sm); }

/* Legenda 6 stanów — slim, pod filtrami */
.cat-legend {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
  padding: 9px 0 10px;
  border-top: 1px dashed var(--color-neutral-200);
}
.cat-legend__label {
  font-size: var(--font-size-2xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-mono);
}
.cat-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}
.cat-legend__sw {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cat-legend__item small {
  color: var(--color-text-muted);
  font-size: 10px;
}

/* --- Lista kafelków --- */
/* Blok (nie flex+gap) — <Virtualize> wstawia własne spacery i źle współgra z flexowym gap;
   odstęp między kafelkami daje margin-bottom na .cat-leaf. */
.cat-list { padding: 18px 0 56px; }

.cat-leaf {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 15px var(--space-xl) 16px;
  cursor: pointer;
  position: relative;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.cat-leaf:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
}
.cat-leaf:active { transform: translateY(1px); }
.cat-leaf:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--color-border-focus); }

/* Wiersz 1: ścieżka + status */
.cat-leaf__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: 7px;
}
.cat-leaf__path {
  font-family: var(--font-mono);
  font-size: var(--font-size-2xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.cat-leaf__path-sep { color: var(--color-neutral-300); }

.leaf-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-2xs);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  flex-shrink: 0;
}
.leaf-status__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.leaf-status--ready { color: var(--color-success-700); }
.leaf-status--ready .leaf-status__dot { background: var(--cat-shared); }
.leaf-status--attention { color: var(--color-warning-700); }
.leaf-status--attention .leaf-status__dot { background: var(--cat-partial); }

/* Wiersz 2: nazwa + licznik produktów */
.cat-leaf__mid {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: 12px;
}
.cat-leaf__name {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
  color: var(--color-text-primary);
  line-height: 1.25;
}
.cat-leaf__count {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.cat-leaf__count strong {
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

/* Pasek atrybutów — rdzeń wizualny */
.cat-bar {
  display: flex;
  height: 14px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--color-neutral-100);
  width: 100%;
}
.cat-bar__seg {
  height: 100%;
  /* Bez animacji szerokości — segmenty renderują się od razu w pełnej szerokości.
     Zostaje tylko subtelne przejście opacity przy hoverze kafelka. */
  transition: opacity var(--duration-fast) var(--ease-out);
  position: relative;
}
.cat-bar__seg + .cat-bar__seg { box-shadow: -1px 0 0 rgba(255,255,255,.55); }
.cat-bar__seg--shared   { background: var(--cat-shared); }
.cat-bar__seg--diff     { background: var(--cat-diff); }
.cat-bar__seg--partial  { background: var(--cat-partial); }
.cat-bar__seg--missing  { background: var(--cat-missing); }
.cat-bar__seg--skipped  { background: var(--cat-skipped); }
.cat-bar__seg--optional { background: var(--cat-optional); }
.cat-leaf:hover .cat-bar__seg { opacity: .92; }

/* Wiersz 4: akcja (tylko Wymaga uwagi) / dyskretny ✓ (Gotowy) */
.cat-leaf__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: var(--font-size-xs);
}
.cat-leaf__action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--color-warning-700);
  font-weight: var(--font-weight-medium);
}
.cat-leaf__action svg { color: var(--color-warning-500); flex-shrink: 0; }
.cat-leaf__action b { font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; }
.cat-leaf__action-sep { color: var(--color-neutral-300); }
.cat-leaf__done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.cat-leaf__done svg { color: var(--color-success-500); flex-shrink: 0; }
.cat-leaf__open {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--color-text-link);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.cat-leaf:hover .cat-leaf__open { opacity: 1; transform: translateX(0); }

/* --- Stan pusty --- */
.cat-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 72px 24px;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  margin: 18px 0 56px;
}
.cat-empty.is-shown { display: flex; }
.cat-empty__icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-neutral-100);
  color: var(--color-text-muted);
  display: grid; place-items: center;
  margin-bottom: var(--space-lg);
}
.cat-empty__title { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); }
.cat-empty__body {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  max-width: 380px;
  margin: 6px 0 18px;
  line-height: 1.5;
}

/* Full-bleed workbench layout — catalog, gaps use this instead of .app-page */

/* --- Status badge (Global / Differentiating / Partial / Missing) --- */
.dq-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 var(--space-sm) 0 7px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  font-family: var(--font-mono);
  white-space: nowrap;
  border: 1px solid transparent;
}
.dq-status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dq-status--global   { background: var(--dq-global-bg);   color: var(--color-success-700); border-color: var(--dq-global-border); }
.dq-status--global::before { background: var(--dq-global); }
.dq-status--diff     { background: var(--dq-diff-bg);     color: var(--color-info-700);    border-color: var(--dq-diff-border); }
.dq-status--diff::before { background: var(--dq-diff); }
.dq-status--partial  { background: var(--dq-partial-bg);  color: var(--color-warning-700); border-color: var(--dq-partial-border); }
.dq-status--partial::before { background: var(--dq-partial); }
.dq-status--missing  { background: var(--cat-missing-bg);  color: var(--cat-missing-text); border-color: var(--cat-missing-border); }
.dq-status--missing::before { background: var(--cat-missing); }
.dq-status--ignored  { background: var(--color-neutral-100); color: var(--color-neutral-600); border-color: var(--color-neutral-300); }
.dq-status--ignored::before { background: var(--color-neutral-400); }
.dq-status--optional { background: var(--dq-optional-bg); color: var(--dq-optional-text); border-color: var(--dq-optional-border); }
.dq-status--optional::before { background: var(--dq-optional); }

/* --- Ready leaf card --- */

/* --- Ready leaf (v2 — z listą produktów) --- */

/* --- Products list inside leaf (Ready view) --- */

/* --- Gaps master list (leaf row) --- */

/* --- Detail section headers --- */
.dq-section {
  margin-bottom: var(--space-xl);
}
.dq-section__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-sm) 0 10px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-sm);
}
.dq-section__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  letter-spacing: var(--letter-spacing-snug);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  font-size: var(--font-size-xs);
}
.dq-section__desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.dq-section__content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.dq-section--globals .dq-section__title { color: var(--color-success-700); }
.dq-section--partials .dq-section__title { color: var(--color-warning-700); }
.dq-section--ignored .dq-section__title { color: var(--color-text-muted); }

.dq-sku {
  font-family: var(--font-mono);
  font-size: var(--font-size-2xs);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  padding: 3px 7px;
  color: var(--color-text-secondary);
}

/* --- Partial: clickable SKU chips --- */
.dq-sku--clickable {
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}
.dq-sku--clickable:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
  color: var(--color-brand-700);
}
.dq-sku--clickable.is-active {
  border-color: var(--color-brand-500);
  background: var(--color-brand-700);
  color: var(--color-neutral-0);
}
/* ============================================================
   Product Modal (shared chrome + card content)
   ============================================================ */
.pm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 29, 54, 0.4);
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  z-index: var(--z-modal);
  padding: var(--space-xl);
  animation: pm-overlay-in var(--duration-base) var(--ease-out);
}
@keyframes pm-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.pm-modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: min(820px, calc(100% - 64px));
  max-height: 90vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  animation: pm-modal-in var(--duration-base) var(--ease-out);
}
.pm-modal--narrow { width: min(640px, calc(100% - 64px)); }
@keyframes pm-modal-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.pm-head {
  padding: 12px 16px 12px 18px;
  border-bottom: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--color-surface);
  grid-row: 1;
}
.pm-head__nav { display: flex; align-items: center; gap: 2px; }
.pm-head__nav-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  display: inline-grid; place-items: center;
  cursor: pointer; background: transparent; border: none; padding: 0;
}
.pm-head__nav-btn:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.pm-head__nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pm-head__counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  padding: 0 6px; white-space: nowrap;
}
.pm-head__title {
  font-size: 13px; font-weight: 500; color: var(--color-text-secondary);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.pm-head__title strong { color: var(--color-text-primary); font-weight: 600; }
.pm-head__close {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  color: var(--color-text-muted); display: inline-grid; place-items: center;
  cursor: pointer; background: transparent; border: none; padding: 0;
}
.pm-head__close:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.pm-strip {
  display: flex; padding: 8px 14px 10px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg); grid-row: 2; min-width: 0;
}
.pm-strip__scroll {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin;
  padding: 2px 2px 4px; flex: 1;
}
.pm-strip__item {
  flex-shrink: 0; width: 56px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px; border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; transition: background 120ms, border-color 120ms; background: transparent;
}
.pm-strip__item:hover { background: var(--color-neutral-100); }
.pm-strip__item.is-active { border-color: var(--color-brand-500); background: var(--color-brand-50); }
.pm-strip__thumb {
  width: 40px; height: 40px; border-radius: 4px;
  border: 1px solid var(--color-border);
  background: repeating-linear-gradient(45deg,
    var(--color-neutral-100), var(--color-neutral-100) 4px,
    var(--color-neutral-200) 4px, var(--color-neutral-200) 8px);
  display: grid; place-items: center; position: relative;
}
.pm-strip__item.is-active .pm-strip__thumb { border-color: var(--color-brand-500); }
.pm-strip__dot {
  position: absolute; top: -3px; right: -3px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--color-surface);
}
.pm-strip__dot--ready { background: var(--color-success-500); }
.pm-strip__sap {
  font-family: var(--font-mono); font-size: 9px; color: var(--color-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%; text-align: center;
}
.pm-strip__item.is-active .pm-strip__sap { color: var(--color-brand-700); font-weight: 600; }
.pm-body {
  overflow-y: auto; overflow-x: hidden; background: var(--color-surface);
  padding: 22px 28px 28px; grid-row: 3; min-height: 0;
}
.pm-modal__loading {
  padding: var(--space-2xl); text-align: center;
  color: var(--color-text-muted); font-size: var(--font-size-sm); font-family: var(--font-mono);
}
.pm-foot {
  padding: 10px 18px; border-top: 1px solid var(--color-border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--color-bg); gap: 12px; grid-row: 4;
}
.pm-foot__shortcuts {
  display: flex; align-items: center; gap: 14px;
  font-size: 11px; color: var(--color-text-muted);
}
.pm-foot__shortcuts kbd {
  font-family: var(--font-mono); font-size: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong); border-bottom-width: 2px;
  border-radius: 3px; padding: 1px 5px; color: var(--color-text-secondary); margin: 0 1px;
}
.pm-foot__actions { display: flex; gap: 8px; }


/* ============================================================
   8. MODULE: LEARNING
   ============================================================ */

/* ---- Conversations list (.learn-*) ----------------------- */

.learn-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-lg);
}
.learn-toolbar .input--search { max-width: none; }
.learn-toolbar .select { min-width: 0; }

.learn-success {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  font-family: var(--font-mono);
  white-space: nowrap;
  border: 1px solid transparent;
}
.learn-success::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.learn-success--ok      { background: var(--color-success-50);  color: var(--color-success-700); border-color: var(--color-success-100); }
.learn-success--ok::before      { background: var(--color-success-500); }
.learn-success--fail    { background: var(--color-danger-50);   color: var(--color-danger-700);  border-color: var(--color-danger-100); }
.learn-success--fail::before    { background: var(--color-danger-500); }
.learn-success--pending { background: var(--color-neutral-100); color: var(--color-text-secondary); border-color: var(--color-border); }
.learn-success--pending::before { background: var(--color-neutral-400); }

.learn-q {
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  line-height: var(--line-height-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 360px;
}

.learn-user { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.learn-user__avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--color-brand-100);
  color: var(--color-brand-700);
  display: grid; place-items: center;
  font-size: 10.5px;
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}
.learn-user__name { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); }

.learn-row { cursor: pointer; }
.learn-row td:first-child {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.learn-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.learn-strip__cell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px var(--space-lg);
}
.learn-strip__label {
  font-size: var(--font-size-2xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-semibold);
}
.learn-strip__value {
  font-size: 24px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-tight);
  margin-top: 4px;
  font-feature-settings: "tnum";
  line-height: 1.1;
}
.learn-strip__delta { font-size: var(--font-size-xs); color: var(--color-text-muted); font-family: var(--font-mono); margin-top: 2px; }

.learn-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.learn-pager__pages { display: flex; gap: 2px; }
.learn-pager__btn {
  min-width: 28px; height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  cursor: pointer;
  background: transparent;
}
.learn-pager__btn:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.learn-pager__btn.is-active {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

/* ---- Conversation detail (.ld-*) ------------------------- */

.ld-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  height: 100%;
  min-height: 0;
}
.ld-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--color-bg);
}
.ld-side {
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.ld-bar {
  padding: 14px var(--space-2xl);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
  flex-shrink: 0;
}
.ld-bar__back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
  margin-bottom: 4px;
  text-decoration: none;
}
.ld-bar__back:hover { color: var(--color-text-primary); text-decoration: none; }
.ld-bar__title { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); line-height: 1.2; }
.ld-bar__meta { font-size: var(--font-size-xs); color: var(--color-text-muted); font-family: var(--font-mono); margin-top: 3px; }
.ld-bar__nav { display: flex; gap: var(--space-xs); flex-shrink: 0; align-items: center; }

.ld-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl) 0 var(--space-2xl);
  min-height: 0;
}
.ld-wrap {
  max-width: var(--chat-message-max-width);
  margin: 0 auto;
  padding: 0 var(--space-2xl);
}

.ld-eval { padding: var(--space-xl); display: flex; flex-direction: column; gap: var(--space-xl); }
.ld-eval__group { display: flex; flex-direction: column; gap: var(--space-sm); }
.ld-eval__label {
  font-size: var(--font-size-2xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-semibold);
}

.ld-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}
.ld-segmented__btn {
  padding: 8px 10px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border-top: none; border-bottom: none; border-left: none;
  border-right: 1px solid var(--color-border);
  background: transparent;
  transition: background var(--duration-fast) var(--ease-out);
}
.ld-segmented__btn:last-child { border-right: none; }
.ld-segmented__btn:hover { background: var(--color-neutral-50); }
.ld-segmented__btn.is-active { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.ld-segmented__btn--ok.is-active   { background: var(--color-success-50); color: var(--color-success-700); }
.ld-segmented__btn--fail.is-active { background: var(--color-danger-50);  color: var(--color-danger-700); }

.ld-divider { height: 1px; background: var(--color-border); margin: 0; }


/* ============================================================
   9. BLAZOR COMPONENT HELPERS
   ============================================================ */

/* Blazor reconnect overlay — opóźnienie 1500 ms ukrywa flash przy przejściach między modułami.
   Po upływie czasu modal pojawia się normalnie (prawdziwa utrata połączenia). */
#components-reconnect-modal.components-reconnect-show {
  animation: reconnect-show 200ms ease-out 1500ms both;
}
@keyframes reconnect-show {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
  animation: none;
  opacity: 1;
}

/* UserMenu dropdown (details/summary wrapper) */
.app-user-details { position: relative; list-style: none; }
.app-user-details > summary { list-style: none; }
.app-user-details > summary::-webkit-details-marker { display: none; }

.app-user-dropdown {
  position: absolute;
  bottom: calc(100% + var(--space-xs));
  left: 0; right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  z-index: var(--z-dropdown);
}
/* W topnavie dropdown otwiera się w dół */
.app-topnav .app-user-dropdown {
  bottom: auto;
  top: calc(100% + var(--space-xs));
  left: auto;
  right: 0;
  min-width: 180px;
}
.app-user-dropdown__item {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.app-user-dropdown__lang {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-xs);
}
.app-user-dropdown__lang-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: transparent;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  line-height: 1;
}
.app-user-dropdown__lang-btn:hover {
  background: var(--color-neutral-100);
  color: var(--color-text-primary);
}
.app-user-dropdown__lang-btn--active {
  background: var(--color-brand-50);
  border-color: var(--color-brand-200);
  color: var(--color-brand-700);
  font-weight: var(--font-weight-semibold);
}

/* ============================================================
   CHAT RENDERER — wspólne style dla modułów Chat i Learning.
   Renderer = sekwencja "turns" z bańkami narzędzi (tool-use).

   Tryby:
     [data-mode="chat"]      → bańki w kompaktowym stylu, bez metryk.
     [data-mode="learning"]  → bańki z metrykami (ms / tok / $).
   Stany bańki:
     .is-running             → animowana kropka, brak chevrona
     .is-open                → body widoczne, chevron obrócony
     .has-error              → akcent danger
   ============================================================ */

.cr {
  --cr-rail-w: 28px;
  --cr-msg-gap: 18px;
  --cr-bot-gap: 10px;
  display: flex;
  flex-direction: column;
  gap: var(--cr-msg-gap);
}

/* =================== MESSAGE (user / bot) =================== */
.cr-msg {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  align-items: flex-start;
}
.cr-msg__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  flex-shrink: 0;
  user-select: none;
}
.cr-msg--user .cr-msg__avatar {
  background: var(--color-brand-100);
  color: var(--color-brand-700);
}
.cr-msg--bot .cr-msg__avatar {
  background: var(--color-brand-700);
  color: var(--color-neutral-0);
  font-weight: 700;
}
.cr-msg__col { min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.cr-msg__head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px;
}
.cr-msg__author {
  font-weight: 600;
  color: var(--color-text-primary);
}
.cr-msg__time {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.cr-msg__body {
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.55;
}
.cr-msg__body > p { margin: 0 0 8px; }
.cr-msg__body > p:last-child { margin-bottom: 0; }
.cr-msg__body > ul {
  margin: 6px 0 8px;
  padding-left: 20px;
  display: flex; flex-direction: column; gap: 3px;
}
.cr-msg__body code {
  background: var(--color-neutral-100);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12.5px;
  font-family: var(--font-mono);
}
.cr-msg__body > ol {
  margin: 6px 0 8px;
  padding-left: 22px;
  display: flex; flex-direction: column; gap: 3px;
}
.cr-msg__body > ol:last-child,
.cr-msg__body > ul:last-child { margin-bottom: 0; }
.cr-msg__body h3, .cr-msg__body h4 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 12px 0 4px;
  line-height: 1.3;
}
.cr-msg__body h3:first-child,
.cr-msg__body h4:first-child { margin-top: 0; }
.cr-msg__body pre {
  background: var(--color-neutral-100);
  border-radius: 4px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0 8px;
}
.cr-msg__body pre code {
  background: none;
  padding: 0;
  font-size: 12px;
}
.cr-msg__body table {
  border-collapse: collapse;
  font-size: 13px;
  margin: 6px 0 8px;
  width: 100%;
}
.cr-msg__body th, .cr-msg__body td {
  border: 1px solid var(--color-neutral-200);
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
}
.cr-msg__body th {
  background: var(--color-neutral-50);
  font-weight: 600;
}
.cr-msg__body blockquote {
  border-left: 3px solid var(--color-neutral-300);
  margin: 6px 0;
  padding: 2px 0 2px 12px;
  color: var(--color-text-secondary);
}

/* =================== TOOL BUBBLE =================== */
.cr-tool {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  overflow: hidden;
  transition: border-color 120ms;
}
.cr-tool:hover { border-color: var(--color-border-strong); }
.cr-tool.is-open { border-color: var(--color-border-strong); }
.cr-tool.has-error { border-color: var(--color-danger-100); background: var(--color-danger-50); }

.cr-tool__head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px 7px 9px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
}
.cr-tool__title { flex: 1; min-width: 0; }
.cr-tool__status { margin-left: auto; }
.cr-tool__metrics + .cr-tool__chev,
.cr-tool__metrics + .cr-tool__status,
.cr-tool__chev + .cr-tool__status { margin-left: 0; }
.cr-tool__head:hover { background: var(--color-neutral-50); }

.cr-tool__icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.cr-tool__icon--retrieval  { background: var(--color-warning-50); color: var(--color-warning-700); }
.cr-tool__icon--product    { background: var(--color-brand-50);   color: var(--color-brand-700); }
.cr-tool__icon--params     { background: #ecfdf5; color: #065f46; }
.cr-tool__icon--display    { background: var(--color-warning-50); color: var(--color-warning-700); }
.cr-tool__icon--analyze    { background: #f1ecfa; color: #5a3aa5; }
.cr-tool__icon--system     { background: var(--color-neutral-100); color: var(--color-text-muted); }
.cr-tool__icon--llm        { background: #eef2ff; color: #3730a3; }

.cr-tool__title {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
  color: var(--color-text-primary);
  font-weight: 500;
}
.cr-tool__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-tool__kind {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-neutral-100);
  border-radius: 3px;
  padding: 1px 5px;
  font-weight: 500;
  flex-shrink: 0;
}
.cr-tool__summary {
  color: var(--color-text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}
.cr-tool__summary strong {
  color: var(--color-text-primary);
  font-weight: 600;
}

.cr-tool__metrics {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.cr-tool__metric strong {
  color: var(--color-text-secondary);
  font-weight: 600;
}

.cr-tool__chev {
  color: var(--color-text-muted);
  transition: transform 120ms ease-out;
  flex-shrink: 0;
}
.cr-tool.is-open .cr-tool__chev { transform: rotate(90deg); }

.cr-tool__status {
  width: 11px; height: 11px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cr-tool__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-success-500);
  animation: none;
  margin: auto;
}
.cr-tool.is-running .cr-tool__dot {
  background: var(--color-info-500);
  animation: cr-pulse 1.1s ease-in-out infinite;
}
.cr-tool.has-error .cr-tool__dot { background: var(--color-danger-500); }
@keyframes cr-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.6; }
  50%      { transform: scale(1.15); opacity: 1; }
}
.cr-tool.is-running .cr-tool__chev { display: none; }

.cr-tool__body {
  display: none;
  border-top: 1px solid var(--color-border);
  padding: 10px 12px 12px;
  background: var(--color-bg-sub);
  font-size: 12.5px;
  color: var(--color-text-primary);
}
.cr-tool.is-open .cr-tool__body { display: block; }

.cr-tool__sub {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  font-weight: 600;
  font-family: var(--font-mono);
  margin: 10px 0 4px;
}
.cr-tool__sub:first-child { margin-top: 0; }

.cr-code {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.cr-code--muted { color: var(--color-text-secondary); }

.cr-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.cr-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-secondary);
}
.cr-pill strong { color: var(--color-text-primary); font-family: var(--font-mono); font-weight: 600; }
.cr-pill.is-picked {
  background: var(--color-brand-50);
  border-color: var(--color-brand-100);
  color: var(--color-brand-700);
}

/* Chat mode = bańki nierozwijalne */
.cr[data-mode="chat"] .cr-tool { cursor: default; }
.cr[data-mode="chat"] .cr-tool__head { cursor: default; }
.cr[data-mode="chat"] .cr-tool__head:hover { background: transparent; }
.cr[data-mode="chat"] .cr-tool__chev { display: none; }
.cr[data-mode="chat"] .cr-tool__body { display: none !important; }
.cr[data-mode="chat"] .cr-tool.is-open { border-color: var(--color-border); }
.cr[data-mode="chat"] .cr-tool:hover { border-color: var(--color-border); }

/* =================== Products block (pod wiadomością bota) =================== */
.cr-products { margin-top: 8px; }
.cr-products__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  font-weight: 600;
  font-family: var(--font-mono);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cr-products__label-count {
  background: var(--color-neutral-100);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  color: var(--color-text-secondary);
}

.cr-products--slider {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding: 2px 0 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.cr-products--slider::-webkit-scrollbar { height: 6px; }
.cr-products--slider::-webkit-scrollbar-thumb {
  background: var(--color-neutral-200);
  border-radius: 3px;
}
.cr-products--slider::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-300);
}

.cr-product-card {
  flex-shrink: 0;
  width: 124px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface);
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-snap-align: start;
  transition: border-color 120ms, background 120ms, transform 120ms;
  position: relative;
}
.cr-product-card:hover {
  border-color: var(--color-border-strong);
  background: var(--color-neutral-50);
}
.cr-product-card:active { transform: translateY(1px); }
.cr-product-card__thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background:
    repeating-linear-gradient(45deg,
      var(--color-neutral-100),
      var(--color-neutral-100) 5px,
      var(--color-neutral-200) 5px,
      var(--color-neutral-200) 10px);
  display: grid; place-items: center;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  position: relative;
}
.cr-product-card__status {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 2px solid var(--color-surface);
}
.cr-product-card__status--ready { background: var(--color-success-500); }
.cr-product-card__sap {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-brand-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-product-card__name {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--color-text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 500;
}
.cr-product-card--more {
  background: var(--color-neutral-50);
  border-style: dashed;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 11px;
  gap: 8px;
}
.cr-product-card--more:hover {
  background: var(--color-brand-50);
  border-color: var(--color-brand-200);
  color: var(--color-brand-700);
  border-style: solid;
}
.cr-product-card--more svg {
  width: 20px; height: 20px;
  color: var(--color-text-muted);
}
.cr-product-card--more:hover svg { color: var(--color-brand-700); }
.cr-product-card--more strong {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--color-text-primary);
  font-weight: 600;
}
.cr-product-card--more:hover strong { color: var(--color-brand-700); }

/* =================== Streaming cursor =================== */
.cr-typing {
  display: inline-block;
  width: 7px; height: 14px;
  background: var(--color-text-primary);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: cr-blink 1s steps(2) infinite;
}
@keyframes cr-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}


/* ============================================================
   LEARNING · FEW-SHOTY / NARZĘDZIA / PROMPT
   ============================================================ */

/* Toggle switch — reused in fewshots AND tools */
.fs-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  padding: 0;
}
.fs-switch__track {
  width: 32px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--color-neutral-200);
  position: relative;
  transition: background var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
.fs-switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--color-neutral-0);
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-fast) var(--ease-out);
}
.fs-switch.is-on .fs-switch__track { background: var(--color-success-500); }
.fs-switch.is-on .fs-switch__track::after { transform: translateX(14px); }
.fs-switch__label {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  font-weight: var(--font-weight-semibold);
  min-width: 32px;
}
.fs-switch.is-on .fs-switch__label { color: var(--color-success-700); }

/* --- Narzędzia: karty ------------------------------------- */
.tools-list { display: flex; flex-direction: column; gap: var(--space-md); }

.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.tool-card.is-off { background: var(--color-bg-sub); }
.tool-card.is-off .tool-card__head { opacity: .72; }

.tool-card__head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: var(--space-md);
  align-items: center;
  padding: 14px var(--space-lg);
  cursor: pointer;
  user-select: none;
}
.tool-card__head:hover { background: var(--color-neutral-50); }
.tool-card.is-off .tool-card__head:hover { background: var(--color-neutral-100); }

.tool-card__chev {
  color: var(--color-text-muted);
  transition: transform var(--duration-fast) var(--ease-out);
  display: grid; place-items: center;
  width: 22px; height: 22px;
}
.tool-card.is-open .tool-card__chev { transform: rotate(90deg); }

.tool-card__title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tool-card__name {
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  line-height: 1.2;
}
.tool-card__paren {
  color: var(--color-text-muted);
  font-weight: var(--font-weight-regular);
}
.tool-card__desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-snug);
  max-width: 720px;
}

.tool-card__body {
  display: none;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-sub);
  padding: var(--space-lg) var(--space-lg) var(--space-xl);
}
.tool-card.is-open .tool-card__body { display: block; }

.tool-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}
.tool-section:first-child { margin-top: 0; }
.tool-section__label {
  font-size: var(--font-size-2xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-semibold);
}

.tool-params {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  font-size: var(--font-size-sm);
}
.tool-params__row {
  display: grid;
  grid-template-columns: 200px 110px 90px 1fr;
  gap: var(--space-md);
  padding: 10px var(--space-md);
  border-bottom: 1px solid var(--color-border);
  align-items: start;
}
.tool-params__row:last-child { border-bottom: none; }
.tool-params__row--head {
  background: var(--color-neutral-50);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: var(--color-text-muted);
  padding: 8px var(--space-md);
}
.tool-params__name {
  font-family: var(--font-mono);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}
.tool-params__type {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-info-700);
  background: var(--color-info-50);
  border: 1px solid var(--color-info-100);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  align-self: start;
  width: fit-content;
}
.tool-params__req {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
}
.tool-params__req--required { color: var(--color-danger-700); }
.tool-params__req--optional { color: var(--color-text-muted); }
.tool-params__desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-snug);
}

.tool-call-example {
  background: var(--color-brand-700);
  color: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.tool-used-in {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-muted);
  background: var(--color-neutral-100);
  border: 1px solid var(--color-border);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.tool-card-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

/* --- Prompt: edytor + sidebar ----------------------------- */
.prompt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--space-2xl);
  margin-top: var(--space-lg);
  align-items: start;
}

.prompt-editor {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.prompt-editor__bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-md);
  align-items: center;
  padding: 12px var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-sub);
}
.prompt-editor__meta {
  display: flex;
  gap: var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  letter-spacing: var(--letter-spacing-wide);
  flex-wrap: wrap;
  align-items: center;
}
.prompt-editor__meta strong { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.prompt-editor__actions { display: flex; gap: var(--space-sm); }

.prompt-edit-banner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-lg);
  background: var(--color-warning-50);
  border-bottom: 1px solid var(--color-warning-100);
  color: var(--color-warning-700);
  font-size: var(--font-size-sm);
}
.prompt-edit-banner__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-warning-500, #d99a16);
  animation: prompt-pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes prompt-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.prompt-textarea {
  width: 100%;
  padding: var(--space-xl) var(--space-2xl);
  border: 0;
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--color-text-primary);
  resize: vertical;
  outline: none;
  white-space: pre-wrap;
  tab-size: 2;
  box-sizing: border-box;
}
.prompt-textarea[readonly] { background: var(--color-bg-sub); cursor: default; }
.prompt-textarea:focus:not([readonly]) { background: var(--color-surface); }

.prompt-editor__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-sub);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.prompt-editor__foot strong { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); font-family: var(--font-mono); }

.prompt-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  position: sticky;
  top: 24px;
}

.prompt-side__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.prompt-side__head {
  padding: 12px var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-sub);
}
.prompt-side__head-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}
.prompt-side__head-count {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.prompt-side__head-link {
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  color: var(--color-text-link);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: var(--letter-spacing-wide);
}
.prompt-side__head-link:hover { color: var(--color-brand-hover); }

.prompt-side__list { display: flex; flex-direction: column; }
.prompt-side__item {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
}
.prompt-side__item:last-child { border-bottom: none; }
.prompt-side__item.is-off { opacity: .55; }

.prompt-side__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-success-500);
}
.prompt-side__item.is-off .prompt-side__dot { background: var(--color-neutral-300); }

.prompt-side__name { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.prompt-side__name-main {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-side__name-sub {
  font-size: 10.5px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
}

.prompt-side__chip {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-neutral-100);
}
.prompt-side__chip--on {
  background: var(--color-success-50);
  color: var(--color-success-700);
}

.prompt-side__hint {
  padding: 10px var(--space-md);
  background: var(--color-info-50);
  border-top: 1px solid var(--color-info-100);
  font-size: var(--font-size-xs);
  color: var(--color-info-700);
  line-height: var(--line-height-snug);
}
.prompt-side__hint strong { font-weight: var(--font-weight-semibold); }

.prompt-meta-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px var(--space-md);
}
.prompt-meta-card__cell { display: flex; flex-direction: column; gap: 2px; }
.prompt-meta-card__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-mono);
}
.prompt-meta-card__value {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.prompt-meta-card__value--mono { font-family: var(--font-mono); }
.prompt-meta-card__value--sub {
  font-size: 10.5px;
  color: var(--color-text-muted);
  font-weight: var(--font-weight-regular);
  font-family: var(--font-mono);
}

/* ── Dropdown wyboru wersji prompta ────────────────────────── */
.prompt-version-picker {
  position: relative;
}
.prompt-version-picker__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-brand-700);
  background: var(--color-brand-50);
  border: 1px solid var(--color-brand-100);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.prompt-version-picker__btn:hover { background: var(--color-brand-100); border-color: var(--color-brand-200); }
.prompt-version-picker.is-open .prompt-version-picker__btn { background: var(--color-brand-100); border-color: var(--color-brand-300); }
.prompt-version-picker__caret {
  margin-left: 2px;
  transition: transform 0.15s;
}
.prompt-version-picker.is-open .prompt-version-picker__caret { transform: rotate(180deg); }
.prompt-version-picker__dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-brand-500);
  flex-shrink: 0;
}
.prompt-version-picker__dot.is-history { background: var(--color-neutral-400); }
.prompt-version-picker__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 220px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
}
.prompt-version-picker__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.prompt-version-picker__item:hover { background: var(--color-neutral-50); }
.prompt-version-picker__item.is-active { background: var(--color-brand-50); color: var(--color-brand-700); }
.prompt-version-picker__meta {
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--font-weight-regular);
  letter-spacing: normal;
  text-transform: none;
  color: var(--color-text-muted);
}

/* ── Banner podglądu historycznej wersji ───────────────────── */
.prompt-history-banner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-lg);
  background: var(--color-neutral-50);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}
.prompt-history-banner strong { color: var(--color-text-primary); }
.prompt-history-banner__back {
  margin-left: auto;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.prompt-history-banner__back:hover { background: var(--color-neutral-100); border-color: var(--color-border-strong); color: var(--color-text-primary); }


/* ── ChatRenderer: separator nowej rozmowy ─────────────────── */
.cr-new-chat-separator {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-2xl) 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.cr-new-chat-separator::before,
.cr-new-chat-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}
.cr-new-chat-separator__label {
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── ChatRenderer: separator progu kosztu ─────────────────── */
.cr-cost-threshold {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-xl) 0;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  border: 1px solid;
}
.cr-cost-threshold--warning {
  background: var(--color-warning-50);
  border-color: var(--color-warning-200);
  color: var(--color-warning-700);
}
.cr-cost-threshold--block {
  background: var(--color-danger-50);
  border-color: var(--color-danger-200);
  color: var(--color-danger-700);
}

/* ============================================================
   USER VIEW — minimalny pasek z ikonami narzędzi (ToolDock).
   Brak metryk, brak rozwijania, brak kosztów.
   ============================================================ */

.cru-dock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  background: var(--color-neutral-100);
  border: 1px solid var(--color-border);
  align-self: flex-start;
  font-size: 12px;
  color: var(--color-text-secondary);
  max-width: 100%;
  user-select: none;
  transition: background 0.35s ease, border-color 0.35s ease, color 0.35s ease;
}
.cru-dock.is-running {
  background: var(--color-info-50);
  border-color: var(--color-info-100);
  color: var(--color-info-700);
}
.cru-dock.is-running.cru-dock--params  { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.cru-dock.is-running.cru-dock--display { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.cru-dock.is-running.cru-dock--analyze { background: #f5f3ff; border-color: #ddd6fe; color: #5b21b6; }
.cru-dock.is-running.cru-dock--system  { background: var(--color-neutral-100); border-color: var(--color-border); color: var(--color-text-secondary); }
.cru-dock.has-error {
  background: var(--color-danger-50);
  border-color: var(--color-danger-100);
  color: var(--color-danger-700);
}

.cru-dock__icons {
  display: inline-flex;
  align-items: center;
}
.cru-dock__icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: grid; place-items: center;
  margin-left: -6px;
  border: 2px solid var(--color-neutral-100);
  position: relative;
  animation: cru-pop 280ms cubic-bezier(.34,1.56,.64,1) both;
}
.cru-dock__icon:first-child { margin-left: 0; }
.cru-dock.is-running .cru-dock__icon { border-color: var(--color-info-50); }
.cru-dock.has-error .cru-dock__icon { border-color: var(--color-danger-50); }

/* ostatnia ikona w trakcie pracy — pulsuje */
.cru-dock.is-running .cru-dock__icon:last-child {
  animation: cru-pop 280ms cubic-bezier(.34,1.56,.64,1) both, cru-pulse 1.2s ease-in-out 300ms infinite;
}

/* Stan inicjalny — trzy kropki + „Myślę…" */
.cru-dock--initial {
  padding-left: 12px;
}
.cru-dock__thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cru-dock__think-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  display: inline-block;
  animation: cru-think 1.1s ease-in-out infinite;
}
.cru-dock__think-dot:nth-child(2) { animation-delay: 0.15s; }
.cru-dock__think-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes cru-think {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-3px); opacity: 1; }
}

@keyframes cru-pop {
  0%   { transform: scale(0.4) translateX(-4px); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes cru-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(21, 114, 203, 0.0); }
  50%      { box-shadow: 0 0 0 4px rgba(21, 114, 203, 0.18); }
}

.cru-dock__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  margin-left: 2px;
}
.cru-dock__time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   ADMIN VIEW — szczegółowy widok wywołań.
   LLM calls pierwszorzędne, tool calls drugorzędne.
   ============================================================ */

.cra .cr-msg--admin-view .cr-msg__col {
  gap: 10px;
}

/* ---------- Pasek podsumowujący na górze tury bota ---------- */
.cra-summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 7px;
  background: var(--color-bg-sub);
  border: 1px solid var(--color-border);
  font-size: 11.5px;
  color: var(--color-text-secondary);
  align-self: flex-start;
  font-variant-numeric: tabular-nums;
}
.cra-summary__group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cra-summary__group strong {
  color: var(--color-text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
}
.cra-summary__group--strong strong {
  color: var(--color-brand-700);
  font-size: 13px;
}
.cra-summary__label {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
}
.cra-summary__sub {
  color: var(--color-text-muted);
  font-size: 10.5px;
  font-family: var(--font-mono);
}
.cra-summary__sep {
  width: 1px;
  height: 14px;
  background: var(--color-border-strong);
  display: inline-block;
}

/* ---------- Lista zdarzeń (tool + llm calls) ---------- */
.cra-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- LLM Bubble ---------- */
.cra-llm {
  border: 1px solid var(--color-border);
  border-radius: 9px;
  background: var(--color-surface);
  overflow: hidden;
}
.cra-llm.is-open { border-color: var(--color-border-strong); }
.cra-llm.has-error { border-color: var(--color-danger-100); background: var(--color-danger-50); }

.cra-llm__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 8px 10px;
  cursor: pointer;
  user-select: none;
}
.cra-llm__head:hover { background: var(--color-neutral-50); }

.cra-llm__head-l {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.cra-llm__head-r {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.cra-llm__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 6px;
  border-radius: 4px;
  background: var(--color-brand-700);
  color: var(--color-neutral-0);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.cra-llm__model {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-brand-700);
  font-weight: 600;
  flex-shrink: 0;
}
.cra-llm__name {
  font-size: 13px;
  color: var(--color-text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cra-llm__metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}
.cra-llm__metric strong {
  color: var(--color-text-primary);
  font-weight: 600;
}
.cra-llm__metric-unit {
  color: var(--color-text-muted);
  font-size: 10px;
}
.cra-llm__metric--strong strong {
  color: var(--color-brand-700);
  font-size: 12.5px;
}

.cra-llm__chev {
  color: var(--color-text-muted);
  transition: transform 120ms;
  display: inline-grid;
  place-items: center;
}
.cra-llm.is-open .cra-llm__chev { transform: rotate(180deg); }

/* Grid 4 metryk */
.cra-llm__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.cra-llm__cell {
  padding: 9px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cra-llm__cell + .cra-llm__cell {
  border-left: 1px solid var(--color-border);
}

.cra-llm__cell-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  font-weight: 600;
  font-family: var(--font-mono);
}
.cra-llm__cell-tok {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--color-text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 3px;
}
.cra-llm__cell-unit {
  font-size: 10px;
  color: var(--color-text-muted);
  font-weight: 400;
}
.cra-llm__cell-cost {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Body (rozwinięty payload) */
.cra-llm__body {
  display: none;
  border-top: 1px solid var(--color-border);
  padding: 12px;
  background: var(--color-bg-sub);
  font-size: 12.5px;
}
.cra-llm.is-open .cra-llm__body { display: block; }

/* ---------- Final answer wrapper ---------- */
.cra-final {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--color-success-100);
  background: linear-gradient(180deg, var(--color-success-50) 0%, #ffffff 60%);
}
.cra-final__label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-success-700);
  margin-bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cra-final__label::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-success-500);
}

/* W admin view tool bubble — pokaż metryki, pozwól rozwijać */
.cra .cr-tool__metrics { display: inline-flex; }
.cra .cr-tool__chev { display: inline-flex; }

/* ── Prompt: podgląd żądania ────────────────────────────────── */
.prompt-preview-section {
  margin-top: var(--space-2xl);
}
.prompt-preview-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  width: 100%;
}
.prompt-preview-toggle:hover {
  background: var(--color-neutral-50);
  color: var(--color-text-primary);
}
.prompt-preview-toggle__hint {
  margin-left: auto;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.prompt-preview-stats {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-md) 0 var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.prompt-preview-stats__sep {
  color: var(--color-text-muted);
}
.prompt-textarea--preview {
  font-size: var(--font-size-xs);
  background: var(--color-neutral-50);
}


/* ============================================================
   9. CHAT — Standalone app shell (no ZARYS topnav/subnav)
      Used by /assistant (user-facing), responsive desktop + mobile.
      Admin pages at /assistant/admin/... keep AssistantModuleLayout.
   ============================================================ */

/* Outer frame: fills viewport, centres the card */
/* Wrapper clips the scaled video so it never overflows past the viewport.
   Dark background shows instantly before the video frame arrives. */
.chat-frame-bg-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0a1628;
  z-index: 0;
}
.chat-frame-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Scale up ~15 % to push letterbox bars out of view */
  transform: translate(-50%, -50%) scale(1.15);
}
.chat-frame {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 32px;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

/* Card: max-width, rounded, elevated */
.chat-app {
  width: 100%;
  max-width: 1080px;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--color-border);
  box-shadow:
    0 20px 48px rgba(15, 29, 54, 0.10),
    0 4px 12px rgba(15, 29, 54, 0.06);
  overflow: hidden;
  position: relative;
}

/* ── Top bar ──────────────────────────────────────────────── */
.chat-app-bar {
  height: 52px;
  padding: 0 var(--space-md);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
  z-index: var(--z-sticky);
  position: relative;
}
.chat-app-bar__left  { justify-self: start;  display: flex; align-items: center; gap: 4px; }
.chat-app-bar__center{ justify-self: center; display: flex; align-items: center; }
.chat-app-bar__right { justify-self: end;    display: flex; align-items: center; gap: var(--space-sm); }

/* Brand */
.chat-brand {
  display: inline-flex; align-items: center; gap: var(--space-sm);
  height: 32px; padding: 0 var(--space-sm); border-radius: var(--radius-md);
  user-select: none;
}
.chat-brand__logo {
  width: 22px; height: 22px;
  background: var(--color-brand); color: white;
  border-radius: 5px; display: grid; place-items: center;
  font-size: var(--font-size-xs); font-weight: var(--font-weight-bold);
  flex-shrink: 0;
}
.chat-brand__name {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
}

/* "Historia" title shown in place of brand on mobile when drawer open */
.chat-app-bar__hist-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
  display: none;
}

/* Icon button (toggle drawer, compose) */
.chat-iconbtn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: transparent; border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-secondary); cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  flex-shrink: 0;
}
.chat-iconbtn:hover  { background: var(--color-neutral-100); color: var(--color-text-primary); }
.chat-iconbtn.is-active { background: var(--color-neutral-100); color: var(--color-text-primary); }
.chat-iconbtn:disabled { opacity: 0.4; cursor: not-allowed; }

/* History/close icon swap inside toggle button */
.chat-bar-toggle__close { display: none; }

/* "New conversation" text button — desktop only */
.chat-new-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 var(--space-md);
  background: var(--color-neutral-100); border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm); font-weight: var(--font-weight-medium);
  cursor: pointer; white-space: nowrap;
  transition: background var(--duration-fast);
}
.chat-new-btn:hover    { background: var(--color-neutral-200); }
.chat-new-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-new-btn__icon    { color: var(--color-text-secondary); display: inline-flex; }

/* Compose icon button — mobile only (hidden on desktop) */
.chat-new-iconbtn { display: none; }

/* Avatar button */
.chat-avatar {
  width: 30px; height: 30px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-brand-accent), #2e5594);
  color: white; display: grid; place-items: center;
  font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold);
  cursor: pointer; border: 1.5px solid transparent;
  transition: border-color var(--duration-fast);
  flex-shrink: 0;
}
.chat-avatar.is-active { border-color: var(--color-brand-accent); }

/* Transparent backdrop — closes account menu on outside click */
.chat-backdrop {
  position: fixed; inset: 0; z-index: calc(var(--z-dropdown) - 1);
  background: transparent;
}

/* Account dropdown */
.chat-account-menu {
  position: absolute; top: 50px; right: var(--space-md);
  width: 244px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 6px;
  z-index: var(--z-dropdown);
  animation: chatMenuIn 0.15s var(--ease-out);
}
@keyframes chatMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-account-menu__head {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}
.chat-account-menu__name { font-size: var(--font-size-base); font-weight: var(--font-weight-semibold); }
.chat-account-menu__role { font-size: var(--font-size-xs); color: var(--color-text-muted); font-family: var(--font-mono); margin-top: 2px; }
.chat-account-menu__item {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 7px var(--space-md); width: 100%;
  background: transparent; border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text-primary); cursor: pointer;
  text-align: left; text-decoration: none;
  transition: background var(--duration-fast);
}
.chat-account-menu__item:hover { background: var(--color-neutral-100); text-decoration: none; }
.chat-account-menu__item--danger { color: var(--color-danger-500); }
.chat-account-menu__item--admin  { font-weight: var(--font-weight-medium); }
.chat-account-menu__item--admin:hover { background: var(--color-brand-50); }
.chat-account-menu__sep { height: 1px; background: var(--color-border); margin: 4px 6px; }
.chat-account-menu__lang {
  display: flex; gap: 4px; padding: 6px var(--space-md);
}
.chat-account-menu__lang-btn {
  flex: 1; height: 30px; display: flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-size: var(--font-size-sm); cursor: pointer; background: transparent;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.chat-account-menu__lang-btn:hover { background: var(--color-neutral-100); }
.chat-account-menu__lang-btn--active {
  background: var(--color-brand-50); border-color: var(--color-brand-200);
  color: var(--color-brand-700); font-weight: var(--font-weight-medium);
}

/* ── Body (drawer + main) ────────────────────────────────── */
.chat-app__body {
  flex: 1; display: flex; min-height: 0;
  position: relative; overflow: hidden;
}

/* ── Drawer (conversation history sidebar) ───────────────── */
.chat-app__drawer {
  width: var(--chat-convo-sidebar-width);
  min-width: 0;
  background: var(--color-neutral-50);
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow: hidden;
  transition: width 0.28s var(--ease-out);
}
.chat-app[data-drawer="closed"] .chat-app__drawer { width: 0; }
.chat-app[data-drawer="open"]   .chat-app__drawer { width: var(--chat-convo-sidebar-width); }

.chat-drawer__search-wrap { padding: var(--space-lg) var(--space-lg) var(--space-sm); flex-shrink: 0; }
.chat-drawer__search { position: relative; }
.chat-drawer__search input {
  width: 100%; height: 32px;
  background: var(--color-neutral-100); border: 1px solid transparent;
  border-radius: var(--radius-md); padding: 0 var(--space-sm) 0 30px;
  font-size: var(--font-size-sm); outline: none; color: var(--color-text-primary);
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.chat-drawer__search input:focus { background: white; border-color: var(--color-border-strong); }
.chat-drawer__search-icon {
  position: absolute; left: var(--space-sm); top: 50%; transform: translateY(-50%);
  color: var(--color-text-muted); pointer-events: none; display: flex; align-items: center;
}
.chat-drawer__list { flex: 1; overflow-y: auto; padding-bottom: var(--space-sm); }
.chat-drawer__group {
  font-family: var(--font-mono); font-size: var(--font-size-2xs);
  letter-spacing: var(--letter-spacing-wider); text-transform: uppercase;
  color: var(--color-text-muted);
  padding: var(--space-lg) var(--space-lg) 6px;
  display: flex; justify-content: space-between;
}
.chat-drawer__row {
  display: grid; grid-template-columns: 3px 1fr auto;
  gap: var(--space-md); padding: var(--space-sm) var(--space-md);
  cursor: pointer; align-items: center;
}
.chat-drawer__row + .chat-drawer__row { border-top: 1px solid var(--color-neutral-100); }
.chat-drawer__row:hover  { background: var(--color-neutral-100); }
.chat-drawer__row.is-active { background: var(--color-brand-50); }
.chat-drawer__row.is-active .chat-drawer__row-title {
  color: var(--color-brand-700); font-weight: var(--font-weight-semibold);
}
.chat-drawer__row-bar {
  width: 3px; height: 22px; border-radius: var(--radius-xs); background: var(--color-neutral-300);
}
.chat-drawer__row.is-active .chat-drawer__row-bar { background: var(--color-brand-500); }
.chat-drawer__row-title {
  font-size: var(--font-size-base); font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.chat-drawer__row-time {
  font-family: var(--font-mono); font-size: var(--font-size-xs);
  color: var(--color-text-muted); white-space: nowrap;
  display: flex; align-items: center; gap: 2px;
}

/* ── Main area ───────────────────────────────────────────── */
.chat-app__main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--color-surface);
}
.chat-app__scroll { flex: 1; overflow-y: auto; }
.chat-app__inner  {
  max-width: var(--chat-message-max-width); margin: 0 auto;
  padding: var(--space-sm) var(--space-2xl) var(--space-2xl);
}

/* ── Empty / new conversation state ─────────────────────── */
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-2xl); text-align: center;
}
.chat-empty__logo {
  width: 56px; height: 56px; background: var(--color-brand); color: white;
  border-radius: 14px; display: grid; place-items: center;
  font-weight: var(--font-weight-bold); font-size: 22px;
  margin-bottom: var(--space-xl); flex-shrink: 0;
}
.chat-empty__greeting {
  font-size: 22px; font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug); margin: 0 0 6px;
}
.chat-empty__sub {
  font-size: var(--font-size-base); color: var(--color-text-secondary);
  margin: 0 0 var(--space-2xl); max-width: 440px; line-height: var(--line-height-normal);
}

/* ── Responsive composer: desktop vs mobile ──────────────── */
.chat-composer-mobile { display: none; }

/* Mobile pill composer */
.composer-m {
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-lg);
  display: flex; align-items: center; gap: var(--space-sm);
  background: var(--color-surface);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.composer-m:focus-within { border-color: var(--color-border-focus); box-shadow: var(--focus-ring); }
.composer-m input {
  flex: 1; border: none; outline: none;
  font-size: var(--font-size-md); background: transparent; color: var(--color-text-primary);
}
.composer-m__send {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--color-brand); color: white; border: none;
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
  transition: background var(--duration-fast);
}
.composer-m__send:hover    { background: var(--color-brand-hover); }
.composer-m__send:disabled { opacity: 0.4; cursor: not-allowed; }


/* ============================================================
   9a. CHAT standalone — MOBILE overrides (≤ 767px)
   ============================================================ */
@media (max-width: 767px) {

  /* Frame: no padding, no centering — full viewport */
  .chat-frame {
    display: block;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Card: stretch to full viewport, no rounding/shadow */
  .chat-app {
    position: fixed;
    inset: 0;
    height: auto;
    padding-bottom: var(--keyboard-height, 0px);
    max-width: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  /* Bar sizing */
  .chat-app-bar { height: 50px; padding: 0 var(--space-sm); }
  .chat-account-menu { top: 48px; right: var(--space-sm); width: 220px; }

  /* Touch targets */
  .chat-iconbtn { width: 38px; height: 38px; }
  .chat-avatar  { width: 32px; height: 32px; }

  /* Toggle icon: swap history→close when drawer is open */
  .chat-app[data-drawer="open"] .chat-bar-toggle__hist  { display: none; }
  .chat-app[data-drawer="open"] .chat-bar-toggle__close { display: block; }

  /* Bar center: swap brand→"Historia" when drawer open */
  .chat-app[data-drawer="open"] .chat-brand              { display: none; }
  .chat-app[data-drawer="open"] .chat-app-bar__hist-title{ display: block; }

  /* Right actions hidden when drawer open */
  .chat-app[data-drawer="open"] .chat-app-bar__right { visibility: hidden; }

  /* Button swap: hide text button, show icon button */
  .chat-new-btn     { display: none; }
  .chat-new-iconbtn { display: grid; }

  /* Admin panel link hidden on mobile */
  .chat-account-menu__item--admin { display: none; }
  .chat-account-menu__sep--admin  { display: none; }

  /* Drawer: full-screen overlay — [data-drawer] beats desktop width:0 rule */
  .chat-app[data-drawer] .chat-app__drawer {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; border-right: none;
    z-index: var(--z-overlay);
    transition: transform 0.28s var(--ease-out);
  }
  .chat-app[data-drawer="closed"] .chat-app__drawer { transform: translateX(-100%); }
  .chat-app[data-drawer="open"]   .chat-app__drawer { transform: translateX(0); }

  /* Feed padding */
  .chat-app__inner { padding: var(--space-xs) var(--space-lg) var(--space-xl); }

  /* Empty state: single-column suggestions, scrollable from top */
  .chat-empty { justify-content: flex-start; padding-top: var(--space-3xl); padding-left: var(--space-lg); padding-right: var(--space-lg); }
  .chat-empty__logo     { width: 48px; height: 48px; font-size: 20px; margin-bottom: var(--space-lg); }
  .chat-empty__greeting { font-size: 18px; }

  /* Swap composers */
  .chat-composer-desktop { display: none; }
  .chat-composer-mobile  { display: block; }
  .chat-composer-mobile .composer-wrap {
    padding: var(--space-sm) var(--space-md) var(--space-md);
  }
}


/* ============================================================
   10. CHAT ADMIN — Dashboard grid
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xl);
}
@media (max-width: 720px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   7b. WARSZTAT LIŚCIA (Leaf Workshop) — DataQuality
   Pełnoekranowy detal pojedynczego liścia. JEDNA kolumna.
   Reużywa .dq-section / .dq-status (z Gaps) + tokeny --dq-* / --cat-*.
   (handoff: docs/design_handoff_leaf_workshop) — podzbiór Fazy A.
   ============================================================ */
.lw-wrap { padding: 0 var(--space-3xl); min-width: 0; }  /* padding jak .cat-wrap/.st-wrap/.ob-wrap (3xl) → ta sama szerokość treści (~1264) co pozostałe widoki; min-width:0 chroni flex-item */


/* nagłówek liścia */
.lw-head { padding: 14px 0 var(--space-lg); }
.lw-head__crumbs { font-family: var(--font-mono); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: var(--space-sm); }
.lw-head__crumbs .sep { color: var(--color-neutral-300); }
.lw-head__crumbs strong { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.lw-head__titlerow { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-xl); flex-wrap: wrap; }
.lw-head__title { font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); line-height: 1.12; text-wrap: pretty; }
.lw-head__count { font-family: var(--font-mono); font-size: var(--font-size-sm); color: var(--color-text-secondary); white-space: nowrap; }
.lw-head__count strong { font-family: var(--font-sans); font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); color: var(--color-text-primary); font-variant-numeric: tabular-nums; }

/* dział inline-edit (admin) */
.lw-dept { display: inline-flex; align-items: center; gap: 8px; margin-top: var(--space-md); flex-wrap: wrap; }
.lw-dept__label { font-family: var(--font-mono); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); color: var(--color-text-muted); }
.lw-dept__hint { font-size: var(--font-size-2xs); color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: var(--letter-spacing-wide); }
.lw-dept .select.is-mine { font-weight: var(--font-weight-medium); }

/* progres: 6-segmentowy pasek + legenda */
.lw-progress { margin-top: var(--space-lg); max-width: 640px; }
.lw-bar { display: flex; height: 14px; border-radius: var(--radius-full); overflow: hidden; background: var(--color-neutral-100); width: 100%; }
.lw-bar__seg { height: 100%; transition: flex-basis var(--duration-slow) var(--ease-out); }
.lw-bar__seg + .lw-bar__seg { box-shadow: -1px 0 0 rgba(255,255,255,.55); }
.lw-bar__seg--global   { background: var(--dq-global); }
.lw-bar__seg--diff     { background: var(--dq-diff); }
.lw-bar__seg--partial  { background: var(--dq-partial); }
.lw-bar__seg--missing  { background: var(--cat-missing); }
.lw-bar__seg--ignored  { background: var(--cat-ignored); }
.lw-bar__seg--optional { background: var(--cat-optional); }
.lw-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 9px; font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); }
.lw-legend__item { display: inline-flex; align-items: center; gap: 5px; }
.lw-legend__sw { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.lw-legend__item strong { color: var(--color-text-primary); font-family: var(--font-sans); font-weight: var(--font-weight-semibold); }

/* dwa wskaźniki gotowości */
.lw-readiness { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); margin-top: var(--space-xl); }
.lw-ready-card { display: grid; grid-template-columns: 34px 1fr; gap: var(--space-md); align-items: start; padding: 14px var(--space-lg); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); position: relative; }
.lw-ready-card__icon { width: 34px; height: 34px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0; }
.lw-ready-card__eyebrow { font-family: var(--font-mono); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; }
.lw-ready-card__status { font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); margin-top: 3px; display: flex; align-items: baseline; gap: 7px; }
.lw-ready-card__status .num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.lw-ready-card__desc { font-size: var(--font-size-xs); color: var(--color-text-secondary); line-height: 1.45; margin-top: 5px; }
.lw-ready-card__desc b { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.lw-ready-card--bot .lw-ready-card__icon { background: var(--color-warning-50); color: var(--color-warning-500); }
.lw-ready-card--bot.is-ready .lw-ready-card__icon { background: var(--color-success-50); color: var(--color-success-500); }
.lw-ready-card--bot .lw-ready-card__status { color: var(--color-warning-700); }
.lw-ready-card--bot.is-ready .lw-ready-card__status { color: var(--color-success-700); }
.lw-ready-card--cur .lw-ready-card__icon { background: var(--color-brand-50); color: var(--color-brand-700); }
.lw-ready-card--cur .lw-ready-card__status { color: var(--color-text-primary); }
.lw-ready-card--cur.is-done .lw-ready-card__icon { background: var(--color-success-50); color: var(--color-success-500); }
.lw-ready-card--cur.is-done .lw-ready-card__status { color: var(--color-success-700); }
.lw-cur-track { margin-top: 8px; height: 5px; border-radius: var(--radius-full); background: var(--color-neutral-100); overflow: hidden; }
.lw-cur-track__fill { height: 100%; background: var(--color-brand-500); border-radius: inherit; transition: width var(--duration-slow) var(--ease-out); }
.lw-ready-card--cur.is-done .lw-cur-track__fill { background: var(--color-success-500); }

/* pasek sterujący (sticky): filtr store */
.lw-controls { position: sticky; top: 0; z-index: 30; background: var(--color-bg); padding: var(--space-md) 0 10px; margin-top: var(--space-xl); }
.lw-controls__row { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }
.lw-store-label { font-family: var(--font-mono); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); color: var(--color-text-muted); font-weight: var(--font-weight-semibold); }
.lw-seg { display: inline-flex; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); overflow: hidden; background: var(--color-surface); }
.lw-seg__btn { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); background: var(--color-surface); border: none; border-right: 1px solid var(--color-border); cursor: pointer; transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out); white-space: nowrap; }
.lw-seg__btn:last-child { border-right: none; }
.lw-seg__btn:hover:not(.is-active) { background: var(--color-neutral-50); color: var(--color-text-primary); }
.lw-seg__btn.is-active { background: var(--color-brand-700); color: var(--color-neutral-0); font-weight: var(--font-weight-semibold); }
.lw-seg__count { font-family: var(--font-mono); font-size: 10px; opacity: .7; font-variant-numeric: tabular-nums; }
.lw-controls__spacer { flex: 1; }

/* sekcje stanów (reuse dq-section) */
.lw-section { margin-bottom: var(--space-xl); }
.lw-section.is-empty .dq-section__content { display: none; }
.lw-section__empty { display: none; align-items: center; gap: 10px; padding: 18px var(--space-lg); background: var(--color-surface); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); font-size: var(--font-size-sm); color: var(--color-text-muted); }
.lw-section.is-empty .lw-section__empty { display: flex; }
.lw-section__empty svg { color: var(--color-neutral-300); flex-shrink: 0; }

/* wiersz atrybutu */
/* Akcje = STAŁA szerokość (nie auto): inaczej różna liczba przycisków per sekcja zmienia szerokość elastycznej kolumny nazwy i pasek wypełnienia (kol. 3) rozjeżdża się między sekcjami. */
.lw-attr, .lw-attr-x__head { display: grid; grid-template-columns: 16px minmax(180px, 1.3fr) 150px minmax(150px, 1fr) 260px; gap: var(--space-md); align-items: center; }
.lw-attr { padding: 10px var(--space-lg); border-bottom: 1px solid var(--color-neutral-100); }
.lw-attr:last-child { border-bottom: none; }
.lw-attr__name { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text-primary); display: flex; align-items: center; gap: 7px; min-width: 0; }
.lw-attr__value { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lw-attr__value code, .lw-attr-x__head code { font-family: var(--font-mono); font-size: 11.5px; background: var(--color-neutral-50); border: 1px solid var(--color-border); border-radius: var(--radius-xs); padding: 2px 6px; color: var(--color-text-primary); }
.lw-attr__value--empty { color: var(--color-text-muted); font-style: italic; font-family: var(--font-sans); }
.lw-attr__value--center { text-align: center; }
.lw-attr__actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity var(--duration-fast) var(--ease-out); }
.lw-attr:hover .lw-attr__actions, .lw-attr-x:hover .lw-attr__actions { opacity: 1; }
.dq-section--ignored .lw-attr__name, .dq-section--optional .lw-attr__name { color: var(--color-text-secondary); }

/* mini coverage bar */
.lw-mini { display: inline-grid; grid-template-columns: 1fr 48px; align-items: center; gap: 9px; width: 100%; }  /* licznik N/M stała szerokość → ścieżka paska jednakowa we wszystkich wierszach */
.lw-mini__track { height: 6px; border-radius: var(--radius-full); background: var(--color-neutral-100); overflow: hidden; }
.lw-mini__fill { height: 100%; border-radius: var(--radius-full); transition: width var(--duration-slow) var(--ease-out); }
.lw-mini__fill--global  { background: var(--dq-global); }
.lw-mini__fill--diff    { background: var(--dq-diff); }
.lw-mini__fill--partial { background: var(--dq-partial); }
.lw-mini__fill--missing { background: var(--cat-missing); }
.lw-mini__fill--ignored { background: var(--cat-ignored); }
.lw-mini__fill--optional{ background: var(--cat-optional); }
.lw-mini__val { font-family: var(--font-mono); font-size: 10.5px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.lw-mini__val--warn { color: var(--color-warning-700); }
.lw-mini__val--zero { color: #8a392f; }

/* plakietki przy nazwie atrybutu */
.lw-tag { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); border-radius: 3px; padding: 2px 6px; line-height: 1; flex-shrink: 0; font-weight: var(--font-weight-medium); }
.lw-tag--global { background: var(--color-neutral-100); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.lw-tag--store  { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* pre-triaż (Faza B): instrukcja + wizualne oznaczenie sygnału (kropka + wyróżnienie przycisku) */
.lw-instr { display: flex; align-items: flex-start; gap: 9px; padding: 10px var(--space-lg); background: var(--color-info-50); border: 1px solid var(--color-info-100); border-radius: var(--radius-md); margin-bottom: var(--space-sm); font-size: var(--font-size-xs); color: var(--color-text-secondary); line-height: 1.5; }
.lw-instr svg { flex-shrink: 0; color: var(--color-info-500); margin-top: 2px; }
.lw-sugg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.lw-sugg-dot--gap { background: var(--color-info-500); }
.lw-sugg-dot--ignore { background: var(--color-warning-500); }
.lw-attr__value--foreign { font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); }
.lw-attr__value--foreign.is-gap { color: var(--color-info-700); }

/* wiersz rozwijany (Partial / Differentiating) */
.lw-attr-x { border-bottom: 1px solid var(--color-neutral-100); }
.lw-attr-x:last-child { border-bottom: none; }
.lw-attr-x__head { padding: 10px var(--space-lg); cursor: pointer; transition: background var(--duration-fast) var(--ease-out); }
.lw-attr-x__head:hover { background: var(--color-neutral-50); }
.lw-attr-x__caret { color: var(--color-text-muted); transition: transform var(--duration-fast) var(--ease-out); display: grid; place-items: center; }
.lw-attr-x.is-open .lw-attr-x__caret { transform: rotate(90deg); }
.lw-attr-x__body { display: none; padding: var(--space-md) var(--space-lg) var(--space-lg) 44px; background: var(--color-neutral-50); border-top: 1px solid var(--color-neutral-100); }
.lw-attr-x.is-open .lw-attr-x__body { display: block; }
.lw-subhead { font-family: var(--font-mono); font-size: var(--font-size-2xs); letter-spacing: var(--letter-spacing-wider); text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 7px; }
.lw-subhead--spaced { margin-top: var(--space-lg); }
/* ── Batch fill: panel „Uzupełnij wszystkie…" (zbiorcze wpisanie wartości atrybutu) ── */
.lw-batch { margin: var(--space-sm) var(--space-lg) var(--space-md); padding: var(--space-md); background: var(--color-neutral-50); border: 1px solid var(--color-neutral-100); border-radius: var(--radius-sm); }
.lw-batch__row { display: flex; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }
.lw-batch__preview { margin-top: 8px; font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); }
.lw-values { display: flex; flex-wrap: wrap; gap: 6px; }
.lw-vchip { display: inline-flex; align-items: stretch; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: var(--radius-sm); overflow: hidden; font-size: var(--font-size-xs); }
.lw-vchip__label { padding: 5px 9px; font-family: var(--font-mono); font-size: 11.5px; color: var(--color-text-primary); white-space: nowrap; }
.lw-vchip__count { padding: 5px 8px; background: var(--color-neutral-50); border-left: 1px solid var(--color-border); font-family: var(--font-mono); font-size: 10.5px; color: var(--color-text-secondary); display: inline-flex; align-items: center; font-variant-numeric: tabular-nums; }
.lw-skus { display: flex; flex-wrap: wrap; gap: 5px; }
.lw-sku { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--font-size-2xs); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xs); padding: 3px 7px; color: var(--color-text-secondary); cursor: pointer; transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out); }
.lw-sku:hover { border-color: var(--color-brand-500); background: var(--color-brand-50); color: var(--color-brand-700); }
.lw-sku--pimcore { opacity: .6; }            /* dane Pimcore (read-only) — recede, żeby luki rzucały się w oczy */
.lw-sku--pimcore:hover { opacity: 1; }
.lw-sku__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.lw-sku__dot--empty    { background: var(--color-warning-500); }
.lw-sku__dot--pending  { background: var(--color-info-500); }
.lw-sku__dot--conflict { background: var(--color-danger-500); }
.lw-sku__dot--pimcore  { background: var(--color-success-500); }
.lw-celleg { display: inline-flex; flex-wrap: wrap; gap: 12px; margin-left: 10px; font-family: var(--font-sans); font-size: var(--font-size-2xs); color: var(--color-text-muted); text-transform: none; letter-spacing: normal; font-weight: var(--font-weight-regular); }
.lw-celleg__i { display: inline-flex; align-items: center; gap: 5px; }
.lw-x-actions { margin-top: var(--space-md); display: flex; gap: var(--space-sm); flex-wrap: wrap; align-items: center; }
.lw-x-actions .right { margin-left: auto; }
.lw-scope-note { font-size: var(--font-size-2xs); color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: var(--letter-spacing-wide); display: inline-flex; align-items: center; gap: 5px; }
.lw-scope-note svg { color: var(--color-text-muted); }

/* podsumowania wartości w nagłówku wiersza (kolumna „wartość") */
.lw-val-soft { font-family: var(--font-sans); color: var(--color-text-secondary); }
.lw-val-warn { font-family: var(--font-sans); color: var(--color-warning-700); }

/* przycisk hurtowego czyszczenia overlayu — akcja destrukcyjna w korpusie wiersza */
.lw-clear-btn { color: var(--color-danger-700); }
.lw-clear-btn:hover { background: var(--color-danger-50); color: var(--color-danger-700); }

/* twardy modal potwierdzenia „Wyczyść" — kasowanie overlayu po wpisaniu słowa-klucza */
.dqc-overlay { position: fixed; inset: 0; background: rgba(15,29,54,.42); display: grid; place-items: center; z-index: var(--z-modal); padding: var(--space-xl); }
.dqc-modal { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); width: min(440px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.dqc-head { display: flex; align-items: center; gap: 11px; padding: var(--space-lg) var(--space-xl) var(--space-sm); }
.dqc-head__icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-full); background: var(--color-danger-50); color: var(--color-danger-500); flex-shrink: 0; }
.dqc-head__title { font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); }
.dqc-body { padding: 0 var(--space-xl) var(--space-lg); }
.dqc-text { font-size: var(--font-size-sm); color: var(--color-text-secondary); line-height: 1.55; margin-bottom: var(--space-md); }
.dqc-label { display: block; font-size: var(--font-size-xs); color: var(--color-text-muted); margin-bottom: 6px; }
.dqc-input { width: 100%; }
.dqc-foot { display: flex; justify-content: flex-end; gap: var(--space-sm); padding: var(--space-md) var(--space-xl) var(--space-lg); border-top: 1px solid var(--color-border); }

/* drawer produktu (side-sheet z prawej) */
.lw-drawer-backdrop { position: fixed; inset: 0; background: rgba(15,29,54,.18); z-index: var(--z-overlay); opacity: 0; pointer-events: none; transition: opacity var(--duration-normal) var(--ease-out); }
.lw-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.lw-drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 540px; max-width: 94vw; background: var(--color-surface); box-shadow: var(--shadow-xl); z-index: var(--z-modal); display: flex; flex-direction: column; transform: translateX(100%); transition: transform var(--duration-slow) var(--ease-out); }
.lw-drawer.is-open { transform: translateX(0); }
.lw-drawer__head { padding: var(--space-lg) var(--space-xl) var(--space-md); border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.lw-drawer__topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.lw-drawer__nav { display: flex; align-items: center; gap: 4px; }
.lw-drawer__nav-pos { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-muted); margin: 0 6px; letter-spacing: var(--letter-spacing-wide); font-variant-numeric: tabular-nums; }
.lw-icon-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--color-text-muted); cursor: pointer; background: none; border: none; }
.lw-icon-btn:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.lw-drawer__sap { font-family: var(--font-mono); font-size: var(--font-size-md); color: var(--color-text-primary); font-weight: var(--font-weight-semibold); display: inline-flex; align-items: center; gap: 6px; background: var(--color-neutral-50); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 3px 8px; cursor: pointer; }
.lw-drawer__sap:hover { border-color: var(--color-brand-500); color: var(--color-brand-700); }
.lw-drawer__sap svg { width: 11px; height: 11px; opacity: .5; }
.lw-drawer__deeplink { font-size: var(--font-size-xs); color: var(--color-text-link); display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; text-decoration: none; }
.lw-drawer__name { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); line-height: 1.3; margin: 10px 0 6px; text-wrap: pretty; }
.lw-drawer__path { font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); }
.lw-drawer__meta { display: flex; flex-wrap: wrap; gap: var(--space-md); font-size: var(--font-size-xs); color: var(--color-text-muted); font-family: var(--font-mono); margin-top: 10px; }
.lw-drawer__meta strong { color: var(--color-text-primary); font-family: var(--font-sans); font-weight: var(--font-weight-semibold); margin-right: 4px; }
.lw-thumbs { display: flex; gap: 6px; padding: var(--space-md) var(--space-xl); border-bottom: 1px solid var(--color-border); overflow-x: auto; flex-shrink: 0; background: var(--color-neutral-50); }
.lw-thumb { flex-shrink: 0; width: 46px; height: 46px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); background: repeating-linear-gradient(45deg, var(--color-neutral-100), var(--color-neutral-100) 4px, var(--color-neutral-200) 4px, var(--color-neutral-200) 8px); display: grid; place-items: end center; cursor: pointer; position: relative; padding-bottom: 3px; transition: border-color var(--duration-fast) var(--ease-out); }
.lw-thumb:hover { border-color: var(--color-brand-400); }
.lw-thumb.is-active { border-color: var(--color-brand-500); box-shadow: 0 0 0 2px var(--color-brand-100); }
.lw-thumb__dot { width: 7px; height: 7px; border-radius: 50%; }
.lw-thumb__dot--gap { background: var(--color-warning-500); }
.lw-thumb__dot--ok { background: var(--color-success-500); }
.lw-drawer__context { margin: var(--space-md) var(--space-xl) 0; padding: 10px 12px; background: var(--color-warning-50); border: 1px solid var(--color-warning-100); border-radius: var(--radius-md); display: flex; align-items: center; gap: 10px; font-size: var(--font-size-xs); color: var(--color-warning-700); }
.lw-drawer__context svg { flex-shrink: 0; color: var(--color-warning-500); }
.lw-drawer__context strong { font-weight: var(--font-weight-semibold); }
.lw-drawer__body { flex: 1; overflow-y: auto; padding: var(--space-lg) var(--space-xl) var(--space-2xl); }
.lw-dgroup { margin-bottom: var(--space-lg); }
.lw-dgroup__head { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; }
.lw-dgroup__count { font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); }
.lw-dgroup__box { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.lw-dattr { display: grid; grid-template-columns: 170px 1fr; gap: var(--space-md); padding: 9px 12px; border-bottom: 1px solid var(--color-neutral-100); font-size: var(--font-size-sm); align-items: center; }
.lw-dattr:last-child { border-bottom: none; }
.lw-dattr__name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--color-text-secondary); font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); font-weight: var(--font-weight-semibold); }
.lw-dattr__val code { font-family: var(--font-mono); font-size: 11.5px; }
.lw-dattr__val--inherited { color: var(--color-text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.lw-dattr__val--inherited::before { content: "↑"; color: var(--color-success-500); font-weight: bold; }
.lw-dattr__val--empty { display: inline-flex; align-items: center; gap: 8px; color: var(--color-warning-700); font-family: var(--font-mono); font-size: var(--font-size-xs); }
.lw-dattr--focus { background: var(--color-warning-50); border-bottom-color: var(--color-warning-100); position: relative; }
.lw-dattr--focus::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--color-warning-500); }
.lw-drawer__foot { flex-shrink: 0; padding: var(--space-md) var(--space-xl); border-top: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
.lw-drawer__foot-hint { font-size: 10.5px; color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: var(--letter-spacing-wide); }
.lw-drawer__foot-hint kbd { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 3px; padding: 1px 5px; font-family: var(--font-mono); font-size: 10px; }

@media (max-width: 720px) {
  .lw-readiness { grid-template-columns: 1fr; }
  .lw-attr, .lw-attr-x__head { grid-template-columns: 16px 1fr; }
  .lw-attr .lw-mini, .lw-attr__value, .lw-attr-x__head .lw-mini { grid-column: 2; }
}

/* ============================================================
   7c. KARTA PRODUKTU — MODAL (pcm-*) — zastępuje drawer.
   Wyśrodkowany, STAŁY rozmiar (height, nie max-height) — nie skacze
   przy nawigacji ‹ › między produktami; treść scrolluje się wewnątrz.
   ============================================================ */
.pcm-overlay { position: fixed; inset: 0; background: rgba(15,29,54,.42); display: grid; place-items: center; z-index: var(--z-modal); padding: var(--space-xl); }
.pcm-modal { background: var(--color-surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); width: min(760px, 100%); height: min(760px, 88vh); display: flex; flex-direction: column; overflow: hidden; }

.pcm-head { flex-shrink: 0; padding: var(--space-md) var(--space-xl) 0; background: var(--color-surface); }
.pcm-head__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.pcm-nav { display: inline-flex; align-items: center; gap: 2px; }
.pcm-nav__btn, .pcm-close { width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; background: none; border: none; cursor: pointer; color: var(--color-text-secondary); transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out); }
.pcm-nav__btn:hover:not(:disabled), .pcm-close:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.pcm-close { color: var(--color-text-muted); }
.pcm-nav__pos { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-secondary); font-variant-numeric: tabular-nums; letter-spacing: var(--letter-spacing-wide); padding: 0 10px; white-space: nowrap; }
.pcm-nav__pos b { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.pcm-nav__set { font-family: var(--font-mono); font-size: 10px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); margin-left: 8px; border-left: 1px solid var(--color-border); padding-left: 10px; }
.pcm-head__navwrap { display: flex; align-items: center; gap: var(--space-md); min-width: 0; }
.pcm-nav__attr { min-width: 0; flex: 0 1 auto; font-family: var(--font-mono); font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-text-primary); font-weight: var(--font-weight-semibold); background: var(--color-neutral-50); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 3px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcm-head__name { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); line-height: 1.22; text-wrap: pretty; margin-bottom: 6px; }

.pcm-thumbs { display: flex; gap: 6px; margin-top: var(--space-md); overflow-x: auto; scrollbar-width: thin; }
.pcm-thumb { flex-shrink: 0; display: inline-flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; cursor: pointer; padding: 0; }
.pcm-thumb__chip { width: 38px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); background: repeating-linear-gradient(45deg, var(--color-neutral-100), var(--color-neutral-100) 4px, var(--color-neutral-200) 4px, var(--color-neutral-200) 8px); display: grid; place-items: center; transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out); }
.pcm-thumb__dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); }
.pcm-thumb__dot--empty    { background: var(--color-warning-500); }
.pcm-thumb__dot--pending  { background: var(--color-info-500); }
.pcm-thumb__dot--conflict { background: var(--color-danger-500); }
.pcm-thumb__dot--pimcore  { background: var(--color-success-500); }
.pcm-thumb:hover .pcm-thumb__chip { border-color: var(--color-brand-400); }
.pcm-thumb.is-active .pcm-thumb__chip { border-color: var(--color-brand-500); box-shadow: 0 0 0 2px var(--color-brand-100); }
.pcm-thumb__sap { font-family: var(--font-mono); font-size: 9px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.pcm-thumb.is-active .pcm-thumb__sap { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }

.pcm-tabs { display: flex; gap: 2px; margin: var(--space-sm) calc(-1 * var(--space-xl)) 0; padding: 0 var(--space-xl); border-bottom: 1px solid var(--color-border); }
.pcm-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out); }
.pcm-tab:hover { color: var(--color-text-primary); }
.pcm-tab.is-active { color: var(--color-text-primary); border-bottom-color: var(--color-brand-700); font-weight: var(--font-weight-semibold); }
.pcm-tab__badge { font-family: var(--font-mono); font-size: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full); background: var(--color-neutral-100); color: var(--color-text-secondary); display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.pcm-tab.is-active .pcm-tab__badge { background: var(--color-brand-50); color: var(--color-brand-700); }
.pcm-tab__badge--todo { background: var(--color-warning-50); color: var(--color-warning-700); }

.pcm-modal__body { flex: 1; overflow-y: auto; padding: var(--space-lg) var(--space-xl) var(--space-2xl); }

/* wiersz edytowalny */
.pcm-fill { display: grid; grid-template-columns: 190px 1fr; gap: var(--space-md); padding: 13px var(--space-lg); border-bottom: 1px solid var(--color-neutral-100); align-items: center; }
.pcm-fill:last-child { border-bottom: none; }
.pcm-fill__name { color: var(--color-text-primary); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); font-weight: var(--font-weight-semibold); display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.pcm-fill__type { display: block; width: 100%; margin-top: 2px; font-size: 9px; color: var(--color-text-muted); font-weight: var(--font-weight-regular); letter-spacing: var(--letter-spacing-wide); }
.pcm-fill__main { min-width: 0; min-height: 54px; display: flex; flex-direction: column; justify-content: center; }
.pcm-dot { display: inline-block; vertical-align: middle; width: 6px; height: 6px; border-radius: 50%; background: var(--color-brand-500); flex-shrink: 0; }

/* grid: pole (kol.1, wypełnia) + przyciski (kol.2, STAŁA kolumna) → „Zapisz" zawsze równo, niezależnie od typu pola */
.pcm-edit { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-sm); align-items: start; min-height: 34px; }
.pcm-edit .input, .pcm-edit .select { height: 34px; max-width: none; }
.pcm-edit .input--num { max-width: 140px; }
.pcm-edit .textarea { min-height: 64px; max-width: 100%; }
.pcm-edit__field { flex: 1 1 240px; min-width: 0; max-width: 360px; }   /* baza: używana też w batchu (flex) */
.pcm-edit > .pcm-edit__field { max-width: none; }                       /* w gridzie modala pole wypełnia kol.1 */
.pcm-edit__actions { display: flex; align-items: center; gap: 6px; }    /* kol.2 — Zapisz/Usuń w jednej kolumnie */
/* textarea: pole rośnie, ale przycisk zostaje OBOK (bez flex-basis:100%, które łamało wiersz) */
.pcm-edit__field--full { max-width: 100%; }
.pcm-edit__field .input, .pcm-edit__field .select, .pcm-edit__field .textarea { width: 100%; }
.pcm-edit__hint { margin-top: 6px; font-size: 10px; font-family: var(--font-mono); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); }

/* AttributeValueInput — lista sugestii wartości rozwijana po fokusie pola tekstowego */
.avi-ac { position: relative; }
/* position:fixed + JS (dqAcPosition) — nachodzi na treść (nie rozpycha wiersza) i nie jest ucinana przez modal */
.avi-ac__list { position: fixed; top: -9999px; left: 0; z-index: 1000; padding: 4px; list-style: none; max-height: 184px; overflow-y: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg, 0 8px 20px rgba(15,29,54,.16)); }
.avi-ac__item { padding: 6px 9px; border-radius: var(--radius-xs); font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-primary); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avi-ac__item:hover { background: var(--color-brand-50); color: var(--color-brand-700); }

.pcm-done { display: flex; align-items: center; flex-wrap: nowrap; gap: var(--space-sm); min-height: 34px; }
.pcm-done__val { flex: 0 1 auto; font-family: var(--font-mono); font-size: 12.5px; color: var(--color-text-primary); background: var(--color-neutral-50); border: 1px solid var(--color-border); border-radius: var(--radius-xs); padding: 4px 9px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcm-prov { flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-family: var(--font-mono); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcm-done__edit { margin-left: auto; }

.lw-vstatus { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 9px; border-radius: var(--radius-full); font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); font-weight: var(--font-weight-semibold); border: 1px solid transparent; }
.lw-vstatus::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.lw-vstatus--pending { background: var(--color-info-50); color: var(--color-info-700); border-color: var(--color-info-100); }
.lw-vstatus--pending::before { background: var(--color-info-500); }
.lw-vstatus--conflict { background: var(--color-danger-50); color: var(--color-danger-700); border-color: var(--color-danger-100); }
.lw-vstatus--conflict::before { background: var(--color-danger-500); }

.pcm-conflict { margin-top: 9px; display: flex; align-items: center; gap: 9px; font-size: var(--font-size-xs); color: var(--color-danger-700); background: var(--color-danger-50); border: 1px solid var(--color-danger-100); padding: 8px 11px; border-radius: var(--radius-sm); line-height: 1.4; }
.pcm-conflict svg { flex-shrink: 0; color: var(--color-danger-500); }
.pcm-conflict a { margin-left: auto; white-space: nowrap; font-weight: var(--font-weight-medium); flex-shrink: 0; }

.pcm-empty { display: flex; align-items: center; gap: 10px; padding: 16px var(--space-lg); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); font-size: var(--font-size-sm); color: var(--color-text-muted); }
.pcm-empty svg { color: var(--color-text-muted); flex-shrink: 0; }

.pcm-foot { flex-shrink: 0; padding: var(--space-md) var(--space-xl); border-top: 1px solid var(--color-border); background: var(--color-bg); display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); }
.pcm-foot__hint { font-size: 10.5px; color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: var(--letter-spacing-wide); }
.pcm-foot__actions { display: inline-flex; align-items: center; gap: var(--space-md); }
.pcm-deeplink { font-size: var(--font-size-xs); color: var(--color-text-link); display: inline-flex; align-items: center; gap: 4px; font-weight: var(--font-weight-medium); text-decoration: none; }
.pcm-deeplink:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .pcm-fill { grid-template-columns: 1fr; gap: 8px; }
  .pcm-fill__name { padding-top: 0; }
}

/* ============================================================
   7c. STRUKTURA — read-only wgląd w graf DataQuality (Atrybuty + Grupy).
   Jedna pozycja subnav „Struktura" z dwiema zakładkami; lista = tabela;
   detal = osobna strona. Prefiks: .st-  (tokeny z :root powyżej — bez duplikatów).
   ============================================================ */

/* Outbox: zarezerwowana pozycja subnav (Faza F). Subnav jest jasny → reuse [aria-disabled]. */
.app-subnav__inner .app-nav__phase {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--color-text-muted);
}

/* Szerokość/centrowanie daje .app-main__inner (1360). BEZ własnego max-width/margin:auto —
   inaczej jako flex-item z auto-marginesami kurczy się do treści (rozjazd zależny od scrollbara). */
.st-wrap { padding: 0 var(--space-3xl); }

/* Nagłówek strony + zakładki Atrybuty/Grupy */
.st-head { padding: 26px 0 0; }
/* nagłówek w detalu Struktury — ta sama forma co lista, + separacja od kontentu (brak zakładek) */
.st-head--detail { padding-bottom: var(--space-lg); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-xl); }
/* detal nie ma lede — tytuł wyrównany do góry rzędu (jak na liście), nie dociskany do dołu przy przycisku Powrót */
.st-head--detail .st-head__titlerow { align-items: flex-start; }
.st-head__crumbs {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
  margin-bottom: var(--space-sm);
}
.st-head__crumbs strong { color: var(--color-text-primary); font-weight: var(--font-weight-medium); }
.st-head__titlerow {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-xl);
  flex-wrap: wrap;
}
.st-head__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
  line-height: 1.12;
}
.st-head__lede {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  max-width: 720px;
  margin-top: 8px;
  line-height: 1.55;
}
/* Zakładki struktury */
.st-tabs {
  display: flex;
  gap: 2px;
  margin-top: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}
.st-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}
.st-tab:hover { color: var(--color-text-primary); }
.st-tab.is-active {
  color: var(--color-text-primary);
  border-bottom-color: var(--color-brand-700);
  font-weight: var(--font-weight-semibold);
}
.st-tab__count {
  font-family: var(--font-mono);
  font-size: var(--font-size-2xs);
  color: var(--color-text-muted);
  background: var(--color-neutral-100);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: var(--letter-spacing-wide);
  font-variant-numeric: tabular-nums;
}
.st-tab.is-active .st-tab__count { background: var(--color-brand-50); color: var(--color-brand-700); }

.st-panel { padding-bottom: 64px; }

/* Pasek sterowania (sticky) */
.st-controls { position: sticky; top: 0; z-index: 20; padding-top: var(--space-lg); background: var(--color-bg); }
.st-controls__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  padding: 12px var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.st-controls__row + .st-controls__row { margin-top: 8px; }

/* segmentowany Store */
.st-seg {
  display: inline-flex;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  flex-shrink: 0;
}
.st-seg__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: none;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.st-seg__btn:last-child { border-right: none; }
.st-seg__btn:hover:not(.is-active) { background: var(--color-neutral-50); color: var(--color-text-primary); }
.st-seg__btn.is-active { background: var(--color-brand-700); color: var(--color-neutral-0); font-weight: var(--font-weight-semibold); }
/* stała szerokość na 3 cyfry → segment ma tę samą szerokość przy 2- i 3-cyfrowych licznikach (grupy vs atrybuty) */
.st-seg__count { font-family: var(--font-mono); font-size: 10px; opacity: .7; font-variant-numeric: tabular-nums; display: inline-block; min-width: 3ch; text-align: center; }

.st-controls .select { height: 34px; width: auto; min-width: 130px; flex-shrink: 0; }
.st-search { position: relative; flex: 1; min-width: 200px; }
.st-search .input--search { height: 34px; }
.st-divider { width: 1px; height: 24px; background: var(--color-border); flex-shrink: 0; }

/* szybkie filtry (chipy) */
.st-quick { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.st-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.st-chip:hover { border-color: var(--color-border-strong); color: var(--color-text-primary); }
.st-chip.is-active { border-color: var(--color-brand-500); background: var(--color-brand-50); color: var(--color-brand-700); }
.st-chip__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.st-chip__dot--orphan { background: var(--color-info-500); }
.st-chip__dot--dead { background: var(--cat-missing); }
.st-chip__dot--globign { background: var(--color-neutral-400); }
.st-chip__dot--provider { background: var(--dq-diff); }
.st-chip__dot--inline { background: var(--dq-global); }
.st-chip__num { font-family: var(--font-mono); font-size: 10px; opacity: .65; font-variant-numeric: tabular-nums; }

.st-controls__right { display: inline-flex; align-items: center; gap: var(--space-md); margin-left: auto; flex-shrink: 0; }
.st-count { font-size: var(--font-size-sm); color: var(--color-text-secondary); white-space: nowrap; }
.st-count strong { font-weight: var(--font-weight-semibold); color: var(--color-text-primary); font-variant-numeric: tabular-nums; }
.st-sort { display: inline-flex; align-items: center; gap: 7px; font-size: var(--font-size-2xs); color: var(--color-text-muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); }
.st-sort .select { height: 30px; min-width: 0; font-size: var(--font-size-sm); }

/* Tabela */
.st-tablewrap {
  margin-top: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
/* table-layout: fixed → szerokości kolumn z <colgroup>, nie z treści → filtr store nie przesuwa siatki */
.st-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: var(--font-size-sm); }
.st-table td { overflow: hidden; text-overflow: ellipsis; }
.st-table thead th {
  position: sticky; top: 0;
  background: var(--color-neutral-50);
  color: var(--color-text-secondary);
  font-size: var(--font-size-2xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  font-weight: var(--font-weight-semibold);
  text-align: left;
  padding: 10px var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.st-table th.st-th--num, .st-table td.st-td--num { text-align: right; font-variant-numeric: tabular-nums; }
.st-table tbody td { padding: 11px var(--space-lg); border-bottom: 1px solid var(--color-neutral-100); vertical-align: middle; }
.st-table tbody tr { transition: background var(--duration-fast) var(--ease-out); }
.st-table tbody tr:hover { background: var(--color-neutral-50); }
.st-table tbody tr:last-child td { border-bottom: none; }

.st-name { font-weight: var(--font-weight-medium); color: var(--color-text-primary); display: flex; align-items: center; gap: 8px; }
.st-name__txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.st-id { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

/* typ + store jako badge */
.st-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--letter-spacing-wide);
  white-space: nowrap;
}
.st-badge--type { background: var(--color-neutral-100); color: var(--color-text-secondary); }
.st-badge--tech { background: var(--color-neutral-100); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.st-badge--reg  { background: var(--color-warning-50); color: var(--color-warning-700); border: 1px solid var(--color-warning-100); }

/* na liściach — paleta / obserwowany */
.st-leaves { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-leaves strong { color: var(--color-text-primary); font-family: var(--font-sans); font-weight: var(--font-weight-semibold); }
.st-leaves__off { color: var(--dq-diff); }
.st-leaves__sep { color: var(--color-neutral-300); margin: 0 2px; }

/* pokrycie own-brand: mini-bar + % + rozbicie */
.st-cover { display: grid; min-width: 0; }
.st-cover__top { display: flex; align-items: center; gap: 8px; }
.st-cover__track { flex: 1; height: 6px; border-radius: var(--radius-full); background: var(--color-neutral-100); overflow: hidden; display: flex; }
.st-cover__fill { height: 100%; background: var(--dq-global); }
.st-cover__fill--low { background: var(--dq-partial); }
.st-cover__fill--zero { background: var(--cat-missing); }
/* globalnie ignorowany — pasek szary „pod modyfikatorem" (nieaktywny) */
.st-cover__fill--ignored { background: var(--color-neutral-300); }
.st-cover--ignored .st-cover__pct { color: var(--color-neutral-400); }
.st-cover__pct { font-family: var(--font-mono); font-size: 11px; color: var(--color-text-primary); font-variant-numeric: tabular-nums; width: 34px; text-align: right; }
.st-cover__split { font-family: var(--font-mono); font-size: 9.5px; color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); }
.st-cover__split b { color: var(--cat-missing); font-family: var(--font-sans); }
.st-cover__split i { font-style: normal; color: var(--color-neutral-400); }
.st-cover--untouched { color: var(--color-neutral-400); font-family: var(--font-mono); font-size: 11px; }

/* plakietki stanu */
.st-flags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.st-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  border-radius: 3px;
  padding: 2px 6px;
  white-space: nowrap;
  font-weight: var(--font-weight-medium);
}
.st-flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.st-flag--orphan  { background: var(--color-info-50); color: var(--color-info-700); }
.st-flag--orphan::before { background: var(--color-info-500); }
.st-flag--dead    { background: #f9eceb; color: #8a392f; }
.st-flag--dead::before { background: var(--cat-missing); }
.st-flag--globign { background: var(--color-neutral-100); color: var(--color-text-secondary); }
.st-flag--globign::before { background: var(--color-neutral-400); }
.st-flag--deadgrp { background: var(--color-warning-50); color: var(--color-warning-700); }
.st-flag--deadgrp::before { background: var(--color-warning-500); }

.st-empty { display: none; flex-direction: column; align-items: center; text-align: center; padding: 64px 24px; }
.st-empty.is-shown { display: flex; }
.st-empty__icon { width: 42px; height: 42px; border-radius: var(--radius-full); background: var(--color-neutral-100); color: var(--color-text-muted); display: grid; place-items: center; margin-bottom: var(--space-md); }
.st-empty__title { font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }
.st-empty__body { font-size: var(--font-size-sm); color: var(--color-text-secondary); margin: 6px 0 16px; max-width: 360px; }

.st-foot-note {
  padding: 14px var(--space-lg);
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
  border-top: 1px solid var(--color-neutral-100);
}

/* objaśnienie kolumny pokrycia */
.st-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: var(--space-md);
  padding: 10px 14px;
  background: var(--color-info-50);
  border: 1px solid var(--color-info-100);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: var(--color-info-700);
  line-height: 1.5;
}
.st-note svg { flex-shrink: 0; color: var(--color-info-500); margin-top: 1px; }
.st-note b { font-weight: var(--font-weight-semibold); }

@media (max-width: 1100px) {
  .st-table .st-hide-md { display: none; }
  .st-col--collapsible { width: 0 !important; }   /* zwiń kolumnę razem z komórkami, by nie rozjechać siatki */
}

/* wiersz listy Struktury klikalny w całości → detal (AttributeDetail / GroupDetail) */
/* stała wysokość wiersza = ItemSize Virtualize (54px) → brak luk/nakładek przy scrollu */
.st-rowlink { cursor: pointer; height: 54px; }
.st-rowlink:hover { background: var(--color-neutral-50); }
.st-rowlink:hover .st-name__txt { color: var(--color-brand-700); }

/* ============================================================
   7d. STRUKTURA — detal atrybutu / grupy (osobne strony AttributeDetail/GroupDetail).
   Wspólne style obu detali. Reuse tokenów z :root powyżej. Prefiks: .sd-
   (blok :root i nadpisania app-nav z handoffu pominięte — tokeny już istnieją).
   ============================================================ */

.sd-wrap { padding: 0 var(--space-3xl); }

/* ---- pasek powrotu + stepper ---- */
.sd-navbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); padding: 16px 0 0; }
.sd-back {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--font-size-sm); color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium); background: none; border: none;
  cursor: pointer; padding: 6px 4px; border-radius: var(--radius-sm); text-decoration: none;
}
.sd-back:hover { color: var(--color-text-primary); }
.sd-backbtn { display: inline-flex; align-items: center; gap: 7px; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); padding: 7px 14px; text-decoration: none; white-space: nowrap; flex-shrink: 0; }
.sd-backbtn:hover { background: var(--color-neutral-50); color: var(--color-text-primary); border-color: var(--color-brand-500); text-decoration: none; }
.sd-backbtn svg { opacity: .7; }
.sd-stepper { display: inline-flex; align-items: center; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden; }
.sd-stepper__btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; font-size: var(--font-size-xs); color: var(--color-text-secondary); background: var(--color-surface); border: none; cursor: pointer; white-space: nowrap; text-decoration: none; }
.sd-stepper__btn:hover { background: var(--color-neutral-50); color: var(--color-text-primary); }
.sd-stepper__btn:disabled { opacity: .4; cursor: default; }
.sd-stepper__btn--prev { border-right: 1px solid var(--color-border); }
.sd-stepper__pos { font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); padding: 0 10px; letter-spacing: var(--letter-spacing-wide); font-variant-numeric: tabular-nums; }

/* ---- nagłówek ---- */
.sd-head { padding: 14px 0 var(--space-lg); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-xl); }
.sd-head__crumbs {
  font-family: var(--font-mono); font-size: var(--font-size-2xs); text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide); color: var(--color-text-muted);
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: var(--space-sm);
}
.sd-head__crumbs .sep { color: var(--color-neutral-300); }
.sd-head__crumbs strong { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.sd-head__titlerow { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-xl); flex-wrap: wrap; }
.sd-head__title { font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); line-height: 1.12; text-wrap: pretty; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sd-id {
  font-family: var(--font-mono); font-size: var(--font-size-md); color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold); display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-neutral-50); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 3px 9px;
}
.sd-id svg { width: 11px; height: 11px; opacity: .5; }

/* badges typu / store */
.sd-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--letter-spacing-wide); white-space: nowrap; }
.sd-badge--type { background: var(--color-neutral-100); color: var(--color-text-secondary); }
.sd-badge--tech { background: var(--color-neutral-100); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.sd-badge--reg  { background: var(--color-warning-50); color: var(--color-warning-700); border: 1px solid var(--color-warning-100); }
.sd-head__badges { display: inline-flex; gap: 7px; align-items: center; }

/* indykator „martwy w N z M grup" / sierota / globign */
.sd-signals { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-md); }
.sd-signal {
  display: inline-flex; align-items: center; gap: 7px; font-size: var(--font-size-xs);
  padding: 5px 11px; border-radius: var(--radius-full); border: 1px solid transparent; font-weight: var(--font-weight-medium);
}
.sd-signal::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sd-signal b { font-weight: var(--font-weight-semibold); }
.sd-signal--dead { background: var(--color-warning-50); color: var(--color-warning-700); border-color: var(--color-warning-100); }
.sd-signal--dead::before { background: var(--color-warning-500); }
.sd-signal--orphan { background: var(--color-info-50); color: var(--color-info-700); border-color: var(--color-info-100); }
.sd-signal--orphan::before { background: var(--color-info-500); }
.sd-signal--globign { background: var(--color-neutral-100); color: var(--color-text-secondary); border-color: var(--color-border); }
.sd-signal--globign::before { background: var(--color-neutral-400); }
.sd-signal--off { background: var(--dq-diff-bg); color: var(--color-info-700); border-color: var(--dq-diff-border); }
.sd-signal--off::before { background: var(--dq-diff); }

/* ---- metadane (grid kart) ---- */
.sd-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); margin-bottom: var(--space-xl); }
.sd-meta__card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 13px var(--space-lg); }
.sd-meta__card--wide { grid-column: span 2; }
.sd-meta__label { font-family: var(--font-mono); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); color: var(--color-text-muted); margin-bottom: 7px; }
.sd-meta__val { font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); color: var(--color-text-primary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sd-meta__val .sd-badge { font-weight: var(--font-weight-regular); }
.sd-meta__sub { font-size: var(--font-size-2xs); color: var(--color-text-muted); font-family: var(--font-mono); margin-top: 5px; letter-spacing: var(--letter-spacing-wide); }

/* wartości słownika (provider / inline) */
.sd-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sd-opt-chip {
  display: inline-flex; align-items: stretch; border: 1px solid var(--color-border);
  background: var(--color-surface); border-radius: var(--radius-sm); overflow: hidden; font-size: var(--font-size-xs);
}
.sd-opt-chip__label { padding: 4px 9px; font-family: var(--font-mono); font-size: 11.5px; color: var(--color-text-primary); white-space: nowrap; }
.sd-opt-chip__count { padding: 4px 8px; background: var(--color-neutral-50); border-left: 1px solid var(--color-border); font-family: var(--font-mono); font-size: 10.5px; color: var(--color-text-secondary); display: inline-flex; align-items: center; font-variant-numeric: tabular-nums; }
.sd-opt-provider { display: inline-flex; align-items: center; gap: 7px; }
.sd-opt-provider__tag { font-family: var(--font-mono); font-size: 12px; background: var(--dq-diff-bg); color: var(--color-info-700); border: 1px solid var(--dq-diff-border); border-radius: var(--radius-xs); padding: 2px 8px; }
.sd-opt-note { font-size: var(--font-size-2xs); color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: var(--letter-spacing-wide); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.sd-opt-note svg { flex-shrink: 0; color: var(--color-text-muted); }

/* ---- sekcje ---- */
.sd-section { margin-bottom: var(--space-2xl); }
.sd-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); flex-wrap: wrap; }
.sd-section__title { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); display: inline-flex; align-items: center; gap: 9px; }
.sd-section__count { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-muted); background: var(--color-neutral-100); border-radius: 999px; padding: 2px 9px; letter-spacing: var(--letter-spacing-wide); }
.sd-section__desc { font-size: var(--font-size-sm); color: var(--color-text-secondary); }

.sd-listcard { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }

/* ---- wiersz cross-link (grupa lub atrybut) ---- */
.sd-row { display: grid; gap: var(--space-md); align-items: center; padding: 12px var(--space-lg); border-bottom: 1px solid var(--color-neutral-100); transition: background var(--duration-fast) var(--ease-out); cursor: pointer; }
.sd-row:last-child { border-bottom: none; }
.sd-row:hover { background: var(--color-neutral-50); }
.sd-row--group { grid-template-columns: 60px minmax(150px, 1fr) 58px 132px max-content; }
.sd-row--key   { grid-template-columns: minmax(160px, 1fr) 96px max-content 132px max-content; }
.sd-row--leaf  { grid-template-columns: minmax(200px, 1.6fr) 150px 132px max-content; }

.sd-row__code { font-family: var(--font-mono); font-size: var(--font-size-sm); color: var(--color-text-primary); font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-row__link { display: inline-flex; align-items: center; gap: 7px; font-weight: var(--font-weight-medium); color: var(--color-text-primary); text-decoration: none; min-width: 0; }
.sd-row:hover .sd-row__link { color: var(--color-brand-700); }
.sd-row__link-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* mini-bar w wierszu */
.sd-mini { display: inline-grid; grid-template-columns: 1fr 48px; align-items: center; gap: 8px; width: 100%; }
.sd-mini__track { height: 6px; border-radius: var(--radius-full); background: var(--color-neutral-100); overflow: hidden; }
.sd-mini__fill { height: 100%; background: var(--dq-global); }
.sd-mini__fill--low { background: var(--dq-partial); }
.sd-mini__fill--zero { background: var(--cat-missing); }
.sd-mini__val { font-family: var(--font-mono); font-size: 10.5px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

/* rozjazd store (klucz reg w grupie tech itp.) */
.sd-mismatch { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-danger-700); background: var(--color-danger-50); border: 1px solid var(--color-danger-100); border-radius: 3px; padding: 2px 6px; margin-left: 6px; }

/* martwy w tej grupie znacznik */
.sd-deadhere { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-warning-700); background: var(--color-warning-50); border: 1px solid var(--color-warning-100); border-radius: 3px; padding: 2px 6px; }

/* ---- SLOT przyszłej akcji (Faza D „usuń z grupy") ---- */

/* nota promienia rażenia — pełnowierszowa pod listą kluczy w grupie */

/* ---- stan atrybutu na liściu (badge) ---- */
.sd-leafstate { display: inline-flex; align-items: center; gap: 6px; font-size: var(--font-size-2xs); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); font-weight: var(--font-weight-semibold); padding: 3px 9px; border-radius: var(--radius-full); border: 1px solid transparent; }
.sd-leafstate::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.sd-leafstate--global { background: var(--dq-global-bg); color: var(--color-success-700); border-color: var(--dq-global-border); }
.sd-leafstate--global::before { background: var(--dq-global); }
.sd-leafstate--diff { background: var(--dq-diff-bg); color: var(--color-info-700); border-color: var(--dq-diff-border); }
.sd-leafstate--diff::before { background: var(--dq-diff); }
.sd-leafstate--incomplete { background: var(--dq-partial-bg); color: var(--color-warning-700); border-color: var(--dq-partial-border); }
.sd-leafstate--incomplete::before { background: var(--dq-partial); }
.sd-leafstate--missing { background: var(--cat-missing-bg); color: var(--cat-missing-text); border-color: var(--cat-missing-border); }
.sd-leafstate--missing::before { background: var(--cat-missing); }
.sd-leafstate--ignored { background: var(--color-neutral-100); color: var(--color-text-secondary); border-color: var(--color-neutral-200); }
.sd-leafstate--ignored::before { background: var(--color-neutral-400); }
.sd-leafstate--optional { background: var(--dq-optional-bg); color: var(--dq-optional-text); border-color: var(--dq-optional-border); }
.sd-leafstate--optional::before { background: var(--dq-optional); }

.sd-tag-off { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-info-700); background: var(--color-info-50); border: 1px solid var(--color-info-100); border-radius: 3px; padding: 2px 5px; margin-left: 7px; }
.sd-tag-pal { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-text-muted); margin-left: 7px; }

.sd-row__open { color: var(--color-text-muted); justify-self: end; opacity: 0; transition: opacity var(--duration-fast) var(--ease-out); }
.sd-row:hover .sd-row__open { opacity: 1; color: var(--color-brand-700); }

.sd-more { padding: 11px var(--space-lg); text-align: center; font-size: var(--font-size-xs); color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: var(--letter-spacing-wide); border-top: 1px solid var(--color-neutral-100); background: var(--color-neutral-50); }
.sd-more a { color: var(--color-text-link); }

/* ---- overlay & triaż ---- */
.sd-triage { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
.sd-triage__card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-lg); }
.sd-triage__label { font-family: var(--font-mono); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); color: var(--color-text-muted); margin-bottom: 9px; display: flex; align-items: center; gap: 6px; }
.sd-triage__big { font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; line-height: 1; }
.sd-triage__row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.sd-triage__row .num { font-family: var(--font-mono); font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; }
.sd-triage__desc { font-size: var(--font-size-xs); color: var(--color-text-secondary); line-height: 1.45; margin-top: 8px; }
.sd-triage__desc b { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.sd-triage--outbox { background: var(--color-neutral-50); }
.sd-outbox-link { display: inline-flex; align-items: center; gap: 6px; font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 12px; font-weight: var(--font-weight-medium); cursor: default; }
.sd-pendnum { color: var(--color-info-700); }
.sd-confnum { color: var(--color-danger-700); }

/* dane liścia w grupie */
.sd-leaf-meta { font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); }
.sd-leaf-meta strong { color: var(--color-text-primary); font-family: var(--font-sans); font-weight: var(--font-weight-semibold); }

@media (max-width: 900px) {
  .sd-meta { grid-template-columns: 1fr 1fr; }
  .sd-meta__card--wide { grid-column: span 2; }
  .sd-triage { grid-template-columns: 1fr; }
  .sd-row--group, .sd-row--key, .sd-row--leaf { grid-template-columns: 1fr auto; }
  .sd-row--group > *:nth-child(n+3), .sd-row--key > *:nth-child(n+3), .sd-row--leaf > *:nth-child(n+3) { display: none; }
}

/* ============================================================
   7e. OUTBOX (Faza F) — DataQuality
   Wartości overlayu „dążące do zera". Płaska, cross-liściowa lista z dwiema
   sekcjami: Oczekujące (kolejka WYCHODZĄCA) i Konflikty (kolejka PRZEGLĄDU).
   Pierwsza powierzchnia z DZIAŁAJĄCYMI akcjami. Chipy stanu reuse: .lw-vstatus
   (globalne, sekcja 7c). (handoff: docs/outbox-handoff) — prefiks .ob-
   ============================================================ */
.ob-wrap { padding: 0 var(--space-3xl) var(--space-3xl); min-width: 0; }  /* szerokość/centrowanie z .app-main__inner — wzorzec .st-wrap; bez margin:auto; dolny odstęp od krawędzi strony */

/* ---- Nagłówek ---- */
.ob-head { padding: 26px 0 0; }
.ob-head__crumbs { font-size: var(--font-size-xs); color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: var(--letter-spacing-wide); margin-bottom: var(--space-sm); }
.ob-head__crumbs strong { color: var(--color-text-primary); font-weight: var(--font-weight-medium); }
.ob-head__titlerow { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-xl); flex-wrap: wrap; }
.ob-head__title { font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); line-height: 1.12; }
.ob-head__lede { font-size: var(--font-size-md); color: var(--color-text-secondary); max-width: 760px; margin-top: 8px; line-height: 1.55; }
.ob-head__cta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.ob-head__cta-scope { font-size: 10px; font-family: var(--font-mono); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); text-align: right; }

/* ---- Pasek liczników ---- */
.ob-counts { display: flex; align-items: stretch; gap: 0; margin-top: var(--space-lg); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); overflow: hidden; }
.ob-count { padding: 14px var(--space-xl); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ob-count:last-child { border-right: none; }
.ob-count--push { margin-left: auto; align-items: flex-end; text-align: right; background: var(--color-neutral-50); justify-content: center; }
.ob-count__label { font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); color: var(--color-text-muted); font-weight: var(--font-weight-semibold); display: inline-flex; align-items: center; gap: 6px; }
.ob-count__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ob-count__dot--pending { background: var(--color-info-500); }
.ob-count__dot--conflict { background: var(--color-danger-500); }
.ob-count__value { font-size: 26px; font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-tight); line-height: 1; font-feature-settings: "tnum"; }
.ob-count__split { font-size: 10.5px; font-family: var(--font-mono); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); }
.ob-count__split b { color: var(--color-text-secondary); font-family: var(--font-sans); font-weight: var(--font-weight-semibold); }
.ob-count__split .reg { color: var(--color-warning-700); }
.ob-trend { display: inline-flex; align-items: center; gap: 7px; font-size: var(--font-size-xs); color: var(--color-text-muted); }
.ob-trend__slot { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--color-border-strong); border-radius: var(--radius-sm); padding: 3px 8px; background: var(--color-neutral-50); color: var(--color-text-muted); font-size: var(--font-size-xs); cursor: not-allowed; }
.ob-trend__slot svg { opacity: .6; }
.ob-phase { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); color: var(--color-brand-700); background: var(--color-brand-50); border: 1px solid var(--color-brand-100); border-radius: 3px; padding: 1px 5px; }

/* ---- Nota narracyjna ---- */
.ob-note { display: flex; align-items: flex-start; gap: 10px; margin-top: var(--space-md); padding: 10px 14px; background: var(--color-info-50); border: 1px solid var(--color-info-100); border-radius: var(--radius-md); font-size: var(--font-size-xs); color: var(--color-info-700); line-height: 1.5; }
.ob-note svg { flex-shrink: 0; color: var(--color-info-500); margin-top: 1px; }
.ob-note b { font-weight: var(--font-weight-semibold); }

/* ---- Zakładki sekcji ---- */
.ob-tabs { display: flex; gap: 2px; margin-top: var(--space-lg); border-bottom: 1px solid var(--color-border); }
.ob-tab { display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; font-size: var(--font-size-md); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color var(--duration-fast) var(--ease-out); }
.ob-tab:hover { color: var(--color-text-primary); }
.ob-tab.is-active { color: var(--color-text-primary); border-bottom-color: var(--color-brand-700); font-weight: var(--font-weight-semibold); }
.ob-tab__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ob-tab__count { font-family: var(--font-mono); font-size: var(--font-size-2xs); color: var(--color-text-muted); background: var(--color-neutral-100); padding: 2px 7px; border-radius: 999px; letter-spacing: var(--letter-spacing-wide); font-variant-numeric: tabular-nums; }
.ob-tab.is-active .ob-tab__count { background: var(--color-brand-50); color: var(--color-brand-700); }

/* ---- Pasek sterowania (filtry) ---- */
.ob-controls { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; padding: 12px var(--space-lg); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.ob-seg { display: inline-flex; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); overflow: hidden; background: var(--color-surface); flex-shrink: 0; }
.ob-seg__btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); background: var(--color-surface); border: none; border-right: 1px solid var(--color-border); cursor: pointer; transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out); white-space: nowrap; }
.ob-seg__btn:last-child { border-right: none; }
.ob-seg__btn:hover:not(.is-active) { background: var(--color-neutral-50); color: var(--color-text-primary); }
.ob-seg__btn.is-active { background: var(--color-brand-700); color: var(--color-neutral-0); font-weight: var(--font-weight-semibold); }
.ob-controls .select { height: 34px; width: auto; min-width: 122px; max-width: 170px; flex-shrink: 0; }
.ob-search { position: relative; flex: 1 1 180px; min-width: 160px; }
.ob-controls .ob-sort { margin-left: 0; }
.ob-search .input--search { height: 34px; }
.ob-divider { width: 1px; height: 24px; background: var(--color-border); flex-shrink: 0; }
.ob-controls__right { display: inline-flex; align-items: center; gap: var(--space-md); margin-left: auto; flex-shrink: 0; }
.ob-count-txt { font-size: var(--font-size-sm); color: var(--color-text-secondary); white-space: nowrap; }
.ob-count-txt strong { font-weight: var(--font-weight-semibold); color: var(--color-text-primary); font-variant-numeric: tabular-nums; }
.ob-sort { display: inline-flex; align-items: center; gap: 7px; font-size: var(--font-size-2xs); color: var(--color-text-muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); }
.ob-sort .select { height: 30px; min-width: 0; font-size: var(--font-size-sm); }

/* ---- Tabela ---- */
.ob-tablewrap { margin-top: var(--space-md); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }
.ob-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--font-size-sm); }
.ob-table thead th { position: sticky; top: 0; z-index: 2; background: var(--color-neutral-50); color: var(--color-text-secondary); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); font-weight: var(--font-weight-semibold); text-align: left; padding: 10px var(--space-lg); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.ob-table th.ob-th-check, .ob-table td.ob-td-check { width: 38px; padding-left: var(--space-lg); padding-right: 0; }
.ob-table th.ob-th-act { text-align: left; }
.ob-table tbody td { padding: 11px var(--space-lg); border-bottom: 1px solid var(--color-neutral-100); vertical-align: middle; }
.ob-table tbody tr { transition: background var(--duration-fast) var(--ease-out); }
.ob-table tbody tr:hover { background: var(--color-neutral-50); }
.ob-table tbody tr:last-child td { border-bottom: none; }
.ob-table tbody tr.is-selected { background: var(--color-brand-50); }
.ob-table tbody tr.is-selected:hover { background: var(--color-brand-100); }
.ob-table tbody tr.is-highlight { background: var(--color-warning-50); box-shadow: inset 3px 0 0 var(--color-warning-500); }

/* komórka liść */
.ob-leaf__name { font-weight: var(--font-weight-medium); color: var(--color-text-primary); white-space: nowrap; }
.ob-leaf__name a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.ob-leaf__name a:hover { color: var(--color-brand-700); text-decoration: underline; }
.ob-leaf__name a svg { color: var(--color-text-muted); opacity: 0; transition: opacity var(--duration-fast) var(--ease-out); }
.ob-table tbody tr:hover .ob-leaf__name a svg { opacity: 1; }
.ob-leaf__path { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-text-muted); margin-top: 3px; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-leaf__orphan { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-danger-700); background: var(--color-danger-50); border: 1px solid var(--color-danger-100); border-radius: 3px; padding: 2px 6px; margin-top: 4px; }
.ob-leaf__orphan svg { flex-shrink: 0; }

/* komórka produkt */
.ob-prod__sap { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ob-prod__name { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 2px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-prod__name--marker { display: inline-flex; align-items: center; gap: 4px; }
.ob-prod__name--marker svg { opacity: .5; }

/* komórka atrybut */
.ob-attr__name { font-weight: var(--font-weight-medium); color: var(--color-text-primary); white-space: nowrap; }
.ob-attr__meta { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; }
.ob-store { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 9px; letter-spacing: var(--letter-spacing-wide); white-space: nowrap; }
.ob-store--tech { background: var(--color-neutral-100); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.ob-store--reg { background: var(--color-warning-50); color: var(--color-warning-700); border: 1px solid var(--color-warning-100); }

/* komórka wartość */
.ob-val { font-family: var(--font-mono); font-size: 12px; color: var(--color-text-primary); background: var(--color-neutral-50); border: 1px solid var(--color-border); border-radius: var(--radius-xs); padding: 4px 9px; display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.ob-vpair { display: inline-flex; align-items: center; gap: 9px; }
.ob-vpair__side { display: inline-flex; flex-direction: column; gap: 3px; }
.ob-vpair__lbl { font-family: var(--font-mono); font-size: 8.5px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-text-muted); }
.ob-vpair__lbl--win { color: var(--color-danger-700); }
.ob-val--ours { border-color: var(--color-danger-100); background: var(--color-danger-50); color: var(--color-danger-700); text-decoration: line-through; text-decoration-color: var(--color-danger-300, rgba(196,43,28,.45)); }
.ob-val--pim { border-color: var(--color-success-100); background: var(--color-success-50); color: var(--color-success-700); font-weight: var(--font-weight-semibold); }
.ob-vpair__arrow { color: var(--color-text-muted); flex-shrink: 0; margin-top: 14px; }

/* komórka proweniencja */
.ob-prov { white-space: nowrap; }
.ob-prov__who { display: inline-flex; align-items: center; gap: 5px; font-size: var(--font-size-xs); color: var(--color-text-secondary); }
.ob-prov__who svg { opacity: .55; }
.ob-prov__when { font-family: var(--font-mono); font-size: 9.5px; color: var(--color-text-muted); margin-top: 3px; letter-spacing: var(--letter-spacing-wide); }
.ob-prov__when[title] { cursor: help; border-bottom: 1px dotted var(--color-border-strong); display: inline-block; }

/* szybki tooltip (bez opóźnienia natywnego title) — wartość: kto·data; SAP: nazwa produktu */
.ob-tip { position: relative; }
.ob-tip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 7px); z-index: 40;
  width: max-content; max-width: 360px; white-space: normal;
  background: var(--color-neutral-900, #18233b); color: var(--color-neutral-0, #fff);
  font-family: var(--font-sans); font-size: var(--font-size-xs); font-weight: var(--font-weight-medium);
  line-height: 1.4; padding: 5px 9px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); pointer-events: none;
}
.ob-tip[data-tip]:hover::before {
  content: ""; position: absolute; left: 12px; bottom: calc(100% + 2px); z-index: 40;
  border: 5px solid transparent; border-top-color: var(--color-neutral-900, #18233b); pointer-events: none;
}

/* akcje wiersza */
.ob-acts { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-start; white-space: nowrap; }
.ob-act { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); background: transparent; cursor: pointer; white-space: nowrap; transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out); }
.ob-act:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.ob-act--primary { border-color: var(--color-border-strong); background: var(--color-surface); color: var(--color-text-primary); }
.ob-act--primary:hover { background: var(--color-neutral-50); border-color: var(--color-neutral-400); }
.ob-act--danger:hover { background: var(--color-danger-50); color: var(--color-danger-700); }
.ob-act:disabled { opacity: .45; cursor: not-allowed; }
.ob-act svg { flex-shrink: 0; }

/* ---- Stany puste ---- */
.ob-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.ob-empty__icon { width: 46px; height: 46px; border-radius: var(--radius-full); background: var(--color-success-50); color: var(--color-success-500); display: grid; place-items: center; margin-bottom: var(--space-md); }
.ob-empty__icon--filtered { background: var(--color-neutral-100); color: var(--color-text-muted); }
.ob-empty__title { font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }
.ob-empty__body { font-size: var(--font-size-sm); color: var(--color-text-secondary); margin: 6px 0 0; max-width: 420px; line-height: 1.55; }
.ob-empty .btn { margin-top: var(--space-md); }
.ob-success { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 80px 24px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); margin-top: var(--space-lg); }
.ob-success__icon { width: 60px; height: 60px; border-radius: var(--radius-full); background: var(--color-success-50); color: var(--color-success-500); display: grid; place-items: center; margin-bottom: var(--space-lg); }
.ob-success__title { font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); }
.ob-success__body { font-size: var(--font-size-md); color: var(--color-text-secondary); margin: 10px 0 0; max-width: 480px; line-height: 1.6; }
.ob-success__hint { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: var(--space-lg); letter-spacing: var(--letter-spacing-wide); }

/* ---- Lekkie dialogi Outboxu (NIE drawer karty produktu) ---- */
.ob-dialog-overlay { position: fixed; inset: 0; background: rgba(15,29,54,.42); display: grid; place-items: center; z-index: var(--z-modal); padding: var(--space-xl); }
.ob-dialog { background: var(--color-surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); width: 100%; max-width: 460px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.ob-dialog--wide { max-width: 760px; }
.ob-dialog__head { padding: var(--space-xl) var(--space-xl) var(--space-md); display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-md); }
.ob-dialog__title { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-snug); }
.ob-dialog__sub { font-size: var(--font-size-sm); color: var(--color-text-secondary); margin-top: 5px; line-height: 1.5; }
.ob-dialog__close { width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--color-text-muted); flex-shrink: 0; cursor: pointer; background: none; border: none; }
.ob-dialog__close:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
.ob-dialog__body { padding: 0 var(--space-xl) var(--space-lg); overflow-y: auto; }
.ob-dialog__foot { padding: var(--space-md) var(--space-xl); border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: var(--space-sm); align-items: center; }
.ob-dialog__foot--split { justify-content: space-between; }
.ob-confirm-body { font-size: var(--font-size-sm); color: var(--color-text-secondary); line-height: 1.6; }

/* edytor wartości w dialogu (type-aware) */
.ob-ed { display: flex; flex-direction: column; gap: var(--space-sm); }
.ob-ed__attr { display: inline-flex; align-items: center; gap: 8px; font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }
.ob-ed__field .input, .ob-ed__field .select, .ob-ed__field .textarea { max-width: 100%; width: 100%; }
.ob-ed__hint { margin-top: 2px; font-size: 10px; font-family: var(--font-mono); color: var(--color-text-muted); letter-spacing: var(--letter-spacing-wide); display: inline-flex; align-items: center; gap: 5px; }
.ob-ed__prev { display: inline-flex; align-items: center; gap: 7px; font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 8px; flex-wrap: wrap; }
.ob-ed__prev .ob-val { font-size: 11px; }
.ob-ed__err { font-size: var(--font-size-xs); color: var(--color-danger-700); margin-top: 4px; }

/* dialog dokumentu — zakładki wyjścia */
.ob-out-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); margin: 0 0 var(--space-md); }
.ob-out-tab { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.ob-out-tab.is-active { color: var(--color-text-primary); border-bottom-color: var(--color-brand-700); font-weight: var(--font-weight-semibold); }
.ob-out-tab:disabled { color: var(--color-text-muted); cursor: not-allowed; }
.ob-out-tab__phase { font-family: var(--font-mono); font-size: 8.5px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-brand-700); background: var(--color-brand-50); border: 1px solid var(--color-brand-100); border-radius: 3px; padding: 1px 4px; }
.ob-doctable-wrap { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; max-height: 320px; overflow-y: auto; }
.ob-doctable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--font-size-xs); }
.ob-doctable th { position: sticky; top: 0; background: var(--color-neutral-50); text-align: left; padding: 8px var(--space-md); font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-spacing-wide); color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.ob-doctable td { padding: 7px var(--space-md); border-bottom: 1px solid var(--color-neutral-100); font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--color-text-secondary); white-space: nowrap; }
.ob-doctable td.ob-doc-val { font-family: var(--font-sans); color: var(--color-text-primary); white-space: normal; }
.ob-doctable tr:last-child td { border-bottom: none; }
.ob-doc-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); font-size: var(--font-size-sm); color: var(--color-text-secondary); }
.ob-doc-meta strong { color: var(--color-text-primary); font-weight: var(--font-weight-semibold); }
.ob-doc-actions { display: inline-flex; gap: 8px; }
.ob-doc-note { display: flex; align-items: flex-start; gap: 9px; margin-top: var(--space-md); padding: 9px 12px; background: var(--color-info-50); border: 1px solid var(--color-info-100); border-radius: var(--radius-sm); font-size: var(--font-size-xs); color: var(--color-info-700); line-height: 1.45; }
.ob-doc-note svg { flex-shrink: 0; color: var(--color-info-500); margin-top: 1px; }

/* toast */
.ob-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px); background: var(--color-brand-700); color: var(--color-neutral-0); padding: 9px 16px; border-radius: var(--radius-md); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); box-shadow: var(--shadow-lg); z-index: var(--z-toast); opacity: 0; pointer-events: none; transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out); display: inline-flex; align-items: center; gap: 8px; }
.ob-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1180px) {
  .ob-table .ob-hide-md { display: none; }
}

/* ===== Import (DataQuality, admin) — przeniesione z inline <style> ImportSettings.razor.
   Klasy używane wyłącznie przez ImportSettings; trzymane tu dla spójności (jeden plik stylów). ===== */
@keyframes dq-import-slide {
    0%   { transform: translateX(-110%); }
    100% { transform: translateX(310%); }
}

.import-section { margin-bottom: var(--space-2xl); }
.import-section__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
}
.import-section__title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--letter-spacing-snug);
    color: var(--color-text-primary);
}
.import-section__desc {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    max-width: 640px;
    margin-top: 2px;
}
.import-section__aux {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    flex-shrink: 0;
}

.surface {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-xl);
}

.source-row {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    align-items: center;
    gap: var(--space-lg);
    padding: 10px 0;
    border-bottom: 1px solid var(--color-neutral-100);
}
.source-row:last-child { border-bottom: none; }
.source-row__label {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-semibold);
}
.source-row__value {
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    font-family: var(--font-mono);
    word-break: break-all;
}

.table-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px var(--space-lg);
    background: var(--color-neutral-50);
    border-top: 1px solid var(--color-border);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

.checkrow {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    padding: 8px 0;
    cursor: pointer;
}
.checkrow__hint {
    margin-left: auto;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

.cell--code {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
}

.table--config th:last-child,
.table--config td:last-child {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

.history-list {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.history-row {
    display: grid;
    grid-template-columns: 160px 110px 1fr auto;
    align-items: center;
    gap: var(--space-lg);
    padding: 14px var(--space-lg);
    border-bottom: 1px solid var(--color-neutral-100);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}
.history-row:last-child { border-bottom: none; }
.history-row:hover { background: var(--color-neutral-50); }
.history-row.is-expanded { background: var(--color-neutral-50); }
.history-row__when {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    font-weight: var(--font-weight-medium);
}
.history-row__when-sub {
    font-size: var(--font-size-2xs);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    margin-top: 2px;
}
.history-row__summary {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}
.history-row__meta {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.history-detail {
    padding: var(--space-lg) var(--space-2xl) var(--space-xl);
    background: var(--color-neutral-50);
    border-bottom: 1px solid var(--color-neutral-100);
}
.history-detail__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-xl);
    margin-bottom: var(--space-md);
}
.history-detail__metric-label {
    font-size: var(--font-size-2xs);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-semibold);
    margin-bottom: 4px;
}
.history-detail__metric-value {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.history-detail__metric-value--ok  { color: var(--color-success-700); }
.history-detail__metric-value--err { color: var(--color-danger-700); }

.history-detail__trace {
    background: var(--color-danger-50);
    border: 1px solid var(--color-danger-100);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-danger-700);
    white-space: pre-wrap;
    line-height: var(--line-height-snug);
    max-height: 220px;
    overflow: auto;
    margin-top: var(--space-md);
}

.history-detail__actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.schedule-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    align-items: start;
    gap: var(--space-lg);
    padding: 10px 0;
    border-bottom: 1px solid var(--color-neutral-100);
}
.schedule-row:last-child { border-bottom: none; }

.dq-status--error {
    background: var(--color-danger-50);
    color: var(--color-danger-700);
    border-color: var(--color-danger-100);
}
.dq-status--error::before { background: var(--color-danger-500); }
.dq-status--running {
    background: var(--color-info-50);
    color: var(--color-info-700);
    border-color: var(--color-info-100);
}
.dq-status--running::before { background: var(--color-info-500); }

.chevron { transition: transform 200ms ease; }
.chevron--up { transform: rotate(180deg); }
