/* Design system 4CONVY — tabela „Arkusz” (D-027). Wartości: blok .v-a w docs/design-system/2026-11-26_runda-3-dane.html.
   Kolory tylko przez zmienne z ds-tokeny.css. Bez animacji (ruch: ds-ruch.css).
   Szerokość kolumn zależy od kontenera `.tabela-blok` (container query), nie od okna. */

.tabela-blok { container: tabela / inline-size; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Pasek filtrów (formularz GET) ---------- */
.tabela-filtry {
  display: grid; gap: var(--sp-3); align-items: end; margin: 0;
  grid-template-columns: minmax(180px, 2fr) repeat(2, minmax(120px, 1fr)) repeat(2, minmax(130px, 1fr)) auto;
}
.tabela-filtry .pole { margin: 0; min-width: 0; }
.tabela-filtry .etykieta { font-size: var(--fs-small); }
.tabela-filtry-akcje { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
@container tabela (max-width: 759px) {
  .tabela-filtry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabela-filtry .pole-szukaj { grid-column: 1 / -1; }
  .tabela-filtry-akcje { grid-column: 1 / -1; }
}
@container tabela (max-width: 599px) {
  .tabela-filtry { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Tabela ---------- */
.tabela-opak { position: relative; max-width: 100%; overflow-x: auto; border: var(--tw-border); border-radius: var(--r-card); background: var(--lvl-1); }
.tabela-opak:focus-visible { outline-offset: 2px; }
.tabela { width: 100%; border-collapse: separate; border-spacing: 0; font: 500 var(--fs-cell)/1.35 var(--f-body); }
.tabela th, .tabela td {
  padding: 6px var(--cell-px); height: var(--row-h); text-align: left; vertical-align: middle;
  border-bottom: var(--grid-h); border-right: var(--grid-v);
}
.tabela tr > :last-child { border-right: 0; }
.tabela thead th {
  padding: 0; background: var(--th-bg); border-bottom: 1px solid var(--line-strong);
  font: 600 12px/1.2 var(--f-body); color: var(--text);
}
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela .liczba { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabela td.liczba { font-weight: 500; }
.tabela .k-zazn { width: 44px; padding: 0; text-align: center; }
.tabela .k-dzial { width: 104px; }
.tabela .k-termin { width: 108px; white-space: nowrap; }
.tabela .k-status { width: 132px; }
.tabela .k-liczba { width: 84px; }
.tabela .k-tytul { min-width: 160px; overflow-wrap: anywhere; }
.tabela .brak { color: var(--muted); }
.tabela-pod { display: none; margin-top: 2px; font: 400 12px/1.35 var(--f-body); color: var(--muted); }

/* nagłówek sortowania: link wypełnia całą komórkę, strzałka w górę/w dół */
.tabela-sort {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 36px; height: var(--row-h);
  padding: 0 var(--cell-px); color: inherit; text-decoration: none; cursor: pointer;
}
.tabela-sort:hover { background: var(--accent-soft); }
.tabela-sort:focus-visible { outline-offset: -3px; }
.tabela .liczba .tabela-sort { justify-content: flex-end; text-align: right; }
.tabela-nagl-tekst { display: flex; align-items: center; min-height: 36px; height: var(--row-h); padding: 0 var(--cell-px); }
.tabela-strzalka { width: 12px; height: 12px; flex: none; fill: currentColor; }
.tabela-strzalka path { opacity: .4; }
th[aria-sort="ascending"] .tabela-strzalka .gora, th[aria-sort="descending"] .tabela-strzalka .dol { opacity: 1; }
th[aria-sort="ascending"] .tabela-strzalka .dol, th[aria-sort="descending"] .tabela-strzalka .gora { opacity: 0; }

/* zaznaczanie: pole wyboru na całą komórkę, tło wiersza granat 10% */
.tabela .cbx { display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--row-h); margin: 0; cursor: pointer; }
.tabela thead .cbx { min-height: 36px; }
.tabela tbody tr:hover { background: var(--hover-bg); }
.tabela tbody tr.jest-zazn, .tabela tbody tr.jest-zazn:hover { background: var(--sel-bg); }
.tabela tbody tr.pusta:hover { background: transparent; }

/* pusty wynik */
.tabela .pusta td { height: auto; padding: 36px 16px; text-align: center; border: 0; }
.tabela-pusta-ikona { width: 28px; height: 28px; color: var(--muted); margin-bottom: 8px; }
.tabela-pusta-tytul { margin: 0 0 4px; font: 700 15px/1.3 var(--f-head); }
.tabela-pusta-opis { margin: 0 0 14px; font: 400 13px/1.4 var(--f-body); color: var(--muted); }

/* ---------- Pasek akcji (po zaznaczeniu; atrybut hidden przy 0) ---------- */
.pasek-akcji {
  position: sticky; bottom: 12px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 8px 8px 8px 14px; background: var(--accent); color: var(--on-accent);
  border-radius: var(--r-card); box-shadow: var(--sh-2);
}
.pasek-akcji[hidden] { display: none; }
.pasek-akcji-tekst { margin-right: auto; font: 600 14px/1.2 var(--f-body); }
.pasek-akcji .btn-s { background: var(--c-white); color: var(--text); box-shadow: none; height: 36px; }
.pasek-akcji .btn-s:hover { background: var(--c-paper); }
.pasek-akcji .btn-t { color: var(--on-accent); height: 36px; }
.pasek-akcji .btn-t:hover { background: color-mix(in srgb, var(--c-white) 14%, transparent); }
.pasek-akcji :focus-visible { outline-color: var(--on-accent); }

/* ---------- Stronicowanie ---------- */
.tabela-strony { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; font: 400 13px/1.3 var(--f-body); color: var(--muted); }
.tabela-strony-przyciski { display: flex; align-items: center; gap: 6px; }
.tabela-strony-numer {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: var(--ctl-h); padding: 0 6px; border-radius: var(--r-ctl);
  color: var(--text); font: 600 13px/1 var(--f-body); text-decoration: none; font-variant-numeric: tabular-nums;
}
.tabela-strony-numer:hover { background: var(--accent-soft); }
.tabela-strony-numer[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
.tabela-strony-numer::after { content: ""; position: absolute; left: 0; right: 0; top: calc(var(--hit-pad) * -1); bottom: calc(var(--hit-pad) * -1); }
.tabela-strony-numer-lista { display: contents; }
.tabela-strony-wielokropek { min-width: 24px; text-align: center; color: var(--muted); }
.tabela-strony-telefon { display: none; padding: 0 6px; font-weight: 500; color: var(--text); white-space: nowrap; }
.tabela-strony .btn-s { padding: 0 12px; gap: 4px; }

/* ---------- Zachowanie przy zmianie szerokości kontenera (progi 759 / 599) ---------- */
@container tabela (max-width: 759px) {
  .tabela .k-liczba { display: none; }
}
@container tabela (max-width: 599px) {
  .tabela .k-dzial, .tabela .k-termin { display: none; }
  .tabela-pod { display: block; }
  .tabela .k-zazn { width: 36px; }
  .tabela .k-tytul { min-width: 112px; }
  .tabela .k-status { width: 96px; }
  .tabela th, .tabela td { --cell-px: 6px; }
  .tabela-strony-numer-lista { display: none; }
  .tabela-strony-telefon { display: inline; }
  .tabela-strony-przyciski { gap: 4px; }
  .tabela-strony .btn-s { padding: 0 10px; }
}
