/*
 * Biblioteka komponentów WWW (R19-C, WEB_DESIGN_SYSTEM.md sekcja 8): Components/Design/**.
 * Wyłącznie tokeny z tokens.css; bez literałów kolorów (strażnik WebPage.Tests/Design).
 * Celowo bez @layer, jak shell.css: Tailwind (app.css) jest poza warstwami,
 * a reguły w warstwie przegrałyby z jego resetem. Ładowany po shell.css.
 * Klasy .tm-btn, .tm-icon-btn i .tm-avatar są wspólne z powłoką (R19-B): tutaj pełny zestaw wariantów,
 * zgodny z wartościami powłoki dla wariantów, których ona używa.
 * Wygląd: karta 16 px z miękkim cieniem, tonalne etykiety z kropką, nagłówki tabel 12 px wersalikami,
 * wiersze 64 px, jedna akcja główna wypełniona, ikony Lucide 16/18 px z kreską 2.
 */

/* ==========================================================================
 * Tony: zmienne --tone* dla każdego modyfikatora tonu
 * ======================================================================== */
[class*="--neutral"], .tm-tonal--neutral, .tm-text--neutral, .tm-dot--neutral {
  --tone: var(--tm-neutral);
  --tone-ch: var(--tm-neutral-ch);
  --tone-text: var(--tm-neutral-text);
  --tone-bg: var(--tm-neutral-tonal);
}

[class*="--primary"], .tm-tonal--primary, .tm-text--primary, .tm-dot--primary {
  --tone: var(--tm-primary);
  --tone-ch: var(--tm-primary-ch);
  --tone-text: var(--tm-primary-text);
  --tone-bg: var(--tm-primary-tonal);
}

[class*="--success"], .tm-tonal--success, .tm-text--success, .tm-dot--success {
  --tone: var(--tm-success);
  --tone-ch: var(--tm-success-ch);
  --tone-text: var(--tm-success-text);
  --tone-bg: var(--tm-success-tonal);
}

[class*="--warning"], .tm-tonal--warning, .tm-text--warning, .tm-dot--warning {
  --tone: var(--tm-warning);
  --tone-ch: var(--tm-warning-ch);
  --tone-text: var(--tm-warning-text);
  --tone-bg: var(--tm-warning-tonal);
}

[class*="--danger"], .tm-tonal--danger, .tm-text--danger, .tm-dot--danger {
  --tone: var(--tm-danger);
  --tone-ch: var(--tm-danger-ch);
  --tone-text: var(--tm-danger-text);
  --tone-bg: var(--tm-danger-tonal);
}

[class*="--info"], .tm-tonal--info, .tm-text--info, .tm-dot--info {
  --tone: var(--tm-info);
  --tone-ch: var(--tm-info-ch);
  --tone-text: var(--tm-info-text);
  --tone-bg: var(--tm-info-tonal);
}

.tm-tonal--neutral, .tm-tonal--primary, .tm-tonal--success, .tm-tonal--warning, .tm-tonal--danger, .tm-tonal--info {
  background: var(--tone-bg);
  color: var(--tone-text);
}

.tm-text--neutral, .tm-text--primary, .tm-text--success, .tm-text--warning, .tm-text--danger, .tm-text--info {
  color: var(--tone-text);
}

.tm-mono {
  font-family: var(--tm-font-mono);
  font-size: .9em;
  letter-spacing: 0;
}

/* ==========================================================================
 * Wskaźnik pracy i szkielet
 * ======================================================================== */
.tm-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  border: 2px solid rgb(var(--tm-text-ch) / .16);
  border-top-color: currentColor;
  border-radius: var(--tm-radius-pill);
  animation: tm-spin 700ms linear infinite;
}

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

@keyframes tm-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes tm-appear {
  to { opacity: 1; }
}

@keyframes tm-rise {
  from { opacity: 0; transform: translateY(-.5rem); }
  to { opacity: 1; transform: none; }
}

.tm-skel {
  position: relative;
  display: block;
  overflow: hidden;
  height: .75rem;
  border-radius: var(--tm-radius-xs);
  background: var(--tm-paper-3);
}

.tm-skel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgb(var(--tm-paper-ch) / .55), transparent);
  animation: tm-shimmer 1.4s ease-in-out infinite;
}

.tm-skel--thin { height: .5rem; }
.tm-skel--box { width: 2.5rem; height: 2.5rem; border-radius: var(--tm-radius-sm); flex-shrink: 0; }
.tm-skel--square { width: 2.25rem; height: 2.25rem; border-radius: var(--tm-radius-md); }
.tm-skel--pill { width: 5.5rem; height: 1.5rem; border-radius: var(--tm-radius-pill); flex-shrink: 0; }
.tm-skel--dot { width: 1.5rem; height: 1.5rem; border-radius: var(--tm-radius-pill); flex-shrink: 0; }
.tm-skel--kpi { width: 45%; height: 1.75rem; border-radius: var(--tm-radius-sm); }
.tm-skel--line { height: .75rem; }
.tm-skel--input { height: var(--tm-control-md); border-radius: var(--tm-radius-sm); }
.tm-skel--block { height: 12rem; border-radius: var(--tm-radius-lg); margin-top: 1rem; }

.tm-skeleton {
  padding: .5rem 1.5rem 1rem;
}

.tm-card__body > .tm-skeleton { padding: 0; }

.tm-skeleton__row {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4rem;
  border-bottom: 1px solid var(--tm-border-subtle);
}

.tm-skeleton__lines {
  display: grid;
  flex: 1;
  gap: .5rem;
}

.tm-skeleton__short { width: 4.5rem; flex-shrink: 0; }

/* Reflow at 320 px (WCAG 1.4.10, R19-I): the fixed placeholders of a list row were wider than a phone card; below
   600 px the registry shows cards, so the skeleton keeps the identity, lines and status dot only. */
.tm-skeleton__lines { min-width: 0; }

@media (max-width: 599px) {
  .tm-skeleton__row .tm-skel--pill,
  .tm-skeleton__row .tm-skeleton__short { display: none; }
}

.tm-skeleton__pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 1rem;
  padding: .875rem 0;
  border-bottom: 1px solid var(--tm-border-subtle);
}

.tm-skeleton__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
}

.tm-skeleton__tile {
  display: grid;
  gap: .75rem;
  padding: 1.25rem;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-lg);
  background: var(--tm-paper);
}

.tm-skeleton__field {
  display: grid;
  gap: .5rem;
  padding: .5rem 0;
}

.tm-skeleton__label {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin: 1rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
  opacity: 0;
  animation: tm-appear 1ms linear 400ms forwards;
}

.tm-skeleton__label .tm-spinner {
  color: var(--tm-primary-text);
}

/* ==========================================================================
 * Przyciski (TmButton) i przyciski ikonowe (IconButton)
 * ======================================================================== */
.tm-btn {
  --btn-h: var(--tm-control-md);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: var(--btn-h);
  min-width: var(--btn-h);
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: var(--tm-radius-md);
  background: transparent;
  color: var(--tm-text);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.003em;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--tm-dur-fast) var(--tm-ease), border-color var(--tm-dur-fast) var(--tm-ease),
    color var(--tm-dur-fast) var(--tm-ease), box-shadow var(--tm-dur-fast) var(--tm-ease), transform var(--tm-dur-fast) var(--tm-ease);
}

.tm-btn:focus-visible,
.tm-icon-btn:focus-visible,
.tm-page-btn:focus-visible,
.tm-filter-chip:focus-visible,
.tm-criterion:focus-visible,
.tm-check:focus-visible,
.tm-switch:focus-visible,
.tm-tab:focus-visible,
.tm-menu__item:focus-visible,
.tm-preset:focus-visible {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: var(--tm-focus-offset);
  box-shadow: var(--tm-focus-halo);
}

.tm-btn:active:not(.is-inactive):not(:disabled) {
  transform: translateY(1px);
}

.tm-btn__icon,
.tm-btn .tm-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.tm-btn__icon--trail {
  margin-right: -.25rem;
  opacity: .8;
}

.tm-btn--sm { --btn-h: var(--tm-control-sm); padding: 0 .75rem; gap: .375rem; font-size: .8125rem; border-radius: var(--tm-radius-sm); }
.tm-btn--md { --btn-h: var(--tm-control-md); }
.tm-btn--lg { --btn-h: var(--tm-control-lg); padding: 0 1.375rem; font-size: .9375rem; }
.tm-btn--block { display: flex; width: 100%; }

.tm-btn--primary {
  background: var(--tm-primary);
  color: var(--tm-on-primary);
  box-shadow: 0 1px 2px rgb(var(--tm-primary-ch) / .2), 0 6px 16px -8px rgb(var(--tm-primary-ch) / .55);
}

.tm-btn--primary:hover:not(.is-inactive):not(:disabled) {
  background: var(--tm-primary-hover);
}

.tm-btn--secondary {
  border-color: rgb(var(--tm-primary-ch) / .45);
  background: var(--tm-paper);
  color: var(--tm-primary-text);
}

.tm-btn--secondary:hover:not(.is-inactive):not(:disabled) {
  border-color: var(--tm-primary);
  background: var(--tm-primary-tonal);
}

.tm-btn--tonal {
  background: var(--tm-primary-tonal);
  color: var(--tm-primary-text);
}

.tm-btn--tonal:hover:not(.is-inactive):not(:disabled) {
  background: rgb(var(--tm-primary-ch) / calc(var(--tm-primary-tonal-alpha) + .08));
}

.tm-btn--neutral {
  border-color: var(--tm-border);
  background: var(--tm-paper);
  color: var(--tm-text);
}

.tm-btn--neutral:hover:not(.is-inactive):not(:disabled),
.tm-btn--neutral[aria-expanded="true"],
.tm-btn--neutral:popover-open {
  border-color: var(--tm-border-control);
  background: var(--tm-paper-2);
}

.tm-btn--neutral.is-active {
  border-color: rgb(var(--tm-primary-ch) / .5);
  background: var(--tm-primary-tonal);
  color: var(--tm-primary-text);
}

.tm-btn--ghost,
.tm-btn--tertiary {
  background: transparent;
  color: var(--tm-primary-text);
}

.tm-btn--ghost:hover:not(.is-inactive):not(:disabled),
.tm-btn--tertiary:hover {
  background: var(--tm-primary-tonal);
}

.tm-btn--danger {
  background: var(--tm-danger-text);
  color: var(--tm-on-status-strong);
}

.tm-btn--danger:hover:not(.is-inactive):not(:disabled) {
  background: rgb(var(--tm-danger-text-ch) / .88);
}

.tm-btn:disabled,
.tm-btn.is-inactive {
  border-color: transparent;
  background: var(--tm-paper-3);
  color: var(--tm-text-disabled);
  box-shadow: none;
  cursor: not-allowed;
}

.tm-btn--ghost.is-inactive,
.tm-btn--ghost:disabled {
  background: transparent;
}

.tm-btn.is-pending {
  cursor: progress;
}

/* Wysyłanie to nie niedostępność (R19-E): zablokowany przycisk akcji głównej w toku zachowuje barwę marki. */
.tm-btn--primary.is-pending:disabled {
  background: var(--tm-primary);
  color: var(--tm-on-primary);
  cursor: progress;
}

.tm-btn.is-pending .tm-spinner {
  border-color: rgb(var(--tm-text-ch) / .2);
  border-top-color: currentColor;
}

.tm-btn--primary.is-pending .tm-spinner,
.tm-btn--danger.is-pending .tm-spinner {
  border-color: rgb(var(--tm-on-primary-ch) / .35);
  border-top-color: currentColor;
}

.tm-icon-btn {
  --ib: 2.5rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ib);
  height: var(--ib);
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-md);
  background: var(--tm-paper-2);
  color: var(--tm-text-2);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--tm-dur-fast) var(--tm-ease), color var(--tm-dur-fast) var(--tm-ease);
}

.tm-icon-btn:hover,
.tm-icon-btn[aria-expanded="true"],
.tm-icon-btn[aria-pressed="true"] {
  background: var(--tm-paper-3);
  color: var(--tm-text);
}

.tm-icon-btn .tm-btn__icon {
  width: 1.125rem;
  height: 1.125rem;
}

.tm-icon-btn--sm { --ib: 2rem; border-radius: var(--tm-radius-sm); }
.tm-icon-btn--sm .tm-btn__icon { width: 1rem; height: 1rem; }
.tm-icon-btn--md { --ib: 2.5rem; }

.tm-icon-btn--ghost {
  border-color: transparent;
  background: transparent;
}

.tm-icon-btn--ghost:hover {
  background: rgb(var(--tm-text-ch) / .06);
}

.tm-icon-btn.is-inactive {
  color: var(--tm-text-disabled);
  cursor: not-allowed;
}

.tm-icon-btn__badge {
  position: absolute;
  top: -.375rem;
  right: -.375rem;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 .3125rem;
  border: 2px solid var(--tm-paper);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-danger-text);
  color: var(--tm-on-status-strong);
  font-size: .6875rem;
  font-weight: 700;
  line-height: .875rem;
  text-align: center;
}

@media (max-width: 899px) {
  .tm-btn--sm,
  .tm-icon-btn--sm,
  .tm-page-btn {
    min-height: var(--tm-target-touch);
    min-width: var(--tm-target-touch);
  }

  .tm-btn--sm { height: auto; }
}

/* ==========================================================================
 * Łącza
 * ======================================================================== */
.tm-link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tm-primary-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  text-underline-offset: .2em;
  cursor: pointer;
}

.tm-link:hover {
  text-decoration: underline;
}

.tm-link--inline {
  display: inline;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.tm-link__icon {
  width: .875rem;
  height: .875rem;
  flex-shrink: 0;
}

/* ==========================================================================
 * Okienko (TmPopover) i menu (TmMenu): Popover API + pozycjonowanie kotwicą
 * ======================================================================== */
.tm-pop-anchor {
  display: inline-flex;
  position: relative;
}

.tm-pop {
  position: fixed;
  inset: auto;
  margin: .5rem 0 0;
  position-area: bottom span-right;
  position-try-fallbacks: flip-block, flip-inline;
  min-width: 14rem;
  max-width: min(24rem, calc(100vw - 2rem));
  max-height: min(28rem, calc(100dvh - 6rem));
  overflow: auto;
  padding: .5rem;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-lg);
  background: var(--tm-paper);
  color: var(--tm-text);
  box-shadow: var(--tm-shadow-overlay);
  font-size: var(--tm-text-body-sm);
}

.tm-pop--end {
  position-area: bottom span-left;
}

.tm-pop:popover-open {
  animation: tm-rise var(--tm-dur) var(--tm-ease-out);
}

@supports not (position-area: bottom) {
  .tm-pop {
    inset: 0;
    margin: auto;
    height: fit-content;
  }
}

.tm-pop__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .625rem .625rem;
}

.tm-pop__title {
  color: var(--tm-text-2);
  font-size: var(--tm-text-overline);
  font-weight: 700;
  letter-spacing: var(--tm-tracking-overline);
  text-transform: uppercase;
}

.tm-pop__head .tm-link {
  font-size: var(--tm-text-caption);
}

.tm-pop__foot {
  margin-top: .375rem;
  padding-top: .375rem;
  border-top: 1px solid var(--tm-border-subtle);
}

.tm-menu {
  min-width: 13rem;
  padding: .375rem;
}

.tm-menu__list {
  display: grid;
  gap: .125rem;
}

.tm-menu__item {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  min-height: 2.375rem;
  padding: .5rem .75rem;
  border: 0;
  border-radius: var(--tm-radius-sm);
  background: transparent;
  color: var(--tm-text);
  font: inherit;
  font-size: var(--tm-text-body-sm);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.tm-menu__item:hover,
.tm-menu__item:focus-visible {
  background: rgb(var(--tm-text-ch) / .05);
}

.tm-menu__icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--tm-text-2);
}

.tm-menu__item--danger,
.tm-menu__item--danger .tm-menu__icon {
  color: var(--tm-danger-text);
}

.tm-menu__item--danger:hover {
  background: var(--tm-danger-tonal);
}

.tm-menu__item.is-inactive {
  color: var(--tm-text-disabled);
  cursor: not-allowed;
}

.tm-menu__sep {
  height: 1px;
  margin: .25rem .375rem;
  background: var(--tm-border-subtle);
}

/* ==========================================================================
 * Karta sekcji (SectionCard)
 * ======================================================================== */
.tm-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-lg);
  background: var(--tm-paper);
  color: var(--tm-text);
  box-shadow: var(--tm-shadow-card);
}

.tm-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--tm-border-subtle);
}

.tm-card__head--plain {
  border-bottom: 0;
  padding-bottom: .25rem;
}

.tm-card__titles {
  display: grid;
  gap: .25rem;
  min-width: 0;
}

.tm-card__title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.tm-card__icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  color: var(--tm-primary-text);
}

.tm-card__title {
  margin: 0;
  font-size: var(--tm-text-h2);
  font-weight: 600;
  line-height: var(--tm-leading-h2);
  letter-spacing: var(--tm-tracking-h2);
}

.tm-card__subtitle {
  margin: 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
  line-height: var(--tm-leading-body-sm);
}

.tm-card__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .75rem;
}

.tm-card__body {
  flex: 1;
  min-width: 0;
  padding: 1.25rem 1.5rem 1.5rem;
}

.tm-card--flush > .tm-card__body {
  padding: 0;
}

.tm-card__foot {
  padding: .875rem 1.5rem;
  border-top: 1px solid var(--tm-border-subtle);
  font-size: var(--tm-text-body-sm);
}

.tm-card--success, .tm-card--warning, .tm-card--danger, .tm-card--info, .tm-card--primary {
  border-color: rgb(var(--tone-ch) / .35);
  background: linear-gradient(135deg, rgb(var(--tone-ch) / .07), transparent 60%), var(--tm-paper);
}

@media (max-width: 599px) {
  .tm-card__head { padding: 1rem 1rem .875rem; }
  .tm-card__body { padding: 1rem; }
  .tm-card__foot { padding: .75rem 1rem; }
}

/* ==========================================================================
 * Kafel KPI
 * ======================================================================== */
.tm-kpi-row-wrap {
  container-type: inline-size;
}

.tm-kpi-row__meta {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .5rem;
}

.tm-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(max(12.5rem, calc((100% - 3 * 1rem) / 4)), 1fr));
  gap: 1rem;
}

@container (max-width: 480px) {
  .tm-kpi-row { grid-template-columns: minmax(0, 1fr); }
}

.tm-kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .375rem;
  min-height: 9.5rem;
  padding: 1.25rem 1.25rem 1rem;
  overflow: hidden;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-lg);
  background: var(--tm-paper);
  color: var(--tm-text);
  box-shadow: var(--tm-shadow-card);
  text-decoration: none;
}

.tm-kpi--link {
  transition: box-shadow var(--tm-dur) var(--tm-ease), transform var(--tm-dur) var(--tm-ease), border-color var(--tm-dur) var(--tm-ease);
}

.tm-kpi--link:hover {
  border-color: var(--tm-border);
  box-shadow: var(--tm-shadow-raised);
  transform: translateY(-1px);
}

.tm-kpi--link:focus-visible {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: var(--tm-focus-offset);
}

.tm-kpi__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}

.tm-kpi__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--tm-radius-md);
}

.tm-kpi__svg {
  width: 1.125rem;
  height: 1.125rem;
}

.tm-kpi__trend {
  display: inline-flex;
  align-items: center;
  gap: .125rem;
  font-size: var(--tm-text-caption);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tm-kpi__trend-icon {
  width: .875rem;
  height: .875rem;
}

.tm-kpi__value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .25rem;
}

.tm-kpi__number {
  font-size: var(--tm-text-kpi);
  font-weight: 700;
  line-height: var(--tm-leading-kpi);
  letter-spacing: var(--tm-tracking-kpi);
  font-variant-numeric: tabular-nums;
}

.tm-kpi__total,
.tm-kpi__unit {
  color: var(--tm-text-3);
  font-size: 1.0625rem;
  font-weight: 600;
}

.tm-kpi__missing {
  color: var(--tm-text-2);
  font-size: var(--tm-text-body);
  font-weight: 600;
}

.tm-kpi__label {
  color: var(--tm-text-2);
  font-size: var(--tm-text-overline);
  font-weight: 700;
  letter-spacing: var(--tm-tracking-overline);
  line-height: var(--tm-leading-overline);
  text-transform: uppercase;
}

.tm-kpi__spark {
  display: block;
  width: calc(100% + 2.5rem);
  height: 2.25rem;
  margin: auto -1.25rem -1rem;
}

.tm-spark {
  color: var(--tone);
  overflow: visible;
}

[data-theme="dark"] .tm-spark {
  color: var(--tone-text);
}

.tm-spark__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tm-spark__stop-top { stop-color: currentColor; stop-opacity: .24; }
.tm-spark__stop-bottom { stop-color: currentColor; stop-opacity: 0; }

/* ==========================================================================
 * Etykieta statusu, odznaka, awatar, pigułka danych, lista par
 * ======================================================================== */
.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  max-width: 100%;
  min-height: 1.5rem;
  padding: .1875rem .625rem;
  border-radius: var(--tm-radius-pill);
  background: var(--tone-bg);
  color: var(--tone-text);
  font-size: var(--tm-text-caption);
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: middle;
}

.tm-chip > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A chip whose label is a sentence (KSeF state) wraps in a narrow card instead of widening the page. */
.tm-chip--wrap {
  white-space: normal;
}

.tm-chip--sm {
  min-height: 1.25rem;
  padding: .0625rem .5rem;
  font-size: .6875rem;
}

.tm-chip__dot {
  display: inline-block;
  width: .4375rem;
  height: .4375rem;
  flex-shrink: 0;
  border-radius: var(--tm-radius-pill);
  background: var(--tone);
}

.tm-chip--filled {
  background: var(--tone-text);
  color: var(--tm-on-status-strong);
}

.tm-chip--filled .tm-chip__dot {
  background: currentColor;
}

.tm-dot--neutral, .tm-dot--primary, .tm-dot--success, .tm-dot--warning, .tm-dot--danger, .tm-dot--info {
  background: var(--tone);
}

.tm-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .375rem;
  border-radius: var(--tm-radius-xs);
  background: var(--tone-bg);
  color: var(--tone-text);
  font-size: .6875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.tm-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 .3125rem;
  border-radius: var(--tm-radius-pill);
  background: var(--tm-primary);
  color: var(--tm-on-primary);
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1;
}

.tm-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: var(--tm-radius-pill);
  background: var(--tm-primary-tonal-solid);
  color: var(--tm-primary-text);
  font-size: var(--tm-text-body-sm);
  font-weight: 700;
  letter-spacing: .02em;
}

.tm-avatar--sm { width: 2rem; height: 2rem; font-size: var(--tm-text-caption); }
.tm-avatar--md { width: 2.5rem; height: 2.5rem; }
.tm-avatar--lg { width: 3rem; height: 3rem; font-size: var(--tm-text-body); }

.tm-avatar--success, .tm-avatar--warning, .tm-avatar--danger, .tm-avatar--info, .tm-avatar--neutral {
  background: var(--tone-bg);
  color: var(--tone-text);
}

.tm-kv {
  display: grid;
  width: 100%;
  margin: 0;
  container-type: inline-size;
}

.tm-kv__row {
  display: grid;
  grid-template-columns: minmax(8rem, 2fr) minmax(0, 3fr);
  gap: 1rem;
  align-items: baseline;
  padding: .75rem 0;
  border-bottom: 1px solid var(--tm-border-subtle);
}

.tm-kv__row:last-child { border-bottom: 0; }

.tm-kv__label {
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

.tm-kv__value {
  margin: 0;
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

/* Two columns from about 32rem of list width, one below. An intrinsic auto-fit grid, because .tm-kv is its own
 * container and a @container rule cannot react to the element's own width (R19-H: values wrapped one letter per line
 * on Rozliczenia at 390 px). */
.tm-kv--two {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(15rem, calc((100% - 2rem) / 2))), 1fr));
  column-gap: 2rem;
}

/* ==========================================================================
 * Notatka i baner (InlineNote)
 * ======================================================================== */
.tm-note {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border: 1px solid rgb(var(--tone-ch) / .22);
  border-radius: var(--tm-radius-md);
  background: rgb(var(--tone-ch) / .06);
  color: var(--tm-text);
  font-size: var(--tm-text-body-sm);
  line-height: var(--tm-leading-body-sm);
}

[data-theme="dark"] .tm-note {
  background: rgb(var(--tone-ch) / .14);
}

.tm-note__icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  margin-top: .0625rem;
  color: var(--tone-text);
}

.tm-note__body {
  display: grid;
  flex: 1;
  gap: .125rem;
  min-width: 0;
}

.tm-note__title {
  color: var(--tone-text);
  font-weight: 600;
}

.tm-note__text {
  color: var(--tm-text-2);
}

.tm-note__action {
  align-self: center;
  flex-shrink: 0;
}

.tm-note__close {
  margin: -.375rem -.5rem -.375rem 0;
}

.tm-note--banner {
  padding: 1rem 1.25rem;
  border-radius: var(--tm-radius-lg);
}

@media (max-width: 599px) {
  .tm-note { flex-wrap: wrap; }
  .tm-note__action { flex-basis: 100%; margin-left: 1.875rem; }
}

/* ==========================================================================
 * Stany: pusty, brak wyników, błąd
 * ======================================================================== */
.tm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
}

.tm-empty--compact {
  padding: 2rem 1rem;
}

.tm-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  border-radius: var(--tm-radius-md);
}

.tm-empty__svg {
  width: 1.375rem;
  height: 1.375rem;
}

.tm-empty__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}

.tm-empty__text {
  max-width: 30rem;
  margin: .375rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
  line-height: var(--tm-leading-body-sm);
}

.tm-empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .75rem;
  margin-top: 1.25rem;
}

.tm-empty__actions:empty { display: none; }

.tm-error__id {
  margin: .75rem 0 0;
  color: var(--tm-text-3);
  font-size: var(--tm-text-caption);
  user-select: all;
}

/* ==========================================================================
 * Powiadomienia (ToastHost)
 * ======================================================================== */
.tm-toasts {
  position: fixed;
  top: 1rem;
  left: 50%;
  z-index: var(--tm-z-toast);
  display: grid;
  gap: .5rem;
  width: min(26rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}

.tm-toasts__region {
  display: grid;
  gap: .5rem;
}

.tm-toasts__region:empty { display: none; }

@media (max-width: 599px) {
  .tm-toasts {
    top: auto;
    bottom: 1rem;
  }
}

.tm-toast {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem .75rem .75rem .875rem;
  border: 1px solid rgb(var(--tone-ch) / .28);
  border-radius: var(--tm-radius-md);
  background: var(--tm-paper);
  color: var(--tm-text);
  box-shadow: var(--tm-shadow-overlay);
  pointer-events: auto;
  animation: tm-rise var(--tm-dur) var(--tm-ease-out);
}

.tm-toast__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: var(--tm-radius-sm);
  background: var(--tone-bg);
  color: var(--tone-text);
}

.tm-toast__svg { width: 1rem; height: 1rem; }

.tm-toast__body {
  flex: 1;
  min-width: 0;
  padding-top: .3125rem;
}

.tm-toast__title {
  margin: 0;
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
}

.tm-toast__text {
  margin: .125rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

/* ==========================================================================
 * Zakładki (PageTabs) i kroki (ProcessStepper)
 * ======================================================================== */
/* A tab bar wider than its container scrolls; overlay scrollbars (macOS, phones) are invisible, so scroll shadows
   show that more tabs are hidden (R19-J). Covers in the surface colour scroll with the content (local) and hide the
   shade (scroll) at an end that is reached; with no overflow both ends are covered and nothing shows. */
.tm-tabs {
  --tabs-surface: var(--tm-canvas);
  --tabs-shade: rgb(var(--tm-text-ch) / .2);
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--tm-border-subtle);
  background:
    linear-gradient(to right, var(--tabs-surface) 40%, transparent) left center / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--tabs-surface) 40%, transparent) right center / 2.5rem 100% no-repeat local,
    linear-gradient(to right, var(--tabs-shade), transparent) left center / 1.25rem 100% no-repeat scroll,
    linear-gradient(to left, var(--tabs-shade), transparent) right center / 1.25rem 100% no-repeat scroll;
  scrollbar-width: thin;
}

.tm-card .tm-tabs,
.tm-dialog .tm-tabs,
.tm-drawer .tm-tabs { --tabs-surface: var(--tm-paper); }

.tm-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: 0 .875rem;
  border: 0;
  background: none;
  color: var(--tm-text-2);
  font: inherit;
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.tm-tab:hover { color: var(--tm-text); }

.tm-tab.is-active {
  color: var(--tm-primary-text);
}

.tm-tab.is-active::after {
  content: "";
  position: absolute;
  right: .5rem;
  bottom: -1px;
  left: .5rem;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--tm-primary);
}

.tm-tab.is-inactive {
  color: var(--tm-text-disabled);
  cursor: not-allowed;
}

.tm-tab__icon { width: 1rem; height: 1rem; flex-shrink: 0; }

.tm-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .375rem;
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper-3);
  color: var(--tm-text-2);
  font-size: .6875rem;
  font-weight: 700;
}

.tm-tab.is-active .tm-tab__count {
  background: var(--tm-primary-tonal);
  color: var(--tm-primary-text);
}

.tm-tabs--segmented {
  display: inline-flex;
  gap: .125rem;
  padding: .25rem;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper-2);
}

.tm-tabs--segmented .tm-tab {
  min-height: 2rem;
  padding: 0 .875rem;
  border-radius: var(--tm-radius-pill);
}

.tm-tabs--segmented .tm-tab.is-active {
  background: var(--tm-paper);
  box-shadow: 0 1px 3px rgb(var(--tm-text-ch) / .12);
}

[data-theme="dark"] .tm-tabs--segmented .tm-tab.is-active {
  background: var(--tm-paper-3);
}

.tm-tabs--segmented .tm-tab.is-active::after { display: none; }

.tm-tabpanel { padding-top: 1.25rem; }
.tm-tabpanel:focus-visible { outline: var(--tm-focus-width) solid var(--tm-focus); outline-offset: var(--tm-focus-offset); }

.tm-stepper {
  container-type: inline-size;
  width: 100%;
}

.tm-stepper__list {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tm-step {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  min-width: 0;
  padding-top: .875rem;
  border-top: 3px solid var(--tm-border-subtle);
}

.tm-step--complete,
.tm-step--current { border-top-color: var(--tm-primary); }
.tm-step--error { border-top-color: var(--tm-danger-text); }

.tm-step__marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper-3);
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tm-step__icon { width: 1rem; height: 1rem; }

.tm-step--current .tm-step__marker {
  background: var(--tm-primary);
  color: var(--tm-on-primary);
  box-shadow: 0 0 0 4px var(--tm-primary-tonal);
}

.tm-step--complete .tm-step__marker {
  background: var(--tm-primary-tonal);
  color: var(--tm-primary-text);
}

.tm-step--error .tm-step__marker {
  background: var(--tm-danger-tonal);
  color: var(--tm-danger-text);
}

.tm-step__text {
  display: grid;
  gap: .125rem;
  min-width: 0;
  padding-top: .3125rem;
}

.tm-step__label {
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tm-step--pending .tm-step__label { color: var(--tm-text-2); }
.tm-step--error .tm-step__label { color: var(--tm-danger-text); }

.tm-step__desc {
  color: var(--tm-text-2);
  font-size: var(--tm-text-caption);
}

.tm-stepper--vertical .tm-stepper__list {
  grid-auto-flow: row;
  gap: 0;
}

.tm-stepper--vertical .tm-step {
  padding: 0 0 1.25rem 1rem;
  border-top: 0;
  border-left: 3px solid var(--tm-border-subtle);
}

.tm-stepper--vertical .tm-step--complete,
.tm-stepper--vertical .tm-step--current { border-left-color: var(--tm-primary); }
.tm-stepper--vertical .tm-step--error { border-left-color: var(--tm-danger-text); }

@container (max-width: 560px) {
  .tm-stepper__list { grid-auto-flow: row; gap: 0; }
  .tm-step { padding: 0 0 1.25rem 1rem; border-top: 0; border-left: 3px solid var(--tm-border-subtle); }
  .tm-step--complete, .tm-step--current { border-left-color: var(--tm-primary); }
  .tm-step--error { border-left-color: var(--tm-danger-text); }
}

/* ==========================================================================
 * Rejestr (RegistryTable): pasek narzędzi, filtry, tabela, karty, pager
 * ======================================================================== */
.tm-registry {
  container-type: inline-size;
  min-width: 0;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-lg);
  background: var(--tm-paper);
  box-shadow: var(--tm-shadow-card);
}

.tm-card .tm-registry {
  border: 0;
  border-radius: 0 0 var(--tm-radius-lg) var(--tm-radius-lg);
  box-shadow: none;
  /* R19-G: the registry is the card's last block, so its bottom corners follow the card's; menus and filters use the
     Popover API (top layer), so clipping here never cuts them. */
  overflow: clip;
}

.tm-registry__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1rem;
  padding: 1.25rem 1.5rem 1rem;
}

.tm-registry__criteria {
  display: flex;
  flex: 1 1 32rem;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

.tm-registry__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.tm-registry__clear {
  margin-left: .25rem;
  font-size: var(--tm-text-body-sm);
}

.tm-search {
  position: relative;
  display: flex;
  flex: 1 1 15rem;
  max-width: 22rem;
  min-width: min(15rem, 100%);
}

.tm-search__icon {
  position: absolute;
  top: 50%;
  left: .875rem;
  width: 1rem;
  height: 1rem;
  color: var(--tm-text-3);
  transform: translateY(-50%);
  pointer-events: none;
}

.tm-search__input {
  width: 100%;
  height: var(--tm-control-md);
  padding: 0 1rem 0 2.5rem;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper);
  color: var(--tm-text);
  font: inherit;
  font-size: var(--tm-text-body-sm);
  transition: border-color var(--tm-dur-fast) var(--tm-ease), box-shadow var(--tm-dur-fast) var(--tm-ease);
}

.tm-search__input:hover { border-color: var(--tm-border-control); }

.tm-search__input:focus,
.tm-search__input:focus-visible {
  border-color: var(--tm-primary);
  outline: none;
  box-shadow: var(--tm-focus-halo);
}

.tm-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  height: 2.25rem;
  padding: 0 .75rem;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper);
  color: var(--tm-text-2);
  font: inherit;
  font-size: .8125rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--tm-dur-fast) var(--tm-ease), border-color var(--tm-dur-fast) var(--tm-ease);
}

.tm-filter-chip:hover {
  border-color: var(--tm-border-control);
  color: var(--tm-text);
}

.tm-filter-chip.is-active {
  border-color: rgb(var(--tm-primary-ch) / .5);
  background: var(--tm-primary-tonal);
  color: var(--tm-primary-text);
}

.tm-filter-chip .tm-btn__icon { width: .875rem; height: .875rem; }

.tm-criterion {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  height: 1.875rem;
  padding: 0 .5rem 0 .75rem;
  border: 0;
  border-radius: var(--tm-radius-pill);
  background: var(--tm-primary-tonal);
  color: var(--tm-primary-text);
  font: inherit;
  font-size: var(--tm-text-caption);
  font-weight: 600;
  cursor: pointer;
}

.tm-criterion:hover {
  background: rgb(var(--tm-primary-ch) / calc(var(--tm-primary-tonal-alpha) + .08));
}

.tm-criterion__icon { width: .875rem; height: .875rem; }

.tm-option-list {
  display: grid;
  gap: .125rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tm-option {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 2.25rem;
  padding: .375rem .625rem;
  border-radius: var(--tm-radius-sm);
  color: var(--tm-text);
  font-size: var(--tm-text-body-sm);
  cursor: pointer;
}

.tm-option:hover { background: rgb(var(--tm-text-ch) / .04); }

.tm-option__label { flex: 1; min-width: 0; }
.tm-option__label.is-on { color: var(--tm-primary-text); font-weight: 600; }

.tm-option__count {
  color: var(--tm-text-3);
  font-size: var(--tm-text-caption);
  font-variant-numeric: tabular-nums;
}

.tm-option--switch { cursor: default; }

.tm-preset-list {
  display: grid;
  gap: .125rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tm-preset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  min-height: 2.25rem;
  padding: .375rem .625rem;
  border: 0;
  border-radius: var(--tm-radius-sm);
  background: none;
  color: var(--tm-text);
  font: inherit;
  font-size: var(--tm-text-body-sm);
  text-align: left;
  cursor: pointer;
}

.tm-preset:hover { background: rgb(var(--tm-text-ch) / .04); }

.tm-preset.is-active {
  color: var(--tm-primary-text);
  font-weight: 600;
}

.tm-preset--save {
  justify-content: flex-start;
  color: var(--tm-primary-text);
  font-weight: 600;
}

.tm-preset--save:disabled {
  color: var(--tm-text-disabled);
  cursor: not-allowed;
}

.tm-preset__check { width: 1rem; height: 1rem; flex-shrink: 0; }

.tm-preset-form {
  display: flex;
  gap: .5rem;
  padding: .25rem;
}

/* Przełącznik w liście kolumn */
.tm-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 2.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  padding: 0 .125rem;
  border: 1px solid var(--tm-border-control);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper-3);
  cursor: pointer;
  transition: background-color var(--tm-dur) var(--tm-ease), border-color var(--tm-dur) var(--tm-ease);
}

.tm-switch__thumb {
  display: block;
  width: .875rem;
  height: .875rem;
  border-radius: var(--tm-radius-pill);
  background: var(--tm-text-3);
  transition: transform var(--tm-dur) var(--tm-ease), background-color var(--tm-dur) var(--tm-ease);
}

.tm-switch[aria-checked="true"] {
  border-color: var(--tm-primary);
  background: var(--tm-primary);
}

.tm-switch[aria-checked="true"] .tm-switch__thumb {
  background: var(--tm-on-primary);
  transform: translateX(1rem);
}

.tm-switch[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .6;
}

/* Pasek zaznaczenia */
.tm-bulk {
  border-top: 1px solid var(--tm-border-subtle);
  background: var(--tm-primary-tonal);
}

.tm-bulk__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1rem;
  padding: .75rem 1.5rem;
}

.tm-bulk__count {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--tm-primary-text);
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
}

.tm-bulk__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 .375rem;
  border-radius: var(--tm-radius-pill);
  background: var(--tm-primary);
  color: var(--tm-on-primary);
  font-size: var(--tm-text-caption);
  font-weight: 700;
}

.tm-bulk__clear { font-size: var(--tm-text-body-sm); color: var(--tm-text-2); }

.tm-bulk__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-left: auto;
}

.tm-bulk__confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .75rem 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgb(var(--tone-ch) / .25);
  background: var(--tm-paper);
  background-image: linear-gradient(rgb(var(--tone-ch) / .08), rgb(var(--tone-ch) / .08));
}

.tm-bulk__confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: var(--tm-radius-md);
}

.tm-bulk__confirm-body {
  flex: 1 1 18rem;
  min-width: 0;
}

.tm-bulk__confirm-title {
  margin: 0;
  font-size: var(--tm-text-body);
  font-weight: 600;
}

.tm-bulk__confirm-text {
  margin: .25rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

.tm-bulk__confirm-actions {
  display: flex;
  gap: .5rem;
  align-self: center;
}

/* Tabela */
.tm-registry__scroll {
  overflow-x: auto;
  border-top: 1px solid var(--tm-border-subtle);
  scrollbar-width: thin;
}

.tm-card__body > .tm-registry__scroll:first-child { border-top: 0; }

/* A table that ends a flush card keeps the card's rounded bottom: the scroll box clips its cells to the inner radius
   (without it the cell backgrounds squared the corners and covered the bottom edge, e.g. "Ostatnia aktywność"). */
.tm-card--flush > .tm-card__body:last-child > .tm-registry__scroll:last-child {
  border-bottom-left-radius: calc(var(--tm-radius-lg) - 1px);
  border-bottom-right-radius: calc(var(--tm-radius-lg) - 1px);
}

.tm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--tm-text-body-sm);
  font-variant-numeric: tabular-nums;
}

.tm-table th,
.tm-table td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--tm-border-subtle);
  background: var(--tm-paper);
  text-align: left;
  vertical-align: middle;
}

.tm-table thead th {
  height: 3rem;
  padding-top: .5rem;
  padding-bottom: .5rem;
  color: var(--tm-text-2);
  font-size: var(--tm-text-overline);
  font-weight: 700;
  letter-spacing: var(--tm-tracking-overline);
  line-height: var(--tm-leading-overline);
  text-transform: uppercase;
  white-space: nowrap;
}

.tm-table tbody td {
  height: 4rem;
  color: var(--tm-text);
}

.tm-table th:first-child,
.tm-table td:first-child { padding-left: 1.5rem; }

.tm-table th:last-child,
.tm-table td:last-child { padding-right: 1.5rem; }

.tm-table tbody tr:last-child td { border-bottom: 0; }

/* Pełne barwy (color-mix) zamiast nakładki: komórki przyklejone muszą być nieprzezroczyste, bez szwów między komórkami. */
/* Wiersz i komórki mają tę samą barwę: ułamkowe szerokości kolumn nie odsłaniają tła karty między komórkami. */
.tm-table tbody tr:hover,
.tm-table tbody tr:hover td {
  background: color-mix(in srgb, var(--tm-primary) 4%, var(--tm-paper));
}

.tm-table tbody tr.is-selected,
.tm-table tbody tr.is-selected td {
  background: color-mix(in srgb, var(--tm-primary) calc(var(--tm-primary-tonal-alpha) * 100%), var(--tm-paper));
}

.tm-table .is-end { text-align: right; }

.tm-table thead th.is-sorted { color: var(--tm-primary-text); }

.tm-table__sort {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin: -.25rem -.375rem;
  padding: .25rem .375rem;
  border: 0;
  border-radius: var(--tm-radius-xs);
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.tm-table__sort:hover { color: var(--tm-text); }

.tm-table__sort-icon {
  width: .8125rem;
  height: .8125rem;
  opacity: .7;
}

.tm-table__select {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 3.25rem;
  padding-right: .25rem !important;
}

.tm-table__identity {
  font-weight: 600;
}

.tm-table__actions {
  position: sticky;
  right: 0;
  z-index: 1;
  width: 3.5rem;
  text-align: right !important;
  box-shadow: -1px 0 0 var(--tm-border-subtle);
}

.tm-table__link {
  color: inherit;
  text-decoration: none;
}

.tm-table__link:hover {
  color: var(--tm-primary-text);
  text-decoration: underline;
  text-underline-offset: .2em;
}

.tm-table__link:focus-visible {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: var(--tm-focus-offset);
  border-radius: var(--tm-radius-xs);
}

.tm-table--compact tbody td,
.tm-table--compact tbody th { height: 2.75rem; padding-top: .5rem; padding-bottom: .5rem; }
.tm-table--compact tbody th { font-weight: 600; }

/* Pole wyboru tabeli (button role=checkbox: obsługuje stan „mixed”) */
.tm-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  border: 1.5px solid var(--tm-border-control);
  border-radius: 5px;
  background: var(--tm-paper);
  color: var(--tm-on-primary);
  cursor: pointer;
  transition: background-color var(--tm-dur-fast) var(--tm-ease), border-color var(--tm-dur-fast) var(--tm-ease);
}

.tm-check::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.25rem;
  height: 2.25rem;
  transform: translate(-50%, -50%);
}

.tm-check:hover { border-color: var(--tm-primary); }

.tm-check.is-checked,
.tm-check.is-mixed {
  border-color: var(--tm-primary);
  background: var(--tm-primary);
}

.tm-check__icon {
  width: .75rem;
  height: .75rem;
  stroke-width: 3;
}

/* Widok kart w wąskim kontenerze (Q16j): te same wiersze tabeli, jeden DOM na wiersz. Etykieta pola i tytuł karty bez
   kolumny tożsamości są w komórce, ale szeroka tabela ich nie wyświetla (nagłówek kolumny nazywa komórkę). */
.tm-table__label,
.tm-table__title { display: none; }

/* Q16j: od 1px, bo kontener o szerokości 0 (element wstawiony przy przejściu prerenderu w obwód, jeszcze bez układu)
   przełączał na chwilę całą tabelę w karty; Chromium zostawiał wtedy niezamalowane nagłówek i pierwszy wiersz. */
@container (min-width: 1px) and (max-width: 600px) {
  /* Karta: głowa (wybór, tożsamość, menu wiersza), łamanie linii, pola priorytetowe w dwóch kolumnach. Wartości jak
     dawny osobny widok kart (odstęp 1rem, głowa z odstępem .75rem, pola z odstępem .75rem 1rem). */
  .tm-registry .tm-table,
  .tm-registry .tm-table tbody { display: block; }

  .tm-registry .tm-table {
    font-size: inherit;
    font-variant-numeric: inherit;
  }

  /* Karta nie ma nagłówka kolumn ani podpisu (jak dawna lista kart); nazwę daje region przewijania (aria-label). */
  .tm-registry .tm-table thead,
  .tm-registry .tm-table caption { display: none; }

  .tm-registry .tm-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--tm-border-subtle);
  }

  .tm-registry .tm-table tbody tr::before {
    content: "";
    order: 4;
    flex-basis: 100%;
  }

  .tm-registry .tm-table tbody td {
    display: block;
    position: static;
    width: auto;
    height: auto;
    min-width: 0;
    padding: 0 !important;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    text-align: left !important;
  }

  .tm-registry .tm-table tbody tr,
  .tm-registry .tm-table tbody tr:hover,
  .tm-registry .tm-table tbody tr:hover td,
  .tm-registry .tm-table tbody tr.is-selected td { background: transparent; }

  .tm-registry .tm-table tbody tr.is-selected { background: var(--tm-primary-tonal); }

  .tm-registry .tm-table tbody td.tm-table__select {
    display: flex;
    order: 1;
    margin-right: .75rem;
  }

  .tm-registry .tm-table tbody td.tm-table__select .tm-check { margin-top: .125rem; }

  .tm-registry .tm-table tbody td.tm-table__identity,
  .tm-registry .tm-table tbody td.tm-table__title {
    display: block;
    /* 1px, not 0: with a zero basis a title without selection and menu shares its line with the 100% line break. */
    flex: 1 1 1px;
    order: 2;
    font-family: inherit;
    font-size: var(--tm-text-body);
    font-weight: 600;
    letter-spacing: inherit;
  }

  .tm-registry .tm-table tbody td.tm-table__actions {
    order: 3;
    margin: -.375rem -.375rem 0 .75rem;
  }

  .tm-registry .tm-table tbody td.tm-table__field {
    flex: 0 0 calc(50% - .5rem);
    order: 5;
    margin-top: .75rem;
    font-size: var(--tm-text-body-sm);
    overflow-wrap: anywhere;
  }

  .tm-registry .tm-table tbody td.tm-table__secondary { display: none; }

  .tm-registry .tm-table .tm-table__label {
    display: block;
    margin-bottom: .25rem;
    color: var(--tm-text-3);
    font-family: var(--tm-font-sans);
    font-size: var(--tm-text-overline);
    font-weight: 700;
    letter-spacing: var(--tm-tracking-overline);
    text-transform: uppercase;
  }
}

@container (max-width: 600px) {
  .tm-registry__toolbar { padding: 1rem; }
  .tm-registry__tools { width: 100%; }
  .tm-search { max-width: none; flex-basis: 100%; }
  .tm-bulk__bar, .tm-bulk__confirm { padding-left: 1rem; padding-right: 1rem; }
  .tm-bulk__actions { margin-left: 0; width: 100%; }
}

/* Pager */
.tm-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  padding: .875rem 1.5rem;
  border-top: 1px solid var(--tm-border-subtle);
}

.tm-pager__summary {
  margin: 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
  font-variant-numeric: tabular-nums;
}

.tm-pager__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.25rem;
}

.tm-pager__size {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

.tm-pager__pages {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tm-pager__gap {
  width: 1.5rem;
  color: var(--tm-text-3);
  text-align: center;
}

.tm-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 .5rem;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  background: var(--tm-paper);
  color: var(--tm-text);
  font: inherit;
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.tm-page-btn:hover:not(:disabled) { border-color: var(--tm-border-control); background: var(--tm-paper-2); }

.tm-page-btn.is-current {
  border-color: var(--tm-primary);
  background: var(--tm-primary);
  color: var(--tm-on-primary);
}

.tm-page-btn:disabled {
  color: var(--tm-text-disabled);
  cursor: not-allowed;
}

@container (max-width: 600px) {
  .tm-pager { padding: .875rem 1rem; }
}

/* ==========================================================================
 * Formularze
 * ======================================================================== */
.tm-field {
  display: grid;
  align-content: start;
  gap: .375rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.tm-field__label {
  display: block;
  padding: 0;
  color: var(--tm-text);
  font-size: var(--tm-text-label);
  font-weight: 600;
  line-height: var(--tm-leading-label);
}

.tm-field__opt {
  color: var(--tm-text-3);
  font-weight: 400;
}

.tm-field__req {
  margin-left: .125rem;
  color: var(--tm-danger-text);
}

.tm-field__hint {
  margin: -.125rem 0 .125rem;
  color: var(--tm-text-2);
  font-size: var(--tm-text-caption);
  line-height: 1.45;
}

.tm-field__error {
  display: flex;
  align-items: flex-start;
  gap: .375rem;
  margin: 0;
  color: var(--tm-danger-text);
  font-size: var(--tm-text-caption);
  font-weight: 500;
  line-height: 1.45;
}

.tm-field__error-icon {
  width: .875rem;
  height: .875rem;
  flex-shrink: 0;
  margin-top: .0625rem;
}

.tm-field__counter {
  margin: 0;
  color: var(--tm-text-3);
  font-size: var(--tm-text-caption);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tm-field__counter.is-near { color: var(--tm-warning-text); font-weight: 600; }

.tm-control {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.tm-input {
  width: 100%;
  height: var(--tm-control-md);
  padding: 0 .875rem;
  border: 1px solid var(--tm-border-control);
  border-radius: var(--tm-radius-sm);
  background: var(--tm-paper-2);
  color: var(--tm-text);
  font: inherit;
  font-size: var(--tm-text-body);
  transition: border-color var(--tm-dur-fast) var(--tm-ease), box-shadow var(--tm-dur-fast) var(--tm-ease), background-color var(--tm-dur-fast) var(--tm-ease);
}

.tm-input--sm { height: var(--tm-control-sm); font-size: var(--tm-text-body-sm); }
.tm-input--num { text-align: right; font-variant-numeric: tabular-nums; }

.tm-control--lg .tm-input { height: var(--tm-control-lg); }

.tm-input:hover:not(:disabled):not([readonly]) { border-color: var(--tm-text-3); }

.tm-input:focus,
.tm-input:focus-visible {
  border-color: var(--tm-primary);
  outline: none;
  background: var(--tm-paper);
  box-shadow: var(--tm-focus-halo);
}

.tm-input[aria-invalid="true"],
.tm-input[aria-invalid="true"]:hover:not(:disabled),
.is-invalid > .tm-control .tm-input {
  border-color: var(--tm-danger-text);
}

.tm-input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 4px rgb(var(--tm-danger-ch) / .2);
}

.tm-input:disabled,
.tm-input[readonly] {
  border-color: var(--tm-border);
  background: var(--tm-paper-3);
  color: var(--tm-text-2);
}

.tm-input:disabled { cursor: not-allowed; }

.tm-control.has-lead .tm-input { padding-left: 2.5rem; }
.tm-control.has-trail .tm-input { padding-right: 3rem; }

.tm-control__lead {
  position: absolute;
  left: .875rem;
  width: 1rem;
  height: 1rem;
  color: var(--tm-text-3);
  pointer-events: none;
}

.tm-control__suffix {
  position: absolute;
  right: .875rem;
  color: var(--tm-text-3);
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  pointer-events: none;
}

.tm-control__reveal {
  position: absolute;
  right: .25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: var(--tm-radius-sm);
  background: none;
  color: var(--tm-text-2);
  cursor: pointer;
}

.tm-control__reveal:hover { background: rgb(var(--tm-text-ch) / .06); }

/* Ostrzeżenie Caps Lock (R19-E): region stanu zawsze obecny, pusty bez ostrzeżenia. */
.tm-field__caps {
  display: flex;
  align-items: center;
  gap: .375rem;
  margin: 0;
  color: var(--tm-warning-text);
  font-size: var(--tm-text-caption);
  font-weight: 600;
  line-height: 1.45;
}

/* Pusty region zostaje w drzewie dostępności (ogłoszenie pojawienia się), bez dodatkowego odstępu siatki pola. */
.tm-field__caps:empty { margin-top: -.375rem; }

.tm-field__caps-icon {
  width: .875rem;
  height: .875rem;
  flex-shrink: 0;
}

.tm-textarea {
  height: auto;
  min-height: 6rem;
  padding: .625rem .875rem;
  line-height: var(--tm-leading-body);
  resize: vertical;
}

/* Natywna lista wyboru */
.tm-select-native {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tm-control.tm-select-native { display: flex; }

.tm-select-native select {
  width: 100%;
  appearance: none;
  padding-right: 2.25rem;
  cursor: pointer;
}

.tm-select-native--sm select {
  height: var(--tm-control-sm);
  padding: 0 2rem 0 .75rem;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm);
  background: var(--tm-paper);
  color: var(--tm-text);
  font: inherit;
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
}

.tm-select-native--sm select:focus-visible {
  border-color: var(--tm-primary);
  outline: none;
  box-shadow: var(--tm-focus-halo);
}

.tm-select-native__chevron {
  position: absolute;
  right: .75rem;
  width: 1rem;
  height: 1rem;
  color: var(--tm-text-2);
  pointer-events: none;
}

.tm-select-native--sm .tm-select-native__chevron { right: .5rem; width: .875rem; height: .875rem; }

/* Pole daty (DateInput): tekst dd.MM.yyyy niezależny od języka przeglądarki; pod ikoną kalendarza leży przezroczysty
   natywny input type="date", więc kliknięcie ikony otwiera kalendarz przeglądarki (klawiatura: wpisanie dnia). */
.tm-date {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.tm-date__input {
  min-width: 0;
  padding-right: 2.75rem;
  font-variant-numeric: tabular-nums;
}

.tm-date.has-prefix .tm-date__input { padding-left: 3.25rem; }

.tm-date__prefix {
  position: absolute;
  left: .875rem;
  z-index: 1;
  color: var(--tm-text-3);
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  pointer-events: none;
}

.tm-date__native {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  width: 2.75rem;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.tm-date__native::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.tm-date__native:disabled { cursor: not-allowed; }

.tm-date__icon {
  position: absolute;
  right: .875rem;
  width: 1rem;
  height: 1rem;
  color: var(--tm-text-2);
  pointer-events: none;
}

.tm-date:hover .tm-date__icon { color: var(--tm-primary-text); }
.tm-date__input:disabled ~ .tm-date__icon { color: var(--tm-text-disabled); }

/* Zakres dat: gotowe okresy (grupa segmentowa jak VLX PeriodBar), dwa pola „od” i „do”, nota o strefie doby. */
.tm-range {
  display: grid;
  gap: .625rem;
  container-type: inline-size;
}

.tm-range__presets {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
}

.tm-range__preset {
  height: var(--tm-control-sm);
  padding: 0 .75rem;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper);
  color: var(--tm-text-2);
  font: inherit;
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--tm-dur-fast) var(--tm-ease), background-color var(--tm-dur-fast) var(--tm-ease), color var(--tm-dur-fast) var(--tm-ease);
}

.tm-range__preset:hover:not(:disabled) {
  border-color: var(--tm-text-3);
  color: var(--tm-text);
}

.tm-range__preset[aria-pressed="true"] {
  border-color: rgb(var(--tm-primary-ch) / .35);
  background: var(--tm-primary-tonal-solid);
  color: var(--tm-primary-text);
}

.tm-range__preset:focus-visible {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: var(--tm-focus-offset);
}

.tm-range__preset:disabled {
  color: var(--tm-text-disabled);
  cursor: not-allowed;
}

.tm-range__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

@container (max-width: 25rem) {
  .tm-range__fields { grid-template-columns: minmax(0, 1fr); }
}

.tm-range__tz {
  display: flex;
  align-items: center;
  gap: .375rem;
  margin: 0;
  color: var(--tm-text-3);
  font-size: var(--tm-text-caption);
}

.tm-range__tz-icon {
  width: .875rem;
  height: .875rem;
  flex-shrink: 0;
}

/* Lista z wyszukiwaniem: combobox ARIA APG z listą (SelectField Searchable). */
.tm-combo {
  position: relative;
  display: flex;
  align-items: center;
}

.tm-combo__input { padding-right: 2.75rem; }

.tm-combo__toggle {
  position: absolute;
  right: .25rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: calc(100% - .5rem);
  border: 0;
  border-radius: var(--tm-radius-xs);
  background: transparent;
  color: var(--tm-text-2);
  cursor: pointer;
}

.tm-combo__toggle:hover:not(:disabled) { background: rgb(var(--tm-text-ch) / .06); }

.tm-combo__chevron {
  width: 1rem;
  height: 1rem;
  transition: transform var(--tm-dur-fast) var(--tm-ease);
}

.tm-combo.is-open .tm-combo__chevron { transform: rotate(180deg); }

.tm-combo__list {
  position: absolute;
  top: calc(100% + .375rem);
  right: 0;
  left: 0;
  z-index: var(--tm-z-overlay);
  max-height: 20rem;
  margin: 0;
  padding: .375rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-md);
  background: var(--tm-paper);
  box-shadow: var(--tm-shadow-overlay);
  list-style: none;
  animation: tm-combo-in var(--tm-dur-fast) var(--tm-ease-out);
}

@keyframes tm-combo-in { from { opacity: 0; transform: translateY(-4px); } }

.tm-combo__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 2.25rem;
  padding: .375rem .625rem;
  border-radius: var(--tm-radius-sm);
  color: var(--tm-text);
  font-size: var(--tm-text-body-sm);
  cursor: pointer;
}

.tm-combo__option:hover:not(.is-active) { background: rgb(var(--tm-text-ch) / .05); }

.tm-combo__option.is-active {
  background: var(--tm-primary-tonal-solid);
  color: var(--tm-primary-text);
}

.tm-combo__option.is-selected { font-weight: 600; }

.tm-combo__option[aria-disabled="true"] {
  color: var(--tm-text-disabled);
  cursor: not-allowed;
}

.tm-combo__check {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.tm-combo__empty {
  padding: .625rem;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

/* Pole wyboru, radio i przełącznik natywny */
.tm-checkbox,
.tm-radio__input {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--tm-primary);
  cursor: pointer;
}

.tm-check-field {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}

.tm-check-field .tm-checkbox { margin-top: .125rem; }

.tm-check-field__text {
  display: grid;
  gap: .125rem;
}

.tm-check-field__label {
  color: var(--tm-text);
  font-size: var(--tm-text-body-sm);
  font-weight: 500;
  cursor: pointer;
}

.tm-radio-group__options {
  display: grid;
  gap: .5rem;
}

.tm-radio-group--inline .tm-radio-group__options {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
}

.tm-radio {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  font-size: var(--tm-text-body-sm);
  cursor: pointer;
}

.tm-radio .tm-radio__input { margin-top: .125rem; }

.tm-radio__text { display: grid; gap: .125rem; }
.tm-radio__label { font-weight: 500; }
.tm-radio__desc { color: var(--tm-text-2); font-size: var(--tm-text-caption); }
.tm-radio.is-inactive { color: var(--tm-text-disabled); cursor: not-allowed; }

.tm-radio-group--cards .tm-radio-group__options {
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .75rem;
}

.tm-radio-group--cards .tm-radio {
  padding: .875rem 1rem;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-md);
  background: var(--tm-paper);
  transition: border-color var(--tm-dur-fast) var(--tm-ease), background-color var(--tm-dur-fast) var(--tm-ease);
}

.tm-radio-group--cards .tm-radio:hover { border-color: var(--tm-border-control); }

.tm-radio-group--cards .tm-radio.is-checked {
  border-color: var(--tm-primary);
  background: var(--tm-primary-tonal);
  box-shadow: inset 0 0 0 1px var(--tm-primary);
}

.tm-radio-group--cards .tm-radio:has(:focus-visible) {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: var(--tm-focus-offset);
}

.tm-switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .875rem 0;
}

.tm-switch-field__text {
  display: grid;
  gap: .125rem;
  min-width: 0;
}

.tm-switch-field__label {
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
  cursor: pointer;
}

.tm-switch-native {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.tm-switch-native input {
  position: absolute;
  inset: -.375rem;
  width: calc(100% + .75rem);
  height: calc(100% + .75rem);
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.tm-switch-native__track {
  display: inline-flex;
  align-items: center;
  width: 2.75rem;
  height: 1.5rem;
  padding: 0 .1875rem;
  border: 1px solid var(--tm-border-control);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper-3);
  transition: background-color var(--tm-dur) var(--tm-ease), border-color var(--tm-dur) var(--tm-ease);
}

.tm-switch-native__track .tm-switch__thumb {
  width: 1.125rem;
  height: 1.125rem;
  background: var(--tm-paper);
  box-shadow: 0 1px 2px rgb(var(--tm-text-ch) / .3);
}

.tm-switch-native input:checked + .tm-switch-native__track {
  border-color: var(--tm-primary);
  background: var(--tm-primary);
}

.tm-switch-native input:checked + .tm-switch-native__track .tm-switch__thumb {
  background: var(--tm-on-primary);
  transform: translateX(1.1875rem);
}

.tm-switch-native input:focus-visible + .tm-switch-native__track {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: var(--tm-focus-offset);
}

.tm-switch-native input:disabled + .tm-switch-native__track { opacity: .5; }

/* Sekcja formularza i stopka akcji */
.tm-form-section {
  container-type: inline-size;
  display: grid;
  gap: 1rem;
}

.tm-form-section + .tm-form-section {
  margin-top: .5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--tm-border-subtle);
}

.tm-form-section__title {
  margin: 0;
  font-size: var(--tm-text-h3);
  font-weight: 600;
}

.tm-form-section__desc {
  margin: .25rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

.tm-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.125rem 1.25rem;
}

.tm-form-grid--one,
.tm-form-grid > .tm-span-2,
.tm-form-grid > .tm-switch-field,
.tm-form-grid > .tm-radio-group--cards {
  grid-column: 1 / -1;
}

.tm-form-grid--one { grid-template-columns: minmax(0, 1fr); }

@container (max-width: 520px) {
  .tm-form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* The divider keeps its own distance from the last field: without margin-top a short last row (inline radios)
   sits on the line (R19-J). */
.tm-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--tm-border-subtle);
}

.tm-form-actions__end {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-left: auto;
}

.tm-form-actions--sticky {
  position: sticky;
  bottom: 0;
  z-index: var(--tm-z-sticky);
  margin: 1.5rem -1.5rem -1.5rem;
  padding: 1rem 1.5rem;
  border-radius: 0 0 var(--tm-radius-lg) var(--tm-radius-lg);
  background: rgb(var(--tm-paper-ch) / .94);
  backdrop-filter: blur(6px);
}

.tm-error-summary { margin-bottom: 1.25rem; }
.tm-error-summary:focus { outline: none; }

.tm-error-summary__list {
  margin: .375rem 0 0;
  padding-left: 1.125rem;
}

.tm-error-summary__list a { color: var(--tm-danger-text); font-weight: 500; }

@media (max-width: 599px) {
  .tm-form-actions__end { width: 100%; flex-direction: column-reverse; }
  .tm-form-actions__end .tm-btn { width: 100%; }
}

/* ==========================================================================
 * Okno dialogowe i szuflada (natywny <dialog> z showModal: TmModal, TmDialog, TmDrawer, TmConfirmDialog)
 * ======================================================================== */
html.tm-scroll-locked { overflow: hidden; }

.tm-dialog {
  display: none;
  width: 600px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-xl);
  background: var(--tm-paper);
  color: var(--tm-text);
  box-shadow: var(--tm-shadow-dialog);
  font-size: var(--tm-text-body);
}

.tm-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: tm-dialog-in var(--tm-dur) var(--tm-ease-out);
}

.tm-dialog.is-closing { animation: tm-dialog-out var(--tm-dur-fast) var(--tm-ease) forwards; }

.tm-dialog::backdrop {
  background: var(--tm-scrim);
  animation: tm-backdrop-in var(--tm-dur) var(--tm-ease-out);
}

.tm-dialog.is-closing::backdrop { animation: tm-backdrop-out var(--tm-dur-fast) var(--tm-ease) forwards; }

.tm-dialog:focus-visible { outline: none; }

.tm-dialog--confirm { width: 444px; }
.tm-dialog--wide { width: 900px; }

@keyframes tm-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes tm-dialog-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes tm-backdrop-in { from { opacity: 0; } }
@keyframes tm-backdrop-out { to { opacity: 0; } }

.tm-dialog__header {
  flex-shrink: 0;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--tm-border-subtle);
}

.tm-dialog__content {
  flex: 1;
  min-height: 0;
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tm-dialog__footer {
  flex-shrink: 0;
  padding: .875rem 1.5rem;
  border-top: 1px solid var(--tm-border-subtle);
  background: var(--tm-paper-2);
}

.tm-dialog__head {
  display: flex;
  align-items: flex-start;
  gap: .875rem;
}

.tm-dialog__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: var(--tm-radius-md);
}

.tm-dialog__svg { width: 1.125rem; height: 1.125rem; }

.tm-dialog__titles {
  display: grid;
  flex: 1;
  gap: .125rem;
  min-width: 0;
  padding-top: .25rem;
}

.tm-dialog__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: normal;
}

.tm-dialog__desc {
  margin: 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
  font-weight: 400;
  white-space: normal;
}

.tm-dialog__close { margin: -.25rem -.5rem 0 0; }

.tm-dialog__body {
  display: grid;
  gap: 1rem;
}

.tm-dialog__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .75rem;
}

.tm-confirm__text {
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
  line-height: var(--tm-leading-body-sm);
}

.tm-confirm__text strong { color: var(--tm-text); }

.tm-dialog.tm-drawer {
  width: 480px;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border-width: 0 0 0 1px;
  border-radius: var(--tm-radius-xl) 0 0 var(--tm-radius-xl);
}

.tm-dialog.tm-drawer--lg { width: 640px; }
.tm-dialog.tm-drawer[open] { animation-name: tm-drawer-in; animation-duration: var(--tm-dur-slow); }
.tm-dialog.tm-drawer.is-closing { animation: tm-drawer-out var(--tm-dur) var(--tm-ease) forwards; }

@keyframes tm-drawer-in { from { transform: translateX(100%); } }
@keyframes tm-drawer-out { to { transform: translateX(100%); } }

@media (max-width: 599px) {
  .tm-dialog { max-width: calc(100vw - 1rem); }

  .tm-dialog.tm-drawer,
  .tm-dialog.tm-drawer--lg {
    width: 100vw;
    max-width: 100vw;
    border-width: 0;
    border-radius: 0;
  }

  .tm-dialog__header,
  .tm-dialog__content,
  .tm-dialog__footer { padding-inline: 1rem; }

  .tm-dialog__foot { flex-direction: column-reverse; }
  .tm-dialog__foot .tm-btn { width: 100%; }
}

/* ==========================================================================
 * Wykres i mapa
 * ======================================================================== */
.tm-tabular { font-variant-numeric: tabular-nums; }

/* Kolory serii: wyłącznie tokeny; ta sama klasa barwi linię, gradient, kolumnę, punkt, wycinek i próbkę legendy. */
.tm-series--primary { --series: var(--tm-primary); }
.tm-series--sioptak { --series: var(--tm-brand-sioptak); }
.tm-series--success { --series: var(--tm-success); }
.tm-series--warning { --series: var(--tm-warning); }
.tm-series--danger { --series: var(--tm-danger); }
.tm-series--neutral { --series: var(--tm-neutral); }
[data-theme="dark"] .tm-series--neutral { --series: var(--tm-text-3); }

.tm-chart-card .tm-card__body { container-type: inline-size; }

.tm-chart-card__headline {
  margin-bottom: .75rem;
}

.tm-chart {
  display: grid;
  gap: .75rem;
  margin: 0;
}

.tm-chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  margin: 0;
  padding: 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-caption);
  font-weight: 600;
  list-style: none;
}

.tm-chart__legend li {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
}

.tm-chart__swatch {
  display: inline-block;
  width: .625rem;
  height: .625rem;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--series);
}

/* Siatka: kolumna etykiet osi wartości (szerokość ze znaków najdłuższej etykiety, bez pomiaru) i obszar wykresu;
   pod nim etykiety kategorii. Prawy margines mieści połowę ostatniego punktu. */
.tm-chart__frame {
  display: grid;
  grid-template-columns: var(--chart-y-w) minmax(0, 1fr);
  grid-template-rows: calc(var(--chart-h) - 2.25rem) 2.25rem;
  column-gap: .75rem;
  padding: .5rem .5rem 0 0;
  /* The hover band of the first and last point reaches half a band past the plot; without the clip a wide card with few
     points pushed the page into horizontal scroll. The right padding keeps the edge marker whole; tooltips flip inwards. */
  overflow-x: clip;
}

.tm-chart__y {
  position: relative;
  color: var(--tm-text-3);
  font-size: var(--tm-text-caption);
  font-variant-numeric: tabular-nums;
}

.tm-chart__y span {
  position: absolute;
  right: 0;
  line-height: 1;
  white-space: nowrap;
  transform: translateY(-50%);
}

.tm-chart__plot {
  position: relative;
  border-radius: var(--tm-radius-xs);
}

.tm-chart__plot:focus-visible {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: 6px;
}

.tm-chart__grid span {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--tm-border-subtle);
}

.tm-chart__grid span.is-base { border-top: 1px solid var(--tm-border); }

.tm-chart__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tm-chart__line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tm-chart--line .tm-chart__line { stroke-width: 2.75; }

/* Gradient obszaru: od .3 pod linią do lekkiego tonu przy osi, więc także niskie, gęste serie (trendy godzinowe) mają
   widoczne wypełnienie. */
.tm-chart__stop-top { stop-color: var(--series); stop-opacity: .32; }
.tm-chart__stop-bottom { stop-color: var(--series); stop-opacity: .06; }
[data-theme="dark"] .tm-chart__stop-top { stop-opacity: .4; }
[data-theme="dark"] .tm-chart__stop-bottom { stop-opacity: .08; }

.tm-chart__x {
  position: relative;
  grid-column: 2;
  color: var(--tm-text-3);
  font-size: var(--tm-text-caption);
  font-variant-numeric: tabular-nums;
}

.tm-chart__x span {
  position: absolute;
  top: .75rem;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

.tm-chart__x span.is-first { transform: none; }
.tm-chart__x span.is-last { transform: translateX(-100%); }

@container (max-width: 30rem) {
  .tm-chart__x span.is-alt { display: none; }
  /* Labels with a day and an hour ("19.11 08:00") fit a phone only at the two ends of the axis. */
  .tm-chart-card--long-x .tm-chart__x span:not(.is-first):not(.is-last) { display: none; }
}

/* Day-and-hour labels need about 4.5 rem each: a card of a page column keeps every second one (no touching labels). */
@container (max-width: 56rem) {
  .tm-chart-card--long-x .tm-chart__x span.is-alt { display: none; }
}

/* Strefa punktu: pas pod najechanie z prowadnicą, punktami serii i dymkiem; strzałki z klawiatury aktywują ten sam pas. */
.tm-chart__hit {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
}

.tm-chart__hit:hover,
.tm-chart__hit.is-active { z-index: 2; }

.tm-chart__guide {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 1px solid var(--tm-border);
  opacity: 0;
  transition: opacity var(--tm-dur-fast) var(--tm-ease);
}

.tm-chart__dot {
  position: absolute;
  left: 50%;
  width: .6875rem;
  height: .6875rem;
  margin: -.34375rem 0 0 -.34375rem;
  border: 2px solid var(--series);
  border-radius: var(--tm-radius-pill);
  background: var(--tm-paper);
  opacity: 0;
  transition: opacity var(--tm-dur-fast) var(--tm-ease), transform var(--tm-dur-fast) var(--tm-ease);
}

.tm-chart__hit.has-markers .tm-chart__dot { opacity: 1; }

.tm-chart__hit:hover .tm-chart__guide,
.tm-chart__hit.is-active .tm-chart__guide { opacity: 1; }

.tm-chart__hit:hover .tm-chart__dot,
.tm-chart__hit.is-active .tm-chart__dot {
  border-color: var(--tm-paper);
  background: var(--series);
  box-shadow: 0 0 0 2px var(--series);
  opacity: 1;
  transform: scale(1.15);
}

.tm-chart__bars {
  position: absolute;
  inset: 0 16%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}

.tm-chart__bar {
  flex: 0 1 2.5rem;
  min-width: 3px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(to top, color-mix(in srgb, var(--series) 78%, var(--tm-paper)), var(--series));
  transition: filter var(--tm-dur-fast) var(--tm-ease);
}

.tm-chart--column .tm-chart__hit:hover,
.tm-chart--column .tm-chart__hit.is-active {
  border-radius: var(--tm-radius-sm);
  background: rgb(var(--tm-text-ch) / .045);
}

.tm-chart__hit:hover .tm-chart__bar,
.tm-chart__hit.is-active .tm-chart__bar { filter: saturate(1.15) brightness(1.06); }

.tm-chart__tip {
  position: absolute;
  top: .25rem;
  left: calc(50% + .75rem);
  z-index: 3;
  display: none;
  gap: .25rem;
  min-width: 9rem;
  padding: .5rem .75rem;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-md);
  background: var(--tm-paper);
  box-shadow: var(--tm-shadow-overlay);
  color: var(--tm-text);
  font-size: var(--tm-text-caption);
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
}

.tm-chart__hit.is-end .tm-chart__tip {
  left: auto;
  right: calc(50% + .75rem);
}

.tm-chart__hit:hover .tm-chart__tip,
.tm-chart__hit.is-active .tm-chart__tip { display: grid; }

.tm-chart__tip-title {
  color: var(--tm-text-2);
  font-weight: 600;
}

.tm-chart__tip-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.tm-chart__tip-row strong {
  margin-left: auto;
  padding-left: .75rem;
  font-weight: 700;
}

/* Wykres pierścieniowy: wycinki z kreski koła (pathLength 100), środek z sumą, legenda z wartością i udziałem. */
.tm-donut {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  align-items: center;
  gap: 1.5rem;
  min-height: calc(var(--chart-h) - 2rem);
  margin: 0;
}

.tm-donut__ring {
  position: relative;
  width: 100%;
  max-width: 13rem;
  aspect-ratio: 1;
  justify-self: center;
}

.tm-donut__ring svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.tm-donut__track,
.tm-donut__slice {
  fill: none;
  stroke-width: 13;
}

.tm-donut__track { stroke: var(--tm-paper-3); }

.tm-donut__slice {
  stroke: var(--series);
  stroke-linecap: butt;
  transition: stroke-width var(--tm-dur-fast) var(--tm-ease);
}

.tm-donut__slice:hover { stroke-width: 16; }

.tm-donut__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: .125rem;
  text-align: center;
}

.tm-donut__center strong {
  color: var(--tm-text);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: var(--tm-tracking-kpi);
}

.tm-donut__center span {
  color: var(--tm-text-3);
  font-size: var(--tm-text-overline);
  font-weight: 700;
  letter-spacing: var(--tm-tracking-overline);
  text-transform: uppercase;
}

.tm-donut__legend {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tm-donut__legend li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto 3rem;
  align-items: center;
  gap: .625rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--tm-border-subtle);
  font-size: var(--tm-text-body-sm);
}

.tm-donut__legend li:last-child { border-bottom: 0; }

.tm-donut__name {
  overflow: hidden;
  color: var(--tm-text);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-donut__value { font-weight: 600; text-align: right; }
.tm-donut__share { color: var(--tm-text-3); text-align: right; }

@container (max-width: 28rem) {
  .tm-donut { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .tm-donut__ring { max-width: 11rem; }
}

.tm-chart-card .tm-card__body > .tm-registry__scroll {
  margin: 0 -1.5rem;
  border-top: 0;
}

/* Stan widżetu (MamTaxi widget-state): ładowanie w kształcie i wysokości widżetu, pusty, brak uprawnień, błąd. */
.tm-widget-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .625rem;
  min-height: var(--widget-h, 12rem);
  padding: 1.5rem 1rem;
  text-align: center;
}

.tm-widget-state--loading {
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 0;
}

.tm-widget-state__skeleton {
  height: calc(var(--widget-h, 12rem) - 2.5rem);
}

.tm-widget-state__skeleton--chart {
  display: flex;
  align-items: flex-end;
  gap: 5%;
  padding: 1rem .5rem 0 2.5rem;
  border-bottom: 1px solid var(--tm-border-subtle);
}

.tm-widget-state__bar {
  flex: 1;
  border-radius: 6px 6px 2px 2px;
}

.tm-widget-state__block {
  display: block;
  height: 100%;
  border-radius: var(--tm-radius-md);
}

.tm-widget-state__text {
  max-width: 32rem;
  margin: 0;
  color: var(--tm-text);
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
}

.tm-widget-state__hint {
  margin: -.25rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-caption);
}

.tm-map {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.tm-map--with-list {
  grid-template-columns: minmax(0, 1fr) 17rem;
}

.tm-map__canvas {
  position: relative;
  height: 26.25rem;
  overflow: hidden;
  isolation: isolate;
  background: var(--tm-paper-2);
}

.tm-map__surface,
.tm-map__surface.leaflet-container {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--tm-paper-2);
  font-family: var(--tm-font-sans);
}

/* Leaflet bierze fokus mapy (klawisze przesuwania i powiększenia); pierścień w środku, bo karta przycina krawędź. */
.tm-map__surface:focus-visible,
.tm-map__surface .leaflet-marker-icon:focus-visible {
  outline: var(--tm-focus-width) solid var(--tm-focus);
  outline-offset: calc(var(--tm-focus-width) * -1);
}

.tm-map__surface .leaflet-marker-icon:focus-visible { outline-offset: 2px; border-radius: var(--tm-radius-pill); }

/* Tryb ciemny: te same kafle OpenStreetMap jako ciemna mapa (odwrócenie jasności z zachowaniem odcieni). */
[data-theme="dark"] .tm-map__surface .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55);
}

.tm-map__surface.leaflet-container .leaflet-control-zoom,
.tm-map__surface.leaflet-container .tm-map-all {
  overflow: hidden;
  border: 1px solid var(--tm-border-control);
  border-radius: var(--tm-radius-sm);
  box-shadow: var(--tm-shadow-overlay);
}

.tm-map__surface.leaflet-container .leaflet-bar a {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-bottom: 1px solid var(--tm-border-subtle);
  background: var(--tm-paper);
  color: var(--tm-text-2);
  font: 600 1.125rem/1 var(--tm-font-sans);
  transition: background-color var(--tm-dur-fast) var(--tm-ease), color var(--tm-dur-fast) var(--tm-ease);
}

.tm-map__surface.leaflet-container .leaflet-bar a:last-child { border-bottom: 0; }

.tm-map__surface.leaflet-container .leaflet-bar a:hover,
.tm-map__surface.leaflet-container .leaflet-bar a:focus-visible {
  background: var(--tm-primary-tonal-solid);
  color: var(--tm-primary-text);
}

.tm-map__surface.leaflet-container .leaflet-bar a.leaflet-disabled { color: var(--tm-text-disabled); background: var(--tm-paper); }

.tm-map__surface .tm-map-all svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tm-map__surface.leaflet-container .leaflet-control-attribution {
  padding: .125rem .5rem;
  border-top-left-radius: var(--tm-radius-xs);
  background: rgb(var(--tm-paper-ch) / .86);
  color: var(--tm-text-2);
  font-size: .6875rem;
}

.tm-map__surface.leaflet-container .leaflet-control-attribution a { color: var(--tm-primary-text); }

.tm-map-pin-host { background: none; border: 0; }

.tm-map-pin {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid var(--tm-paper);
  border-radius: var(--tm-radius-pill);
  background: var(--tone);
  box-shadow: 0 0 0 1px rgb(var(--tm-ink-ch) / .18), 0 4px 10px -2px rgb(var(--tm-ink-ch) / .35);
  transition: transform var(--tm-dur-fast) var(--tm-ease);
}

.leaflet-marker-icon:hover .tm-map-pin,
.leaflet-marker-icon:focus-visible .tm-map-pin { transform: scale(1.2); }

.tm-map-cluster {
  display: grid;
  place-items: center;
  border: 3px solid var(--tm-paper);
  border-radius: var(--tm-radius-pill);
  background: var(--tone);
  box-shadow: 0 0 0 5px rgb(from var(--tone) r g b / .28), 0 6px 14px -4px rgb(var(--tm-ink-ch) / .4);
  color: var(--tm-on-status-strong);
  font-size: var(--tm-text-body-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tm-map-pin--neutral { --tone: var(--tm-neutral); }
.tm-map-pin--primary, .tm-map-pin--info { --tone: var(--tm-primary); }
.tm-map-pin--success { --tone: var(--tm-success); }
.tm-map-pin--warning { --tone: var(--tm-warning); }
.tm-map-pin--danger { --tone: var(--tm-danger); }

/* Grupa: wypełnienie mocne statusu z tekstem on-status-strong (para z kontrastem AA w obu trybach, tokens.css). */
.tm-map-cluster--neutral { --tone: var(--tm-neutral-text); }
.tm-map-cluster--success { --tone: var(--tm-success-text); }
.tm-map-cluster--warning { --tone: var(--tm-warning-text); }
.tm-map-cluster--danger { --tone: var(--tm-danger-text); }
.tm-map-cluster--primary, .tm-map-cluster--info { --tone: var(--tm-primary); color: var(--tm-on-primary); }

.leaflet-tooltip.tm-map-tooltip {
  padding: .5rem .75rem;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-md);
  background: var(--tm-paper);
  box-shadow: var(--tm-shadow-overlay);
  color: var(--tm-text);
  font: 400 var(--tm-text-caption)/1.4 var(--tm-font-sans);
}

.leaflet-tooltip.tm-map-tooltip span { color: var(--tm-text-2); }
.leaflet-tooltip-top.tm-map-tooltip::before { border-top-color: var(--tm-paper); }

.tm-map__state { min-height: 20rem; }

.tm-map__legend {
  position: absolute;
  bottom: .75rem;
  left: .75rem;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: .375rem .875rem;
  margin: 0;
  padding: .375rem .75rem;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-pill);
  background: rgb(var(--tm-paper-ch) / .94);
  box-shadow: var(--tm-shadow-overlay);
  font-size: var(--tm-text-caption);
  font-weight: 600;
  list-style: none;
}

.tm-map__legend li {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
}

.tm-map__legend .tm-chip__dot { background: var(--tone); }

.tm-map__legend-count { color: var(--tm-text-3); font-variant-numeric: tabular-nums; }

/* Q33 map lines and trip tables. */
.tm-map__surface path.tm-map-route-casing { stroke: var(--tm-paper); fill: none; }
.tm-map__surface path.tm-map-route { stroke: var(--tone); fill: none; }
.tm-map__surface path.tm-map-route-dot { stroke: var(--tm-paper); fill: var(--tone); fill-opacity: 1; }
.tm-map__legend-line { display: inline-block; width: 1.25rem; height: .25rem; border-radius: var(--tm-radius-pill); background: var(--tone); }
.tm-map-end { display: block; width: 1.125rem; height: 1.125rem; border-radius: var(--tm-radius-pill); box-shadow: 0 0 0 1px rgb(var(--tm-ink-ch) / .18); }
.tm-map-end--start { border: 4px solid var(--tm-success); background: var(--tm-paper); }
.tm-map-end--end { border: 3px solid var(--tm-paper); background: var(--tm-text); }
.tm-statistics-table th[scope="row"] { font-weight: 600; white-space: nowrap; }
.tm-statistics-table .is-end, .tm-trips-registry td.is-end { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tm-statistics-table__total > * { background: var(--tm-paper-2); font-weight: 700; }
.tm-statistics-scroll { container-type: inline-size; }
@container (max-width: 599px) {
  .tm-table.tm-statistics-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tm-table.tm-statistics-table, .tm-table.tm-statistics-table tbody { display: block; }
  .tm-table.tm-statistics-table tbody tr { display: grid; gap: .25rem; padding: .75rem 1rem; border-bottom: 1px solid var(--tm-border-subtle); }
  .tm-table.tm-statistics-table tbody :is(th, td) { height: auto; padding: 0; border: 0; }
  .tm-table.tm-statistics-table tbody td { display: flex; justify-content: space-between; gap: .5rem; }
  .tm-table.tm-statistics-table tbody td::before { content: attr(data-label); color: var(--tm-text-2); }
}

/* Scroll regions take keyboard focus (WCAG 2.1.1); the ring sits inside, because the card clips its overflow. */
.tm-registry__scroll:focus-visible,
.tm-map__list:focus-visible {
  outline-offset: calc(var(--tm-focus-width) * -1);
}

.tm-map__list {
  max-height: 26.25rem;
  margin: 0;
  padding: .5rem 0;
  overflow-y: auto;
  border-left: 1px solid var(--tm-border-subtle);
  list-style: none;
}

.tm-map__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .125rem .5rem;
  align-items: center;
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--tm-border-subtle);
}

.tm-map__item:last-child { border-bottom: 0; }

.tm-map__item-title {
  font-size: var(--tm-text-body-sm);
  font-weight: 600;
}

.tm-map__item-detail {
  grid-row: 2;
  color: var(--tm-text-2);
  font-size: var(--tm-text-caption);
}

.tm-map__item .tm-chip { grid-row: 1 / span 2; grid-column: 2; }

.tm-map__foot {
  padding: .875rem 1.5rem;
  border-top: 1px solid var(--tm-border-subtle);
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

@media (max-width: 899px) {
  .tm-map--with-list { grid-template-columns: minmax(0, 1fr); }
  .tm-map__list { max-height: 15rem; border-top: 1px solid var(--tm-border-subtle); border-left: 0; }
}

@media (max-width: 599px) {
  .tm-map__canvas { height: 20rem; }
}

/* ==========================================================================
 * Galeria /dev/wyglad (tylko Development)
 * ======================================================================== */
.tm-gallery {
  min-height: 100dvh;
  background: var(--tm-canvas);
  color: var(--tm-text);
}

.tm-gallery__bar {
  position: sticky;
  top: 0;
  z-index: var(--tm-z-topbar);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  padding: .75rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--tm-border-subtle);
  background: rgb(var(--tm-paper-ch) / .92);
  backdrop-filter: blur(8px);
}

.tm-gallery__brand {
  display: grid;
  gap: .125rem;
}

.tm-gallery__brand strong { font-size: 1.0625rem; }
.tm-gallery__brand span { color: var(--tm-text-2); font-size: var(--tm-text-caption); }

.tm-gallery__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}

.tm-gallery__main {
  display: grid;
  gap: 1.5rem;
  max-width: var(--tm-layout-panel-max);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 4rem;
}

.tm-gallery__section-title {
  margin: 1.5rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-overline);
  font-weight: 700;
  letter-spacing: var(--tm-tracking-overline);
  text-transform: uppercase;
}

.tm-gallery__h1 {
  margin: 0;
  font-size: var(--tm-text-h1);
  font-weight: 700;
  letter-spacing: var(--tm-tracking-h1);
}

.tm-gallery__lead {
  margin: .25rem 0 0;
  color: var(--tm-text-2);
  font-size: var(--tm-text-body-sm);
}

.tm-gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1.5rem;
}

.tm-gallery__grid--two {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 32rem), 1fr));
}

.tm-gallery__grid--wide {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

@media (max-width: 1023px) {
  .tm-gallery__grid--two {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 32rem), 1fr));
}

.tm-gallery__grid--wide { grid-template-columns: minmax(0, 1fr); }
}

.tm-gallery__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}

.tm-gallery__row + .tm-gallery__row { margin-top: 1rem; }

.tm-gallery__label {
  width: 100%;
  color: var(--tm-text-3);
  font-size: var(--tm-text-caption);
  font-weight: 600;
}

.tm-gallery__stack {
  display: grid;
  gap: .75rem;
}

.tm-gallery__frame {
  padding: 1.25rem;
  border: 1px dashed var(--tm-border);
  border-radius: var(--tm-radius-lg);
  background: var(--tm-paper-2);
}

.tm-gallery__identity {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.tm-gallery__identity-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  background: var(--tm-paper-2);
  color: var(--tm-text-2);
}

.tm-gallery__identity-icon svg { width: 1rem; height: 1rem; }

.tm-gallery__identity-text { display: grid; gap: .125rem; }
.tm-gallery__identity-sub { color: var(--tm-text-2); font-size: var(--tm-text-caption); font-weight: 400; }

.tm-gallery__headline {
  display: flex;
  align-items: baseline;
  gap: .5rem;
}

.tm-gallery__headline strong {
  font-size: 1.75rem;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
 * Ograniczony ruch i wymuszone kolory
 * ======================================================================== */
@media (prefers-reduced-motion: reduce) {
  .tm-skel::after,
  .tm-spinner { animation: none; }
  .tm-pop:popover-open,
  .tm-toast,
  .tm-dialog[open],
  .tm-dialog.is-closing,
  .tm-dialog::backdrop { animation: none; }
  .tm-kpi--link:hover,
  .tm-btn:active:not(.is-inactive):not(:disabled) { transform: none; }
}

@media (forced-colors: active) {
  .tm-card, .tm-kpi, .tm-registry, .tm-pop, .tm-toast, .tm-dialog, .tm-input, .tm-search__input, .tm-filter-chip, .tm-chip {
    border: 1px solid CanvasText;
  }

  .tm-check.is-checked, .tm-check.is-mixed, .tm-switch[aria-checked="true"], .tm-page-btn.is-current, .tm-table tbody tr.is-selected td {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }

  .tm-chip__dot, .tm-dot--neutral, .tm-dot--success, .tm-dot--warning, .tm-dot--danger, .tm-dot--info, .tm-dot--primary {
    background: CanvasText;
  }

  /* Fields show focus with a halo (box-shadow) and outline: none; forced colors drops box-shadow, so a focused field
     looked unfocused (R19-I, WCAG 2.4.7). The guard wins over every field rule, also in site.css and shell.css. */
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  .tm-palette__search:focus-within {
    outline: 2px solid Highlight !important;
    outline-offset: 2px !important;
  }

  /* Stan zaznaczenia bez tła (wymuszone kolory usuwają tła): obrys systemowy. */
  .tm-combo__option.is-active,
  .tm-range__preset[aria-pressed="true"],
  .tm-chart__hit.is-active .tm-chart__tip {
    outline: 2px solid Highlight;
  }

  .tm-chart__bar,
  .tm-chart__swatch,
  .tm-map-pin,
  .tm-map-cluster { forced-color-adjust: none; }
}
