/* ============================================================
   Fakturowanie - arkusz stylów
   Motyw: "bento" - chłodne, lawendowoszare tło, białe karty bez obramowań,
   fiolet jako akcent, ciemny grafit dla najważniejszego kafla (Merchanci).
   Czerwień tylko dla błędów.
   Jasny/ciemny: tokeny przez light-dark(); o trybie decyduje
   color-scheme na :root (auto / data-theme="light" / "dark").
   ============================================================ */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('fonts/manrope-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('fonts/manrope-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokeny ---------- */

:root {
  color-scheme: light dark;

  --bg:          light-dark(#ececf2, #121119);
  --surface:     light-dark(#ffffff, #1b1a25);
  --surface-2:   light-dark(#f6f6f9, #23222f);
  --line:        light-dark(#e4e4eb, #2d2c3a);
  --line-strong: light-dark(#cbcad6, #423f52);

  --ink:       light-dark(#1c1b29, #ecebf3);
  --ink-soft:  light-dark(#5c5b6e, #aaa9bc);
  --ink-faint: light-dark(#67667b, #8a899e);

  --accent:        light-dark(#5b3fd1, #a996ff);
  --accent-strong: light-dark(#4a2fc0, #c7bbff);
  --accent-ink:    light-dark(#ffffff, #170f38);
  --accent-soft:   light-dark(#ebe6fb, #2a2349);

  --ok:    light-dark(#17804c, #5cc995);
  --warn:  light-dark(#93600a, #e7b24c);
  --error: light-dark(#c23b32, #f2877e);

  /* spółki - ten sam kolor w każdej tabeli */
  --co-sm: light-dark(#6a45cf, #b39dff);
  --co-gs: light-dark(#0a6e69, #4fd1c5);
  --co-ex: light-dark(#b5327d, #f08cc4);
  --co-ss: light-dark(#9a5200, #f2a64a);

  /* ciemny kafel (Merchanci na Starcie) - w obu motywach ciemny */
  --hero:      light-dark(#1c1b29, #26223f);
  --hero-ink:  #ffffff;
  --hero-soft: #c9c8d6;
  --hero-line: rgb(255 255 255 / .22);

  --shadow-sm:  0 1px 2px light-dark(rgb(28 27 41 / .06), rgb(0 0 0 / .45));
  --shadow-pop: 0 1px 2px light-dark(rgb(28 27 41 / .06), rgb(0 0 0 / .4)),
                0 18px 40px -14px light-dark(rgb(28 27 41 / .3), rgb(0 0 0 / .7));

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --appbar-h: 72px;
}

:root[data-theme="light"] { color-scheme: light; }

/* Motyw świąteczny: zieleń jodły jako akcent, bordowy kafel, śnieg w tle.
   Działa razem z jasnym i ciemnym. Włącza go atrybut data-festive (_head.html). */
:root[data-festive] {
  --accent:        light-dark(#1d6f47, #72d39e);
  --accent-strong: light-dark(#155a39, #a2e6c0);
  --accent-ink:    light-dark(#ffffff, #0b2618);
  --accent-soft:   light-dark(#e0f1e7, #17342a);

  --hero:      light-dark(#6a1a25, #4b1620);
  --hero-soft: #efd6d9;
  --hero-line: rgb(255 255 255 / .24);

  --snow: light-dark(#b7c2da, #ffffff);
}
:root[data-theme="dark"]  { color-scheme: dark; }

/* przełączanie motywu - bez "płynięcia" kolorów */
:root.theme-switching *,
:root.theme-switching *::before,
:root.theme-switching *::after { transition: none !important; }

/* ---------- Podstawy ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--appbar-h) + 16px);
}

html, body { margin: 0; }

body {
  min-height: 100vh;
  font: 400 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, p { margin: 0; }

a { color: var(--accent); }

::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden { display: none !important; }
.muted { color: var(--ink-faint); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

kbd {
  font: 500 11.5px/1 var(--font);
  color: var(--ink-faint);
}

/* ============================================================
   Pasek górny
   ============================================================ */

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
}

.appbar-inner {
  max-width: 1440px;
  height: var(--appbar-h);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.015em;
}

/* Znak: "FV" z podwójną kreską - tak w księgach podkreśla się sumy */
.brand-mark {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding-bottom: 5px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  height: 4px;
  border-top: 1.25px solid currentColor;
  border-bottom: 1.25px solid currentColor;
  opacity: 0.75;
}

/* Zakładki: biała "pigułka", aktywna zakładka = ciemna pigułka w środku */
.topnav-links {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0 auto;
  display: flex;
  gap: 2px;
  padding: 5px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}

.topnav-links::-webkit-scrollbar { display: none; }

.topnav-links > a {
  position: relative;
  isolation: isolate;
  flex: none;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease;
}

.topnav-links > a.active { color: var(--surface); font-weight: 700; }

/* Tło aktywnej zakładki. Przy przejściu między panelami przesuwa się
   do nowej zakładki (view transition, patrz koniec pliku). */
.nav-ind {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--ink);
  view-transition-name: nav-ind;
}

/* Kategorie w pasku (Rozliczenia, Księgowość): <details class="menu nav-group">.
   Selektory z .nav-group, bo .menu-panel (niżej w pliku) ustawia position: absolute.
   Panel jest position: fixed (ui.js ustawia left/top przy otwarciu), więc nie
   przycina go overflow paska zakładek. */
.nav-group { position: static; }

.nav-group > summary {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 10px 0 12px;
  border-radius: var(--radius-full);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 150ms ease, background-color 150ms ease;
}

.nav-group > summary.active { color: var(--surface); font-weight: 700; }
.nav-group[open] > summary:not(.active) { color: var(--ink); background: var(--surface-2); }
.nav-group > summary:focus-visible { outline-offset: -2px; }

.nav-current { font-weight: 600; opacity: .72; }
.nav-chevron { width: 14px; height: 14px; flex: none; opacity: .7; transition: rotate 160ms var(--ease-out); }
.nav-group[open] .nav-chevron { rotate: 180deg; }

.nav-group .nav-panel {
  position: fixed;
  top: calc(var(--appbar-h) - 8px);
  left: 0;
  right: auto;
  z-index: 50;
  min-width: 290px;
  transform-origin: top left;
}

.nav-group .nav-panel a { display: grid; gap: 1px; padding: 9px 12px; }
.nav-group .nav-panel a strong { font-size: 14px; font-weight: 700; }
.nav-group .nav-panel a small { color: var(--ink-soft); font-size: 12.5px; font-weight: 500; }
.nav-group .nav-panel a.active { background: var(--accent-soft); }
.nav-group .nav-panel a.active strong { color: var(--accent-strong); }

.appbar-end {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-switch {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.theme-switch button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, transform 140ms var(--ease-out);
}

.theme-switch button svg { width: 15px; height: 15px; }
.theme-switch button:active { transform: scale(0.92); }

.theme-switch button[aria-checked="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.festive-toggle {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, transform 140ms var(--ease-out);
}

.festive-toggle svg { width: 16px; height: 16px; }
.festive-toggle:active { transform: scale(0.92); }

.festive-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* czapka na znaku FV */
:root[data-festive] .brand-mark::before {
  content: "";
  position: absolute;
  top: -12px;
  right: -10px;
  width: 26px;
  height: 22px;
  rotate: 16deg;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 22'%3E%3Cpath d='M4 16C6 8 11 3 19 3c-2 4-1.5 8 1 13z' fill='%23d3313c'/%3E%3Crect x='2' y='15' width='20' height='6' rx='3' fill='%23fff'/%3E%3Ccircle cx='20' cy='3.5' r='3' fill='%23fff'/%3E%3C/svg%3E") no-repeat center / contain;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / .18));
  pointer-events: none;
}

/* śnieg pod kartami: widać go tylko na tle strony */
#fv-snow {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

#fv-snow i {
  position: absolute;
  top: -12px;
  border-radius: 50%;
  background: var(--snow);
  animation-name: fv-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes fv-fall {
  to { transform: translate3d(var(--drift, 0), 105vh, 0); }
}

/* Użytkownik: pigułka z awatarem, imieniem i przyciskiem wylogowania */
.topnav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
}

.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.user-text { display: flex; align-items: baseline; gap: 5px; line-height: 1.2; }
.user-name { color: var(--ink); font-weight: 700; }
.user-role { color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.user-role::before { content: "· "; }

.logout {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
}

.logout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.logout svg { width: 16px; height: 16px; }

/* ============================================================
   Układ strony
   ============================================================ */

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.page-narrow { max-width: 780px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.028em;
}

.page-subtitle {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 15.5px;
}

/* ============================================================
   Przyciski
   ============================================================ */

.btn,
.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 140ms var(--ease-out), background-color 150ms ease,
              border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.btn svg { width: 16px; height: 16px; flex: none; }

/* wciśnięcie - interfejs "słyszy" kliknięcie */
.btn:active:not(:disabled),
.btn-primary:active:not(:disabled),
.btn-primary.pressed { transform: scale(0.97); }

.btn:disabled, .btn-primary:disabled { opacity: 0.55; cursor: default; }

.btn-accent,
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), var(--shadow-sm);
}

.btn-neutral {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ok {
  background: color-mix(in srgb, var(--ok) 11%, var(--surface));
  border-color: color-mix(in srgb, var(--ok) 28%, transparent);
  color: var(--ok);
}

.btn-danger {
  background: color-mix(in srgb, var(--error) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--error) 26%, transparent);
  color: var(--error);
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-block { width: 100%; height: 44px; }

/* Przycisk "Szukaj": szerokość nie skacze przy ładowaniu */
.btn-primary { height: 48px; padding: 0 22px; font-size: 15px; border-radius: var(--radius); flex: none; }

.btn-spinner,
.btn-spinner-sm {
  display: none;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  animation: spin 600ms linear infinite;
}

.btn-spinner { position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; }
.btn-spinner-sm { width: 12px; height: 12px; }

.btn-primary.loading .btn-label { opacity: 0; }
.btn-primary.loading .btn-spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Pola formularzy
   ============================================================ */

input[type=text], input[type=password], input[type=date],
input[type=search], input[type=email], input[type=number],
select, textarea {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

textarea { height: auto; padding: 8px 11px; line-height: 1.45; resize: vertical; }

input::placeholder, textarea::placeholder { color: var(--ink-faint); }

input[type=text]:focus, input[type=password]:focus, input[type=date]:focus,
input[type=search]:focus, input[type=email]:focus, input[type=number]:focus,
select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2367667b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
}

select:disabled, input:disabled, textarea:disabled { opacity: 0.55; cursor: default; }

input[type=checkbox] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

/* pola wyszukiwania w paskach filtrów dostają lupę */
.toolbar input[name=q],
input.rk-search {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2367667b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
  background-size: 15px;
}

input[type=file] {
  max-width: 100%;
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
}

input[type=file]::file-selector-button {
  height: 32px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

/* ============================================================
   Statusy, spółki, komunikaty
   ============================================================ */

.badge {
  --tone: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 8px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: var(--tone);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.badge::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ok   { --tone: var(--ok); }
.badge-err  { --tone: var(--error); }
.badge-warn { --tone: var(--warn); }
.badge-neutral {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* Spółki: pełne kolorowe etykiety (jak na Starcie) - odróżniają się od statusów-pigułek */
.co {
  --co: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--co);
  color: var(--surface);
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.co-sm { --co: var(--co-sm); }
.co-gs { --co: var(--co-gs); }
.co-ex { --co: var(--co-ex); }
.co-ss { --co: var(--co-ss); }

.co-list { white-space: nowrap; }
.co-list .co + .co { margin-left: 4px; }

.panel-msg {
  --tone: var(--ink-soft);
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--tone) 26%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--tone) 8%, var(--surface));
  color: color-mix(in srgb, var(--tone) 72%, var(--ink));
  font-size: 14px;
  line-height: 1.5;
}

.panel-msg > div + div { margin-top: 2px; }
.panel-msg-ok   { --tone: var(--ok); }
.panel-msg-err  { --tone: var(--error); }
.panel-msg-warn { --tone: var(--warn); }

/* ============================================================
   Merchanci: wyszukiwarka
   ============================================================ */

.search-box {
  position: relative;
  z-index: 5;
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 15px;
  z-index: 1;
  width: 18px;
  height: 18px;
  color: var(--ink-faint);
  pointer-events: none;
}

#nip {
  width: 100%;
  height: 48px;
  padding: 0 46px 0 43px;
  border-radius: var(--radius);
  font-size: 15px;
  box-shadow: var(--shadow-sm);
}

#nip:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent), var(--shadow-sm);
}

.search-kbd {
  position: absolute;
  right: 14px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  pointer-events: none;
  transition: opacity 150ms ease;
}

#nip:focus ~ .search-kbd,
#nip:not(:placeholder-shown) ~ .search-kbd { opacity: 0; }

.clear-btn {
  position: absolute;
  right: 9px;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 140ms var(--ease-out);
}

.clear-btn svg { width: 14px; height: 14px; }
.clear-btn:active { transform: scale(0.9); }

/* Podpowiedzi otwierają się przy pisaniu - bez animacji (akcja z klawiatury) */
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.suggestion-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.suggestion-item.highlighted { background: var(--accent-soft); }

.suggestion-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 550;
}

.suggestion-nip {
  flex: none;
  color: var(--ink-soft);
  font-size: 12.5px;
}

.suggestion-zagr {
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: 1px;
}

/* Komunikat = dymek na dole ekranu. Przejścia (nie keyframes), więc kolejny
   komunikat w trakcie animacji płynnie ją przejmuje. Wejście 220 ms,
   wyjście 150 ms - system odpowiada szybciej, niż się pojawia. */
.message {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(540px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: var(--radius-full);
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms var(--ease-out);
}

.message.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
  cursor: pointer;
  transition-duration: 220ms;
}

.message.show::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4fc68b;
}

.message.show.error::before { background: #ff7b72; }

/* ============================================================
   Merchanci: karta firmy
   ============================================================ */

table.merchant,
table.merchant > tbody { display: block; }

table.merchant.fade-in { animation: rise-in 220ms var(--ease-out); }

table.merchant tr { display: block; }

.m-head > tr {
  background: var(--surface);
  border-radius: var(--radius-xl);
}

table.merchant .company-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 16px;
  padding: 20px 22px;
}

.company-name-block { display: flex; flex-direction: column; min-width: 0; }

#nazwa {
  font-size: 21px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.018em;
  overflow-wrap: anywhere;
}

.company-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.nip-under-name { color: var(--ink-soft); font-size: 13.5px; }

.zagr-badge,
.status-badge,
.koniec-badge,
.email-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.zagr-badge { background: var(--accent-soft); color: var(--accent-strong); }

.status-badge {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-soft);
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.status-badge.is-ended {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  box-shadow: none;
  color: var(--error);
}

.status-badge.is-ended::before { background: currentColor; }

/* data_zakonczenia_wspolpracy: przyszła = ostrzeżenie, minęła = jak status zakończony */
.koniec-badge { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.koniec-badge.is-ended { background: color-mix(in srgb, var(--error) 10%, transparent); color: var(--error); }
.email-badge {
  border: 0;
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
  font-family: inherit;
  cursor: pointer;
}

.email-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.koniec-badge.is-empty { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-faint); font-weight: 550; }

.whitelist-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--ok) 28%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--ok) 10%, var(--surface));
  color: var(--ok);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 150ms ease;
}

.whitelist-link svg { width: 15px; height: 15px; }
.whitelist-link:active { transform: scale(0.97); }
.whitelist-link.loading { opacity: 0.75; }
.whitelist-link.loading .btn-spinner-sm { display: inline-block; }

.company-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.clickup-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease;
}

.clickup-link svg { width: 13px; height: 13px; }

.whitelist-result {
  grid-column: 1 / -1;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13.5px;
  animation: rise-in 200ms var(--ease-out);
}

.whitelist-result.wl-ok   { border-color: color-mix(in srgb, var(--ok) 32%, var(--line)); }
.whitelist-result.wl-warn { border-color: color-mix(in srgb, var(--error) 32%, var(--line)); }

.wl-header { font-weight: 650; }
.whitelist-result.wl-ok .wl-header   { color: var(--ok); }
.whitelist-result.wl-warn .wl-header { color: var(--error); }

.wl-accounts {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wl-accounts .wl-match    { color: var(--ok); }
.wl-accounts .wl-mismatch { color: var(--error); }

/* --- sekcje karty: tytuł nad grupą, wiersze jako jedna ramka --- */

.m-section > tr.section-row td {
  display: block;
  padding: 26px 4px 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.m-section > tr:not(.section-row) {
  display: grid;
  grid-template-columns: minmax(170px, 37%) minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top-width: 0;
}

.m-section > tr.section-row + tr {
  border-top-width: 1px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.m-section > tr:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.m-section > tr.row-zagr.is-hidden { display: none; }

table.merchant th {
  padding: 14px 18px;
  text-align: left;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
}

table.merchant .hint {
  display: block;
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.4;
}

table.merchant .m-section td {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 10px 4px;
}

.val {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.val[data-field^="nr_konta"],
.val[data-field="swift"] { letter-spacing: 0.01em; }

button.edit,
button.cancel {
  flex: none;
  height: 30px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}

button.edit { color: var(--accent); }
button.cancel { color: var(--ink-soft); }
button.edit:active:not(:disabled), button.cancel:active { transform: scale(0.96); }
button.edit:disabled { opacity: 0.55; cursor: default; }

/* w trybie edycji "Edytuj" zmienia się w "Zapisz" - wtedy pełny przycisk */
.edit-input ~ button.edit {
  background: var(--accent);
  color: var(--accent-ink);
}

.edit-input { flex: 1; min-width: 0; height: 34px; }

.edit-input.invalid { border-color: var(--error); }
.edit-input.invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 18%, transparent); }

table.merchant .m-section td.email-default-cell {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.email-select { min-width: 230px; height: 34px; }

.email-effective { color: var(--ink-soft); font-size: 12.5px; overflow-wrap: anywhere; }
.email-effective.warn { color: var(--error); font-weight: 600; }
#zagr-status { font-size: 13.5px; }
#zagr-status.ok { color: var(--ok); font-weight: 600; }

.audit-line { color: var(--ink-faint); font-size: 12.5px; }
.audit-line.audit-error { color: var(--error); }

#audit-line { margin: 14px 4px 0; text-align: right; }

/* ---------- Przełącznik ---------- */

.switch {
  position: relative;
  flex: none;
  display: inline-block;
  width: 40px;
  height: 24px;
}

.switch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--line-strong);
  transition: background-color 200ms ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .28), 0 0 0 .5px rgb(0 0 0 / .06);
  transform-origin: left center;
  transition: transform 220ms var(--ease-out);
}

.switch input:checked ~ .switch-track { background: var(--accent); }
.switch-danger input:checked ~ .switch-track { background: var(--error); }

.switch input:checked ~ .switch-track .switch-thumb {
  transform: translateX(16px);
  transform-origin: right center;
}

/* przytrzymanie - kciuk lekko się rozciąga, jak w iOS */
.switch input:active ~ .switch-track .switch-thumb { transform: scaleX(1.14); }
.switch input:checked:active ~ .switch-track .switch-thumb { transform: translateX(16px) scaleX(1.14); }

.switch input:focus-visible ~ .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled { cursor: default; }
.switch input:disabled ~ .switch-track { opacity: 0.55; }

/* ---------- Menu (eksport) ---------- */

.menu { position: relative; flex: none; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }

.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 260px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  /* wyrasta z przycisku (prawy górny róg), nie ze środka */
  transform-origin: top right;
}

.menu[open] .menu-panel { animation: pop-in 160ms var(--ease-out); }

.menu-panel a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}

.menu-panel a:focus-visible { outline-offset: -2px; }

/* ============================================================
   Panele: Start (bento)
   Merchanci = duży ciemny kafel z wyszukiwarką, reszta paneli
   w siatce 4 kolumn. Siatka: patrz panels.wsm_index().
   ============================================================ */

.bento {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.bento-wide { grid-column: span 2; }
.bento-span3 { grid-column: span 3; }
.bento-full { grid-column: 1 / -1; }
.bento-hero { grid-column: span 2; grid-row: span 2; }

.bento-hero {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 340px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--hero);
  color: var(--hero-ink);
}

.bento-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bento-hero-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
}

.bento-hero-icon svg { width: 24px; height: 24px; }

.bento-hero-open {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  background: rgb(255 255 255 / .1);
  color: var(--hero-ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: background-color 150ms ease;
}

.bento-hero h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.bento-hero p { margin-top: 6px; color: var(--hero-soft); font-size: 15px; line-height: 1.5; }

.bento-search { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.bento-search label { color: var(--hero-soft); font-size: 13px; font-weight: 600; }

.bento-search-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 6px 0 16px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-faint);
}

.bento-search-field > svg { flex: none; width: 18px; height: 18px; }

.bento-search-field input[type=text] {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
}

.bento-search-field input[type=text]:focus { box-shadow: none; }
.bento-search-field:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.bento-search-field .btn { height: 44px; }
.bento-search-field .suggestions { z-index: 30; color: var(--ink); }

.bento-export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  color: var(--hero-soft);
  font-size: 13px;
}

.bento-export span { margin-right: 4px; }

.bento-chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--hero-line);
  border-radius: var(--radius-full);
  color: var(--hero-ink);
  text-decoration: none;
  font-weight: 600;
  transition: background-color 150ms ease;
}

.bento-tile {
  --tone: var(--accent);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 162px;
  padding: 22px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease;
}

.bento-tile:active { transform: scale(0.985); }

.bento-tile-icon {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 13%, var(--surface));
  color: var(--tone);
}

.bento-tile-icon svg { width: 21px; height: 21px; }

.bento-tile h3 { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.bento-tile p { margin-top: 4px; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }

/* szeroki kafel: ikona obok tekstu */
.bento-tile.bento-wide { flex-direction: row; align-items: center; gap: 18px; min-height: 120px; }
.bento-tile.bento-wide .bento-tile-icon { width: 52px; height: 52px; border-radius: 15px; }
.bento-tile.bento-wide .bento-tile-icon svg { width: 24px; height: 24px; }

.bento-tile-admin {
  min-height: 120px;
  border-style: dashed;
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.bento-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.bento-tag {
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.bento-companies {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
  padding: 20px 22px;
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.bento-companies h3 { color: var(--ink-soft); font-size: 13px; font-weight: 700; }

.bento-co { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }

.bento-co b {
  width: 32px;
  padding: 3px 0;
  border-radius: 6px;
  background: var(--co);
  color: var(--surface);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.tone-merchanci  { --tone: var(--accent); }
.tone-kompensaty { --tone: var(--co-gs); }
.tone-rk         { --tone: var(--co-ex); }
.tone-wz         { --tone: var(--error); }
.tone-vies       { --tone: light-dark(#2b49c2, #93a8ff); }
.tone-narzedzia  { --tone: var(--warn); }
.tone-potwierdzenia { --tone: var(--ok); }
.tone-logi       { --tone: var(--ink-soft); }
.tone-ko         { --tone: var(--co-sm); }
.tone-rejestr    { --tone: light-dark(#0e7c86, #6fd6de); }

/* ============================================================
   Panele: nagłówek (ciemna karta jak "Merchanci" na Starcie)
   Ikona + tytuł + licznik, pod spodem filtry panelu (shell(tools=...)).
   ============================================================ */

.panel-hero {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px 26px;
  border-radius: var(--radius-xl);
  background: var(--hero);
  color: var(--hero-ink);
}

.panel-hero-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.panel-hero-icon {
  flex: none;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--accent);
  color: var(--accent-ink);
}

.panel-hero-icon svg { width: 25px; height: 25px; }

.panel-hero-text { flex: 1 1 280px; min-width: 0; }
.panel-hero .page-title { font-size: 30px; color: var(--hero-ink); }
.panel-hero .page-subtitle { margin-top: 4px; color: var(--hero-soft); }

.panel-hero-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  line-height: 1.1;
}

.panel-hero-stat strong {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.panel-hero-stat span { color: var(--hero-soft); font-size: 13px; font-weight: 600; }

/* filtry w nagłówku: większe pola, bez ramek (białe na ciemnym) */
.panel-hero-tools .toolbar,
.panel-hero-tools { color: var(--ink); }
.panel-hero-tools .rk-toolbar,
.panel-hero-tools .search-box { margin-bottom: 0; }

.panel-hero-tools .toolbar input[type=text] { flex: 1 1 320px; max-width: none; }

.panel-hero input[type=text],
.panel-hero select,
.panel-hero .rk-daterange { height: 44px; border-color: transparent; }

.panel-hero .rk-toolbar input[type=text].rk-date { height: 32px; }
.panel-hero .btn { height: 44px; }
.panel-hero .btn-sm { height: 36px; }

.panel-hero .btn-neutral {
  background: rgb(255 255 255 / .1);
  border-color: var(--hero-line);
  color: var(--hero-ink);
}

.panel-hero #nip { box-shadow: none; }

/* przełącznik w nagłówku (Logi: korekty / kompensaty) */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-full);
  background: rgb(255 255 255 / .1);
}

.segmented a {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-full);
  color: var(--hero-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: background-color 150ms ease, color 150ms ease;
}

.segmented a.active { background: var(--surface); color: var(--ink); }

/* ============================================================
   Panele: pasek filtrów, karty z tabelami, stronicowanie
   ============================================================ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar > form { flex: 1 1 auto; }
.toolbar input[type=text] { flex: 1 1 260px; min-width: 240px; max-width: 480px; }

.panel-summary {
  margin: 0 6px 10px;
  color: var(--ink-soft);
  font-size: 13px;
}

.panel-summary strong { color: var(--ink); font-weight: 600; }

.panel-card {
  margin-bottom: 16px;
  overflow-x: auto;
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.panel-card table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.panel-card th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.panel-card td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: top;
}

.panel-card th:first-child, .panel-card td:first-child { padding-left: 22px; }
.panel-card th:last-child, .panel-card td:last-child { padding-right: 22px; }

.panel-card tbody tr:last-child > td { border-bottom: 0; }

/* najechanie na wiersz: bez przejścia - zdarza się kilkadziesiąt razy na minutę */
.panel-card tbody tr:hover > td { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.docs-list { color: var(--ink-soft); font-size: 13px; }
.docs-list div { padding: 1px 0; }

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}

.pager a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  transition: transform 140ms var(--ease-out), background-color 150ms ease;
}

.pager a:active { transform: scale(0.97); }

.pager a.active {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
  pointer-events: none;
}

.pager a.disabled { opacity: 0.4; pointer-events: none; }

/* ---------- details/summary (rozwijane sekcje) ---------- */

.page summary { cursor: pointer; list-style: none; }
.page summary::-webkit-details-marker { display: none; }

.page details:not(.menu) > summary::before {
  content: "";
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.6;
  transition: transform 200ms var(--ease-out);
}

.page details[open]:not(.menu) > summary::before { transform: rotate(90deg); }

/* ---------- Pola importu ---------- */

.upload-box {
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.nz-drop { border-style: dashed; border-color: var(--line-strong); }

.upload-box h3 { margin-bottom: 8px; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }

details.upload-box { border-style: solid; border-color: transparent; }
details.upload-box > summary h3 { margin: 0; }

.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.upload-form input[type=text] { min-width: 220px; }

.rk-import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.rk-import-grid .upload-box { margin-bottom: 0; display: flex; flex-direction: column; }
.rk-import-grid .upload-box .upload-form { margin-top: auto; }

.rk-hint {
  max-width: 76ch;
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.rk-hint strong { color: var(--ink); font-weight: 600; }

.nz-drop { transition: border-color 150ms ease, background-color 150ms ease; }
.nz-drop.nz-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.nz-result .panel-msg { margin: 14px 0 0; }
.nz-result details { margin-top: 8px; color: var(--ink-soft); font-size: 13px; }

.nz-result .nz-zmiany {
  max-height: 260px;
  overflow: auto;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
}

.nz-section {
  margin: 6px 0 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nz-ver {
  margin-left: 6px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.nz-install { margin: 0 0 16px; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.nz-install summary { color: var(--ink); font-weight: 600; cursor: pointer; }
.nz-install ol { margin: 8px 0 6px; padding-left: 20px; }
.nz-install li { margin-bottom: 4px; }
.nz-install p { margin: 0; }
.nz-install strong { color: var(--ink); font-weight: 600; }
.nz-install code { font-family: var(--mono); font-size: 12px; }

/* Kreator faktury z IR / Mall */
.kreator-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface-2);
}
.kreator-tabs button {
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.kreator-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.kreator-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .kreator-tabs button:not(.active):hover { color: var(--ink); } }
.kir[hidden] { display: none; }
.kir { border-style: dashed; border-color: var(--line-strong); transition: border-color 150ms ease, background-color 150ms ease; }
.kir.nz-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.kir code { font-family: var(--mono); font-size: 12px; }
.kir-info .panel-msg { margin: 14px 0 0; }
.kir-import-uwaga { margin: 10px 0 14px; font-size: 13px; line-height: 1.5; }
.kir-form { margin-top: 18px; }
.kir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px 14px;
  margin-bottom: 12px;
}
.kir-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}
.kir-grid label > input, .kir-grid label > select { width: 100%; min-width: 0; }
.kir-grid small { color: var(--ink-faint); font-size: 11px; font-weight: 500; }
.kir-grid .kir-wide { grid-column: span 2; }
.kir-grid .kir-full { grid-column: 1 / -1; }
.kir-grid label > textarea { width: 100%; min-width: 0; resize: vertical; font: inherit; font-size: 13px; }
@media (max-width: 520px) { .kir-grid .kir-wide { grid-column: auto; } }
.kir-zrodlo:empty, .kir-podglad:empty { display: none; }
.kir-zrodlo, .kir-podglad { margin-bottom: 8px; }

/* ============================================================
   Kompensaty
   ============================================================ */

.kompensata-row { cursor: pointer; }

.row-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.row-toggle-btn:active { transform: scale(0.97); }

.row-toggle-btn.open {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.row-toggle-btn .chevron { transition: transform 200ms var(--ease-out); }
.row-toggle-btn.open .chevron { transform: rotate(180deg); }

.panel-card tr.kompensata-detail-row > td {
  padding: 0 !important;
  background: var(--surface-2) !important;
}

.kompensata-detail {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
  padding: 18px 20px 20px;
  animation: rise-in 200ms var(--ease-out);
}

.detail-col h4 { margin-bottom: 10px; color: var(--ink-soft); font-size: 13px; font-weight: 600; }

.docs-list-full {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 6px;
  font-size: 13.5px;
}

.docs-list-full div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.docs-list-full div:last-child { border-bottom: 0; }
.docs-list-full .pozycje-grupa { padding: 0 0 10px; border-bottom: 0; }
.docs-list-full .pozycje-grupa + .pozycje-grupa { padding-top: 6px; }
.docs-list-full .pozycje-grupa h5 { margin-bottom: 2px; color: var(--ink-soft); font-size: 12.5px; font-weight: 600; }

.kompensata-edit-form { display: flex; flex-direction: column; }

.kompensata-edit-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 550;
}

.kompensata-edit-form textarea { min-height: 72px; }

.detail-form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.doc-cell { text-align: center; white-space: nowrap; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 0 2px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}

.icon-btn:active { transform: scale(0.94); }

/* ---------- Modal z podglądem dokumentu ---------- */

body.modal-open { overflow: hidden; }

.doc-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.doc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(8 12 10 / .55);
  backdrop-filter: blur(2px);
  animation: fade-in 200ms ease;
}

/* modal nie ma wyzwalacza "w przestrzeni" - rośnie ze środka */
.doc-modal-window {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  height: min(90vh, 100%);
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: modal-in 240ms var(--ease-out);
}

.doc-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.doc-modal-actions { display: flex; flex-shrink: 0; gap: 8px; }

.doc-modal-window iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: light-dark(#80867f, #2a302d);
}

/* ============================================================
   Rozliczenie korekt
   ============================================================ */

.rk-imports-log {
  margin-bottom: 18px;
  padding: 12px 18px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
}

.rk-imports-log summary { color: var(--ink); font-weight: 600; }
.rk-imports-log div { margin-top: 6px; }

.rk-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.rk-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 140ms var(--ease-out);
}

.rk-tile:active { transform: scale(0.985); }
.rk-tile .badge { align-self: flex-start; margin-bottom: 8px; }

.rk-tile strong {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

/* sumy podkreślone podwójnie - jak w księdze */
.rk-tile small,
.rk-spolka-box strong,
.rk-aging-tile strong {
  align-self: flex-start;
  text-decoration: underline double color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.rk-tile small { margin-top: 4px; color: var(--ink-soft); font-size: 13px; }

.rk-tile-active,
.rk-spolka-active,
.rk-aging-active {
  border-color: var(--accent) !important;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.rk-tile.rk-tile-active {
  border-color: transparent !important;
  box-shadow: none;
  background: var(--hero);
  color: var(--hero-ink);
}

.rk-tile.rk-tile-active small { color: var(--hero-soft); }
.rk-tile.rk-tile-active .badge { background: rgb(255 255 255 / .14); color: var(--hero-ink); }

.rk-top {
  margin-bottom: 16px;
  padding: 16px 22px;
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.rk-top > summary { font-size: 14px; font-weight: 600; }
.rk-top[open] > summary { margin-bottom: 4px; }

.rk-sub-head { margin-top: 16px; color: var(--ink-soft); font-size: 13px; font-weight: 600; }

.rk-aging,
.rk-spolki {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.rk-aging-tile,
.rk-spolka-box {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 170px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 150ms ease, transform 140ms var(--ease-out);
}

.rk-aging-tile:active, a.rk-spolka-box:active { transform: scale(0.985); }

.rk-aging-tile .badge { align-self: flex-start; margin-bottom: 4px; }
.rk-spolka-name { margin-bottom: 4px; }
.rk-aging-tile strong, .rk-spolka-box strong { font-size: 16px; font-weight: 650; }
.rk-aging-tile small, .rk-spolka-box small { color: var(--ink-soft); font-size: 12.5px; }

.rk-top-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.rk-top-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rk-top-form label { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13px; }
.rk-top-form select { height: 30px; font-size: 13px; }

.rk-top-wrap { overflow-x: auto; margin-top: 12px; }

.rk-top-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.rk-top-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.rk-top-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.rk-top-table tbody tr:last-child td { border-bottom: 0; }
.rk-top-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }

/* ---------- Filtry ---------- */

.rk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.rk-filters { display: flex; flex: 1 1 560px; flex-direction: column; gap: 10px; }
.rk-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rk-toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.rk-search { flex: 0 1 380px; min-width: 240px; }

.rk-daterange {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.rk-daterange-label { color: var(--ink-soft); font-size: 12.5px; white-space: nowrap; }
.rk-daterange-sep { color: var(--ink-faint); }

.rk-toolbar input[type=text].rk-date {
  width: 100px;
  height: 28px;
  padding: 0 8px;
  border-color: transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}

.rk-toolbar input[type=text].rk-date:focus { border-color: var(--accent); background: var(--surface); }

.rk-toolbar input[type=text].rk-date-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 16%, transparent);
}

.rk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 5px 0 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
}

.rk-chip a {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  line-height: 1;
  transition: background-color 150ms ease, color 150ms ease;
}

/* ---------- Pasek akcji na zaznaczonych ----------
   Przykleja się pod paskiem górnym, więc przy przewijaniu długiej tabeli
   akcje są zawsze pod ręką. */

.rk-bulkbar {
  position: sticky;
  top: calc(var(--appbar-h) + 10px);
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 12px;
  padding: 10px 12px 10px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 13.5px;
  animation: slide-in 200ms var(--ease-out);
}

.rk-bulkbar input[type=text],
.rk-bulkbar select { height: 32px; font-size: 13px; }


.rk-bulk-msg { color: var(--ok); font-size: 13px; }
.rk-bulk-msg-err { color: var(--error); }

.rk-selected-sum { color: var(--ink-soft); }
.rk-selected-sum strong { color: var(--ink); }

.rk-scope-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.rk-scope-toggle input[type=checkbox] { width: 15px; height: 15px; }

.rk-scope-toggle.rk-scope-on {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: var(--accent-soft);
  color: var(--ink);
}

/* ---------- Tabela korekt ---------- */

.panel-card .rk-check-cell {
  width: 40px;
  padding-right: 0;
  text-align: center;
}

.rk-table td { vertical-align: middle; }
.rk-table td:nth-child(2), .rk-table td:nth-child(3) { white-space: nowrap; }
.rk-table td:nth-child(5) { min-width: 170px; }

.rk-table tbody tr.rk-row-locked > td { background: color-mix(in srgb, var(--ink-soft) 6%, transparent); }

.rk-row-locked .rk-check-cell input[type=checkbox] { opacity: 0.45; cursor: not-allowed; }

.rk-lock { margin-left: 4px; font-size: 12px; opacity: 0.6; cursor: help; }

.rk-note-cell { position: relative; min-width: 190px; }

.rk-note {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  overflow: hidden;
  border-color: transparent;
  border-radius: 7px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.35;
}

.rk-note:focus { overflow: auto; background: var(--surface); }

.rk-row-locked .rk-note {
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  cursor: not-allowed;
}

.rk-note-state {
  position: absolute;
  right: 18px;
  bottom: 6px;
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
}

/* ============================================================
   Logowanie / zmiana hasła
   ============================================================ */

.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth { width: 100%; max-width: 380px; }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.auth-card {
  padding: 30px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.auth-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.018em; }
.auth-hint { margin: 6px 0 22px; color: var(--ink-soft); font-size: 14px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 550;
}

.field input { width: 100%; height: 44px; }
.auth-card .btn-block { margin-top: 8px; }

/* ============================================================
   Strony błędów (403 / 404 / 500)
   404: faktura ucieka z wydruku, zostaje po niej obrys
   ============================================================ */

.err-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--appbar-h));
  padding: 24px;
}

.err-page-solo { min-height: 100vh; }

.err-card {
  width: 100%;
  max-width: 440px;
  padding: 30px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.err-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.022em; line-height: 1.15; }
.err-card p { margin-top: 8px; color: var(--ink-soft); }
.err-card .btn-block { margin-top: 24px; }

.err-path {
  overflow-wrap: anywhere;
  color: var(--ink-faint) !important;
  font-size: 13px;
}

.err-scene {
  position: relative;
  height: 176px;
  margin-bottom: 26px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.err-slot,
.err-paper {
  position: absolute;
  top: 26px;
  left: 28px;
  width: 96px;
  height: 124px;
  border-radius: 8px;
}

.err-slot {
  display: grid;
  place-items: center;
  border: 2px dashed var(--line-strong);
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 650;
}

.err-paper {
  left: calc(100% - 70px);
  rotate: 11deg;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 13px 11px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.err-paper strong {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}

.err-paper span {
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--line-strong);
}

.err-paper span.short { width: 60%; }
.err-paper span.total { margin-top: auto; width: 70%; align-self: flex-end; background: var(--accent); }

.err-trail {
  position: absolute;
  top: 62px;
  right: 86px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 11px;
}

.err-trail span {
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--accent);
  opacity: 0.35;
  transform-origin: right center;
}

.err-trail span:nth-child(1) { width: 34px; }
.err-trail span:nth-child(2) { width: 54px; }
.err-trail span:nth-child(3) { width: 24px; }

@keyframes err-run {
  from { left: 28px; rotate: 0deg; }
  45%  { rotate: -4deg; }
}

@keyframes err-trail-in {
  from { opacity: 0; transform: scaleX(0.2); }
}

@media (prefers-reduced-motion: no-preference) {
  .err-paper { animation: err-run 750ms var(--ease-out) 350ms both; }
  .err-trail span { animation: err-trail-in 320ms var(--ease-out) 850ms both; }
  .err-trail span:nth-child(2) { animation-delay: 900ms; }
  .err-trail span:nth-child(3) { animation-delay: 950ms; }
}

/* ============================================================
   Animacje
   ============================================================ */

@keyframes fade-in  { from { opacity: 0; } }
@keyframes rise-in  { from { opacity: 0; transform: translateY(6px); } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes pop-in   { from { opacity: 0; transform: scale(0.96) translateY(-2px); } }
@keyframes modal-in { from { opacity: 0; transform: scale(0.97) translateY(8px); } }

/* Przejście między panelami: treść podmienia się od razu (nawigacja
   kilkadziesiąt razy dziennie), animuje się tylko podkreślenie zakładki. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

::view-transition-old(root),
::view-transition-new(root) { animation: none; }

::view-transition-group(nav-ind) {
  animation-duration: 240ms;
  animation-timing-function: var(--ease-out);
}

/* ============================================================
   Najechanie kursorem - tylko na urządzeniach z myszą
   (na dotyku :hover "przykleja się" po stuknięciu)
   ============================================================ */

@media (hover: hover) and (pointer: fine) {
  .topnav-links > a:not(.active):hover { color: var(--ink); background: var(--surface-2); }
  .nav-group > summary:not(.active):hover { color: var(--ink); background: var(--surface-2); }
  .theme-switch button:hover { color: var(--ink); }
  .logout:hover { background: var(--accent-soft); color: var(--accent-strong); }

  .btn-accent:hover, .btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 88%, var(--ink));
  }
  .btn-neutral:hover { background: var(--surface-2); border-color: var(--ink-faint); }
  .btn-ok:hover { background: color-mix(in srgb, var(--ok) 17%, var(--surface)); }
  .btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--error) 15%, var(--surface)); }

  input[type=file]::file-selector-button:hover { background: var(--surface-2); }
  input[type=text]:hover:not(:focus), input[type=password]:hover:not(:focus),
  select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--ink-faint); }

  .clear-btn:hover { background: var(--surface-2); color: var(--ink); }
  .suggestion-item:hover { background: var(--accent-soft); }

  button.edit:hover:not(:disabled) { background: var(--accent-soft); }
  .edit-input ~ button.edit:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
  button.cancel:hover { background: var(--surface-2); color: var(--ink); }
  .whitelist-link:hover { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); }
  .clickup-link:hover { color: var(--accent); }

  .menu-panel a:hover { background: var(--surface-2); }

  .bento-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
  .bento-hero-open:hover, .bento-chip:hover { background: rgb(255 255 255 / .18); color: var(--hero-ink); }
  .panel-hero .btn-neutral:hover { background: rgb(255 255 255 / .18); border-color: var(--hero-line); }
  .segmented a:not(.active):hover { color: var(--hero-ink); }
  .rk-tile:hover { transform: translateY(-2px); }
  .rk-tile:hover, .rk-aging-tile:hover, a.rk-spolka-box:hover { border-color: var(--line-strong); }
  .pager a:not(.active):hover { box-shadow: var(--shadow-sm); }

  .pager a:hover { background: var(--surface-2); }
  .row-toggle-btn:hover:not(.open) { color: var(--ink); border-color: var(--ink-faint); }
  .icon-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
  .rk-chip a:hover { background: color-mix(in srgb, var(--error) 16%, transparent); color: var(--error); }
  .rk-scope-toggle:hover { border-color: var(--ink-faint); }
  .rk-note:hover:not(:focus):not([readonly]) { border-color: var(--line-strong); }
}

/* ============================================================
   Dostępność
   ============================================================ */

/* Mniej ruchu = bez przesunięć i skalowania; zostają zmiany przezroczystości
   i kolorów, które pomagają zrozumieć, co się zmieniło. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-property: opacity, color, background-color, border-color, box-shadow !important;
  }
  table.merchant.fade-in,
  .whitelist-result,
  .kompensata-detail,
  .rk-bulkbar,
  .menu[open] .menu-panel,
  .doc-modal-window { animation-name: fade-in !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .appbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .doc-modal-backdrop { backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root {
    --line: light-dark(#a5a4b4, #5a586c);
    --line-strong: light-dark(#73728a, #8a889c);
    --ink-soft: var(--ink);
    --ink-faint: light-dark(#4b4a5c, #c3c2d2);
  }
  .panel-card, .bento-tile, .bento-companies, .rk-tile, .rk-top,
  .m-head > tr, .topnav-links, .topnav-user, .theme-switch { outline: 1px solid var(--line); }
}

/* ============================================================
   Mniejsze ekrany
   ============================================================ */

@media (max-width: 1320px) {
  .brand-name { display: none; }
}

@media (max-width: 1180px) {
  .user-text { display: none; }
}

@media (max-width: 960px) {
  .appbar-inner { gap: 12px; }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento-span3 { grid-column: 1 / -1; }
  .panel-card table { min-width: 780px; }
}

@media (max-width: 780px) {
  .kompensata-detail { grid-template-columns: 1fr; }
  .rk-toolbar { flex-direction: column; align-items: stretch; }
  .rk-search { flex: 1 1 auto; }
  .rk-daterange { justify-content: space-between; }
  .rk-bulkbar { position: static; }
}

@media (max-width: 640px) {
  .appbar-inner { padding: 0 14px; }
  .theme-switch { padding: 3px; }
  .theme-switch button { width: 26px; height: 26px; }
  .festive-toggle { width: 32px; height: 32px; }
  .topnav-user { padding: 3px; }
  .avatar, .logout { width: 30px; height: 30px; }
  .bento { grid-template-columns: minmax(0, 1fr); }
  .bento-wide, .bento-hero { grid-column: auto; grid-row: auto; }
  .bento-hero { padding: 22px; }
  .panel-hero { padding: 20px; }
  .panel-hero .page-title { font-size: 26px; }
  .panel-hero-stat { align-items: flex-start; }
  .page { padding: 22px 14px 56px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .page-title { font-size: 27px; }

  .search-box { flex-direction: column; }
  .btn-primary { width: 100%; }
  .search-kbd { display: none; }

  table.merchant .company-cell { grid-template-columns: 1fr; padding: 18px; }
  .company-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .m-section > tr:not(.section-row) { grid-template-columns: 1fr; }
  table.merchant th { padding: 12px 16px 2px; }
  table.merchant .m-section td { padding: 6px 12px 12px 16px; }
  .email-select { min-width: 0; width: 100%; }

  .rk-import-grid { grid-template-columns: 1fr; }
  .doc-modal { padding: 0; }
  .doc-modal-window { height: 100%; border-radius: 0; }
}

/* ---------- Załącznik do kompensaty ---------- */

.zal-block { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.zal-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  color: var(--ink-soft); font-size: 13px; text-align: center; cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.zal-drop small { color: var(--ink-faint); font-size: 12px; }
.zal-drop:hover, .zal-block.zal-over .zal-drop { border-color: var(--accent); background: var(--accent-soft); }
.zal-block.zal-over .zal-file { outline: 1.5px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius); }
.zal-block.zal-busy { opacity: .6; pointer-events: none; }
.zal-file { display: flex; flex-direction: column; gap: 4px; }
.zal-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.zal-actions label.btn { cursor: pointer; }
.zal-msg:empty { display: none; }
.zal-msg { display: block; margin-top: 6px; }

/* ============================================================
   Logi: aktywność i historia zmian (logi.py, tylko admin)
   ============================================================ */

.log-table td { vertical-align: top; }
.log-ts { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.log-user { font-weight: 700; color: var(--ink); text-decoration: none; }
.log-user:hover { text-decoration: underline; }
.log-label { color: var(--ink-faint); font-size: 12.5px; margin-top: 2px; overflow-wrap: anywhere; }
.log-label a { color: inherit; }
.log-err { color: var(--error); }
.log-empty { text-align: center; color: var(--ink-soft); padding: 34px !important; }
.log-row-err > td:first-child { box-shadow: inset 3px 0 0 var(--error); }

.log-val {
  display: inline-block;
  max-width: 340px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
}
.log-old .log-val {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: color-mix(in srgb, var(--error) 70%, var(--ink));
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--error) 45%, transparent);
}
.log-new .log-val {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: color-mix(in srgb, var(--ok) 70%, var(--ink));
}

.log-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.log-details[open] { min-width: min(560px, 70vw); }
.log-details[open] summary { margin-bottom: 8px; }

.log-mini { width: 100%; font-size: 13px; margin-bottom: 8px; }
.log-mini th, .log-mini td { padding: 6px 8px !important; }

.log-json {
  margin: 0 0 6px;
  padding: 10px 12px;
  max-height: 320px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--hero-ink, inherit);
  font-size: 14px;
  white-space: nowrap;
}

#audit-history { margin: 4px 4px 0; text-align: right; }
#audit-history a { color: var(--accent); font-weight: 600; }

/* Szukaj/Enter przy kilku pasujących firmach - pole "odbija" zamiast akceptować frazę */
@keyframes search-bounce {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}
.search-input-wrap.bounce {
  animation: search-bounce 0.36s cubic-bezier(.36,.07,.19,.97);
}
@media (prefers-reduced-motion: reduce) {
  .search-input-wrap.bounce { animation: none; }
}


/* ============================================================
   Wezwania korekt (panel_wz.py)
   ============================================================ */

.wz-poz-wrap { max-height: 320px; overflow: auto; }
.wz-poz { width: 100%; border-collapse: collapse; font-size: 13px; }
.wz-poz th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-soft); font-size: 12px; font-weight: 600; text-align: left; padding: 6px 8px; }
.wz-poz td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.wz-poz td small { color: var(--ink-soft); }
.wz-poz tr:last-child td { border-bottom: 0; }

.wz-meta { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13.5px; }
.wz-meta div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.wz-meta span { color: var(--ink-soft); font-size: 12.5px; }
.wz-meta a { word-break: break-all; }


/* ============================================================
   Narzędzia -> Rejestr sprzedaży BL (rejestr_bl.js)
   ============================================================ */

.rbl-serie-box { display: grid; gap: 8px; }
.rbl-serie-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.rbl-serie-bar .rbl-filtr { flex: 1 1 220px; min-width: 180px; }
.rbl-zaznacz-grupa { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.rbl-zaznacz-label { color: var(--ink-soft); margin-right: 2px; }
.rbl-info { margin-top: 14px; }
.rbl-licznik { color: var(--ink-soft); font-size: 12px; }
.rbl-serie {
  max-height: 320px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.rbl-grupa {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0 14px;
  min-width: 0;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}
.rbl-grupa legend { grid-column: 1 / -1; margin-bottom: 4px; color: var(--ink-soft); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
/* .kir-grid label ustawia kolumnę i input na 100% - lista serii musi to nadpisać */
.kir-grid label.rbl-seria {
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.kir-grid label.rbl-seria > input { width: auto; flex: none; margin: 2px 0 0; }
.kir-grid label.rbl-seria[hidden] { display: none; }
.rbl-seria-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rbl-seria-txt > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rbl-seria-txt small { overflow: hidden; color: var(--ink-faint); font-family: var(--mono); font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.rbl [hidden] { display: none !important; }  /* .btn ma własne display */
.rbl-wynik { margin-top: 14px; }
.rbl-tabele { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 10px; }
.rbl-tabele .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rbl-uwagi { margin: 6px 0 12px; color: var(--ink-soft); font-size: 13px; }
.rbl-poprawki { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.kir-grid label.rbl-check { align-self: center; }
.kir-grid label.rbl-check small { font-family: inherit; }
