/*
 * Mobilny Mechanik SSP — design system.
 * Keeps the legacy look (dark UI, RAL 1028 accent #FF9B00, sidebar for the office, bottom bar on phones)
 * with consistent spacing, accessible contrast (WCAG 2.2 AA), visible focus and 44 px touch targets.
 * No inline styles anywhere (CSP style-src 'self').
 */

:root {
  color-scheme: dark;

  --c-bg: #0b0f13;
  --c-bg-glow: #18242e;
  --c-surface: #141b22;
  --c-surface-2: #1b232c;
  --c-surface-3: #232d38;
  --c-border: #2b3641;
  --c-border-strong: #3d4a57;
  --c-text: #f2f5f8;
  --c-text-muted: #a3afba;
  --c-text-subtle: #7d8a96;
  /* Subtle text on raised surfaces (surface-2/3), AA for small text (G3). */
  --c-text-subtle-on-raised: #929fab;
  /* Input boundaries >= 3:1 against cards (WCAG 1.4.11, G4). */
  --c-input-border: #66727e;

  --c-accent: #ff9b00;
  --c-accent-hover: #ffae2e;
  --c-accent-text: #111111;
  --c-accent-soft: rgb(255 155 0 / 12%);
  --g-accent: linear-gradient(135deg, #ff8a00, #ffae24);

  --c-success: #34d399;
  --c-success-soft: rgb(52 211 153 / 12%);
  --c-warning: #fbbf24;
  --c-warning-soft: rgb(251 191 36 / 12%);
  --c-danger: #f87171;
  --c-danger-strong: #dc2626;
  --c-danger-soft: rgb(248 113 113 / 12%);
  --c-info: #60a5fa;
  --c-info-soft: rgb(96 165 250 / 12%);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 12px 32px rgb(0 0 0 / 35%);
  --shadow-lg: 0 30px 80px rgb(0 0 0 / 55%);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --sidebar-width: 264px;
  --topbar-height: 64px;
  --bottom-nav-height: 68px;
  --touch: 44px;

  /* Stacking: drawer 50/60, bottom nav 40. */
  --z-menu: 30;
  --z-toast: 70;
  --z-dialog: 80;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

/* ---------- Base ---------- */

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

[hidden]:not([hidden="until-found"]) {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchors and focused fields never land under the sticky topbar (G7, WCAG 2.4.11). */
  scroll-padding-top: calc(var(--topbar-height) + var(--space-3));
}

@media (max-width: 720px) {
  html {
    scroll-padding-top: calc(var(--topbar-height) + 3.25rem);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  line-height: 1.25;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--c-accent);
  text-underline-offset: 3px;
}

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

code,
kbd,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

small,
.text-muted {
  color: var(--c-text-muted);
}

.text-subtle {
  color: var(--c-text-subtle);
}

:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--c-accent);
  color: var(--c-accent-text);
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.skip-link:focus {
  top: var(--space-3);
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.25em;
}

/* ---------- Application shell ---------- */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-3) var(--space-4);
  background: linear-gradient(180deg, #0f1317, #171b20);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--c-border);
  color: inherit;
  text-decoration: none;
  text-align: center;
}

.sidebar__brand:hover {
  color: inherit;
}

.sidebar__logo {
  width: 168px;
  max-width: 100%;
  height: auto;
}

.sidebar__brand strong {
  display: block;
  font-size: 1.05rem;
}

.sidebar__brand small {
  display: block;
  font-size: 0.8rem;
}

.nav {
  display: grid;
  gap: var(--space-1);
}

.nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: #e6eaee;
  font-weight: 600;
  text-decoration: none;
}

.nav__link:hover {
  background: var(--c-surface-2);
  color: #ffffff;
}

.nav__link.is-active {
  background: var(--g-accent);
  border-color: #ffb545;
  color: var(--c-accent-text);
  box-shadow: 0 8px 25px rgb(255 157 0 / 12%);
}

.nav__link .badge {
  margin-left: auto;
}

/* MT-12: a badge on the active (accent) item gets the dark surface behind it, so it stays readable; its tone
   (border and text colour of .badge--warning / --danger / --info) is kept (CR-15). */
.nav__link.is-active .badge {
  background: var(--c-surface);
}

.sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--c-border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

.user-card:hover {
  background: var(--c-surface-2);
  color: inherit;
}

.user-card__text {
  min-width: 0;
  display: grid;
}

.user-card__text strong,
.user-card__text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border-strong);
  color: var(--c-accent);
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.avatar--lg {
  width: 64px;
  height: 64px;
  font-size: 1.3rem;
}

.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  background: rgb(11 15 19 / 88%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
}

.topbar__title {
  min-width: 0;
}

.topbar__title h1 {
  margin: 0;
  font-size: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__title small {
  display: block;
}

.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar .topbar__menu {
  display: none;
}

.content {
  width: 100%;
  padding: var(--space-5);
  flex: 1;
  overflow-wrap: anywhere;
}

.sidebar-backdrop {
  display: none;
}

.bottom-nav {
  display: none;
}

/* Phones and small tablets: off-canvas sidebar + bottom navigation (legacy technician layout). */
@media (max-width: 960px) {
  html:has(.bottom-nav) {
    scroll-padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + var(--space-3));
  }

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease, visibility 0s;
  }

  body.drawer-open {
    overflow: hidden;
  }

  .sidebar-backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgb(0 0 0 / 55%);
  }

  .topbar {
    padding: var(--space-2) var(--space-3);
  }

  .topbar .topbar__menu {
    display: inline-flex;
  }

  .topbar__user {
    display: none;
  }

  .content {
    padding: var(--space-4) var(--space-3) calc(var(--bottom-nav-height) + var(--space-5) + env(safe-area-inset-bottom));
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
    background: rgb(11 15 19 / 96%);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--c-border);
  }

  .bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--touch);
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: #8f9ca8;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
  }

  .bottom-nav__item .icon {
    width: 24px;
    height: 24px;
  }

  .bottom-nav__item.is-active {
    color: var(--c-accent);
    background: var(--c-accent-soft);
  }
}

@media (max-width: 720px) {
  /* MT-09: long titles wrap, but at most to two lines, so the sticky top bar does not cover a quarter of the phone
     screen (a long customer name took four lines). The full name is the page heading below. */
  .topbar__title h1 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Authentication layout (legacy technician login) ---------- */

.auth {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5) var(--space-3);
  overflow: hidden;
  background: radial-gradient(circle at 50% 10%, #213340 0, #0b1218 38%, #06090c 78%);
}

.auth::before {
  content: "";
  position: absolute;
  top: -200px;
  left: 50%;
  width: 460px;
  height: 460px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgb(255 157 0 / 9%);
  filter: blur(60px);
  pointer-events: none;
}

.auth__card {
  position: relative;
  width: min(440px, 100%);
  padding: var(--space-6) var(--space-5);
  background: rgb(14 21 27 / 95%);
  border: 1px solid #2a353e;
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.auth__card--wide {
  width: min(560px, 100%);
}

.auth__header {
  text-align: center;
  margin-bottom: var(--space-5);
}

.auth__logo {
  width: 200px;
  max-width: 70%;
  height: auto;
  margin-bottom: var(--space-3);
}

.auth__header h1 {
  margin-bottom: var(--space-1);
  font-size: 1.6rem;
}

.auth__header p {
  margin: 0;
  color: var(--c-text-muted);
}

.auth__footer {
  margin-top: var(--space-5);
  text-align: center;
  color: var(--c-text-subtle);
  font-size: 0.8rem;
}

.auth__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-4);
  font-size: 0.92rem;
}

/* ---------- Layout helpers ---------- */

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.stack--sm {
  gap: var(--space-2);
}

.stack--lg {
  gap: var(--space-5);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.cluster--end {
  justify-content: flex-end;
}

.cluster--between {
  justify-content: space-between;
}

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.grid--start {
  align-items: start;
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(380px, calc(50% - var(--space-4) / 2))), 1fr));
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.page-header p {
  margin: 0;
  color: var(--c-text-muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  color: var(--c-text-muted);
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  color: var(--c-text);
}

/* ---------- Cards ---------- */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--space-5);
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.card__header h2,
.card__header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card__header p {
  margin: var(--space-1) 0 0;
  color: var(--c-text-muted);
  font-size: 0.92rem;
}

.card--flush .card__header {
  padding: var(--space-4) var(--space-5) 0;
}

.card--danger {
  border-color: rgb(248 113 113 / 35%);
}

.tile {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-4);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

a.tile {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

a.tile:hover {
  color: inherit;
  border-color: rgb(255 155 0 / 55%);
  background: var(--c-surface-3);
}

.tile__icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--c-accent-soft);
  color: var(--c-accent);
}

.tile__icon--ok {
  background: var(--c-success-soft);
  color: var(--c-success);
}

.tile__icon--warn {
  background: var(--c-warning-soft);
  color: var(--c-warning);
}

.tile__icon--danger {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

.tile h3 {
  margin: 0 0 var(--space-1);
}

.tile p {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.92rem;
}

.tile p.text-warning,
.text-warning {
  color: var(--c-warning);
}

.tile h2 {
  margin: 0 0 var(--space-1);
  font-size: 1.05rem;
}

/* K1: stretched tile. The title link covers the card; secondary links sit above it. */
.tile--stretched {
  position: relative;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.tile--stretched:hover {
  border-color: rgb(255 155 0 / 55%);
  background: var(--c-surface-3);
}

.tile--stretched:focus-within {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.tile__body {
  min-width: 0;
  flex: 1;
}

.tile__link {
  color: inherit;
  text-decoration: none;
}

.tile__link:focus-visible {
  outline: none;
}

.tile__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.tile__title-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.tile .tile__summary {
  margin-top: var(--space-2);
  color: var(--c-text);
}

.tile__meta-links {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--space-1);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.tile__meta-links li {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* K2: reorder control (move up / down buttons, each its own form). */
.reorder {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
}

.reorder__text {
  display: none;
}

@media (max-width: 720px) {
  .reorder__text {
    display: inline;
  }

  /* With the "Wyżej"/"Niżej" text the button is no longer a square icon button (it broke the words letter by letter). */
  .reorder .btn--icon {
    width: auto;
    min-width: var(--touch);
    padding: 0 var(--space-3);
    white-space: nowrap;
  }
}

/* K6: week grid (days with hours). */
.week-grid__day {
  display: grid;
  grid-template-columns: minmax(10rem, max-content) repeat(2, minmax(0, 9rem)) minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  align-items: end;
  padding: var(--space-2) 0;
  border-top: 1px solid var(--c-border);
}

.week-grid__day:first-of-type {
  border-top: 0;
}

.week-grid__toggle {
  align-self: center;
  font-weight: 600;
}

.week-grid__time {
  margin: 0;
}

.week-grid__error {
  align-self: center;
  margin: 0;
}

.week-grid__day:has(.week-grid__toggle input:not(:checked)) .week-grid__time label {
  color: var(--c-text-muted);
}

@media (max-width: 720px) {
  .week-grid__day {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .week-grid__toggle,
  .week-grid__error {
    grid-column: 1 / -1;
  }
}

/* K9: newly added row. */
.table tr.is-new > :first-child {
  box-shadow: inset 3px 0 0 var(--c-accent);
}

/* K5: conflict notice under a field. */
.field__conflict {
  margin: var(--space-1) 0 0;
  color: var(--c-warning);
  font-size: 0.86rem;
}

.field__conflict .icon {
  vertical-align: -0.15em;
}

.history-entry__record {
  margin: 0 0 var(--space-1);
  font-weight: 700;
}

.settings-alert-link {
  margin-top: var(--space-2);
}

.definition {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: var(--space-2) var(--space-5);
  margin: 0;
}

.definition dt {
  color: var(--c-text-muted);
}

.definition dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .definition {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .definition dd {
    margin-bottom: var(--space-3);
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface-3);
  color: var(--c-text);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.12s ease, background-color 0.12s ease;
}

.btn:hover {
  color: var(--c-text);
  filter: brightness(1.12);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

.btn--primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: var(--c-accent-text);
}

.btn--primary:hover {
  color: var(--c-accent-text);
}

.btn--danger {
  background: var(--c-danger-strong);
  border-color: var(--c-danger-strong);
  color: #ffffff;
}

.btn--danger:hover {
  color: #ffffff;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--c-text-muted);
}

.btn--ghost:hover {
  background: var(--c-surface-2);
}

.btn--outline-danger {
  background: transparent;
  border-color: rgb(248 113 113 / 45%);
  color: var(--c-danger);
}

.btn--outline-danger:hover {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

.btn--block {
  width: 100%;
}

.btn--lg {
  min-height: 52px;
  font-size: 1.05rem;
}

.btn--sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  flex: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  color: var(--c-text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--c-surface-3);
}

.inline-form {
  display: inline;
  margin: 0;
}

/* ---------- Forms ---------- */

.form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.form__row {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  align-items: start;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

fieldset.field > legend {
  margin-bottom: var(--space-2);
  padding: 0;
}

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-1);
  min-width: 0;
}

.content .field:has(input[autocomplete$="password"]) {
  max-width: 42rem;
}

.field > label,
.field__label {
  color: #c4ccd4;
  font-size: 0.88rem;
  font-weight: 700;
}

.field__hint {
  margin: 0;
  color: var(--c-text-subtle-on-raised);
  font-size: 0.84rem;
}

.field__error,
.field-validation-error {
  color: var(--c-danger);
  font-size: 0.86rem;
  font-weight: 600;
}

.field-validation-valid:empty {
  display: none;
}

.input {
  width: 100%;
  min-width: 0;
  min-height: var(--touch);
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--c-input-border);
  border-radius: var(--radius-sm);
  background: #1d252e;
  color: var(--c-text);
  font: inherit;
}

.input::placeholder {
  color: #8a96a2;
}

.input:hover {
  border-color: #6b7783;
}

/* MT-09: single-line controls have one height (the touch size, same as .btn), so inputs, selects, date/time pickers,
   invalid fields (2 px border drawn inward) and buttons in one row line up. Text is centred by the browser. */
:is(input, select).input:not(.input--code, [type="file"]) {
  height: var(--touch);
  padding-block: 0;
}

.input:focus {
  outline: 2px solid var(--c-accent);
  outline-offset: 1px;
  border-color: var(--c-accent);
}

.input.input-validation-error,
.input[aria-invalid="true"] {
  border-color: var(--c-danger);
  border-width: 2px;
}

/* K8: input widths (max-width only; full width on very small phones). */
.input--xs {
  max-width: 9rem;
}

.input--sm {
  max-width: 20rem;
}

@media (max-width: 360px) {
  .input--xs,
  .input--sm {
    max-width: none;
  }
}

.input--code {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  letter-spacing: 0.35em;
  text-align: center;
}

select.input {
  appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, #a3afba 50%), linear-gradient(135deg, #a3afba 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.input-group {
  position: relative;
  display: flex;
}

.input-group .input {
  padding-right: 3.2rem;
}

.input-group__action {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--touch);
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  color: var(--c-text-muted);
  cursor: pointer;
}

.input-group__action:hover {
  color: var(--c-text);
}

.input-group__action .icon-show-hidden {
  display: none;
}

.input-group__action[aria-pressed="true"] .icon-show {
  display: none;
}

.input-group__action[aria-pressed="true"] .icon-show-hidden {
  display: inline;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: var(--touch);
  padding: var(--space-2) 0;
  cursor: pointer;
}

.check input {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--c-accent);
}

.check__text {
  display: grid;
}

.check__text small {
  font-size: 0.84rem;
}

.choice-grid {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.choice {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  cursor: pointer;
}

.choice:hover {
  border-color: var(--c-border-strong);
}

.choice:has(input:checked) {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
}

.choice input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex: none;
  accent-color: var(--c-accent);
}

.choice__text {
  display: grid;
  gap: 2px;
}

.choice__text small {
  font-size: 0.82rem;
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

/* MT-09: a button placed beside fields in a form row lines up with the controls, not with the labels
   (label line = 0.88rem × line-height 1.5, then the field gap). */
/* A button row next to fields lines up with the controls (label-height offset). Only where the row can hold two
   columns: on phones the row is one column, the buttons stack under the field with the normal row gap (CR-08). */
.form__row > :is(.form-actions, .form__actions) {
  padding-top: 0;
}

@media (min-width: 721px) {
  .form__row > :is(.form-actions, .form__actions) {
    padding-top: calc(0.88rem * 1.5 + var(--space-1));
  }
}

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.alert > .icon {
  margin-top: 2px;
}

.alert p:last-child,
.alert ul:last-child {
  margin-bottom: 0;
}

.alert ul {
  margin: 0;
  padding-left: 1.1rem;
}

.alert--info {
  background: var(--c-info-soft);
  border-color: rgb(96 165 250 / 35%);
  color: #cfe2ff;
}

.alert--success {
  background: var(--c-success-soft);
  border-color: rgb(52 211 153 / 35%);
  color: #c9f5e4;
}

.alert--warning {
  background: var(--c-warning-soft);
  border-color: rgb(251 191 36 / 35%);
  color: #fdecc0;
}

.alert--danger {
  background: var(--c-danger-soft);
  border-color: rgb(248 113 113 / 40%);
  color: #ffd5d5;
}

.validation-summary-valid {
  display: none;
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 1.1rem;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 24px;
  max-width: 100%;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface-3);
  color: #dbe1e7;
  font-size: 0.78rem;
  font-weight: 700;
  overflow-wrap: break-word;
}

.badge--accent {
  background: var(--c-accent-soft);
  border-color: rgb(255 155 0 / 40%);
  color: #ffc46b;
}

.badge--success {
  background: var(--c-success-soft);
  border-color: rgb(52 211 153 / 35%);
  color: #8ff0c6;
}

.badge--warning {
  background: var(--c-warning-soft);
  border-color: rgb(251 191 36 / 35%);
  color: #fcd977;
}

.badge--danger {
  background: var(--c-danger-soft);
  border-color: rgb(248 113 113 / 40%);
  color: #fca5a5;
}

.badge--muted {
  color: var(--c-text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Tables (become cards on phones) ---------- */

.table-wrap,
.card--flush:has(> .table) {
  position: relative;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: middle;
  /* MT-15 (text-fit check): cells keep their words whole. The page-wide `overflow-wrap: anywhere` let a column shrink
     to one letter ("PRZEJ / AZD", "202 / 6"); a word that is longer than the whole line still breaks, and a table
     wider than its card scrolls inside .table-wrap. */
  overflow-wrap: break-word;
}

.table th {
  background: var(--c-surface-2);
  color: #c4ccd4;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table tbody tr:hover {
  background: rgb(255 255 255 / 2%);
}

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

.table__primary {
  display: grid;
}

.table__primary .badge {
  justify-self: start;
}

.table__primary a {
  color: var(--c-text);
  font-weight: 700;
  text-decoration: none;
}

.table__primary a:hover {
  color: var(--c-accent);
}

.table .table__actions {
  text-align: right;
  white-space: nowrap;
}

/* MT-12: a table with a long free-text column (e.g. a clamped scope or note). The page-wide
   `overflow-wrap: anywhere` lets every other column shrink to one character; here words stay whole
   (a single over-long word still breaks); status badges and buttons stay on one line.
   CR-18 (later UI sweep): `.pending-table td/th` and the desktop `.week-table` rules do the same job their own way
   (no badge nowrap there; the week table also keeps its headers and numbers on one line). Move them to this modifier
   once their phone cards are re-checked, so there is one pattern. */
.table--whole-words th,
.table--whole-words td {
  overflow-wrap: break-word;
}

.table--whole-words .badge,
.table--whole-words .btn {
  white-space: nowrap;
}

/* K152 (MT-18 ux-review §2.3.1): selectable table rows — a checkbox column with a 44 px target and a second
   `<label for>` on the identity text, so the whole name toggles the row. On a phone the checkbox takes the card's
   status area (top right, like K37 `.tile__select`). The checked row is tinted; the checkbox carries the state. */
.table--select th.table__select,
.table--select td.table__select {
  width: 3.25rem;
  padding-right: 0;
  vertical-align: top;
}

.table__select-target {
  display: grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  margin-block: calc(-1 * var(--space-2));
  cursor: pointer;
}

.table__select-target input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--c-accent);
}

.table__select-label {
  cursor: pointer;
  font-weight: 600;
}

.table--select tbody tr:has(.table__select input:checked) {
  background: var(--c-accent-soft);
}

@media (max-width: 720px) {
  .table--responsive.table--select td.table__select {
    grid-area: status;
    justify-self: end;
    width: auto;
    padding: 0;
    margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-2)) 0 0;
  }

  .table--responsive.table--select td.table__select::before {
    content: none;
  }

  /* MT-18: an optional stacked cell (e.g. "Uwagi") without content is not an empty card line. */
  .table--responsive td.table__cell--stack:empty {
    display: none;
  }
}

/* K153 (MT-18 ux-review §2.3.2): fields shown by a segmented choice in the same `.form-section`. Without `:has()`
   everything shows (the server drops values that do not apply). */
.form-section:has(.segmented__input[value="positive"]:checked) [data-hide-when~="positive"],
.form-section:has(.segmented__input[value="negative"]:checked) [data-hide-when~="negative"],
.form-section:has(.segmented__input[value="not_done"]:checked) [data-hide-when~="not_done"],
.form-section:not(:has(.segmented__input:checked)) [data-hide-when~="none"] {
  display: none;
}

.empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--c-text-muted);
}

@media (max-width: 720px) {
  .table--responsive thead {
    display: none;
  }

  .table--responsive,
  .table--responsive tbody,
  .table--responsive tr,
  .table--responsive td {
    display: block;
    width: 100%;
  }

  .table--responsive tr {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--c-border);
  }

  .table--responsive td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-1) 0;
    border: 0;
    text-align: right;
  }

  .table--responsive td[data-label]::before {
    content: attr(data-label);
    color: var(--c-text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-align: left;
  }

  .table--responsive td.table__primary-cell {
    display: block;
    text-align: left;
  }

  .table--responsive td.table__primary-cell::before {
    content: none;
  }

  .table--responsive .table__actions {
    justify-content: flex-start;
  }
}

/* ---------- Pagination ---------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--c-border);
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

/* ---------- MFA / secrets ---------- */

.steps {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  padding-left: 2.75rem;
  counter-increment: step;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-accent-soft);
  color: var(--c-accent);
  font-weight: 800;
}

.qr {
  display: inline-block;
  padding: var(--space-3);
  background: #ffffff;
  border-radius: var(--radius);
  line-height: 0;
}

.qr img {
  width: 196px;
  height: 196px;
}

.secret {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
}

.secret code {
  flex: 1 1 220px;
  overflow-wrap: anywhere;
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-4);
  list-style: none;
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  text-align: center;
}

/* ---------- Session list ---------- */

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

.session {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--c-border);
}

.session__icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
}

.session__body {
  min-width: 0;
  flex: 1;
  display: grid;
}

.session__body small {
  overflow-wrap: anywhere;
}

/* ---------- Misc ---------- */

.divider {
  height: 1px;
  margin: var(--space-4) 0;
  border: 0;
  background: var(--c-border);
}

.copy-feedback {
  color: var(--c-success);
  font-size: 0.85rem;
  font-weight: 700;
}

.app-version {
  color: var(--c-text-subtle);
  font-size: 0.75rem;
  text-align: center;
}

/* ======================================================================
   MT-01 UI building blocks (ux-review §3). Server pieces: Ssp.Platform.Web.Ui.
   ====================================================================== */

/* ---------- Page header (list pages; the topbar h1 is the title) ---------- */

.page-header__text {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.page-header__count {
  font-weight: 700;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

@media (max-width: 720px) {
  .page-header__actions {
    width: 100%;
  }

  .page-header__actions .btn {
    flex: 1;
  }
}

/* ---------- Filter bar (G1: flex-wrap instead of the invalid auto-fit grid) ---------- */

.filter-bar {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.filter-bar--simple {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
}

.filter-bar--simple > .filter-bar__actions {
  margin-top: var(--space-1);
}

.filter-bar__main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.filter-bar__search {
  flex: 2 1 280px;
}

.filter-bar__fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  margin-top: var(--space-3);
  min-width: 0;
}

.filter-bar__fields:not(:has(> *)) {
  display: none;
}

.filter-bar__fields > .field {
  flex: 1 1 160px;
  min-width: 0;
}

.filter-bar__actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-bar__main :is(.input, .filter-bar__actions .btn) {
  min-height: 3rem;
}

.filter-bar__more > summary {
  list-style: none;
}

.filter-bar__more > summary::-webkit-details-marker {
  display: none;
}

@media (min-width: 721px) {
  .filter-bar--simple {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .filter-bar--simple > :is(.field__label, .field__hint, .field__error) {
    grid-column: 1 / -1;
  }

  .filter-bar--simple > .filter-bar__actions {
    grid-area: 2 / 2;
    margin-top: 0;
  }

  /* `display: contents` does not work on <details> (Chrome keeps its internal content box, so the fields stacked in
     one column). The open panel is a flex item of the main row and its fields wrap inside it instead. */
  .filter-bar__more[open] {
    flex: 3 1 320px;
    min-width: 0;
  }

  .filter-bar__more[open] > summary {
    display: none;
  }

  .filter-bar__more[open] > .filter-bar__fields {
    --filter-field-width: 200px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--filter-field-width)), 1fr));
    margin-top: 0;
  }

  .filter-bar__search + .filter-bar__more[open] > .filter-bar__fields {
    --filter-field-width: 150px;
  }

  /* Field feedback sits below controls, so keep actions on their own row when it is present. */
  .filter-bar__main:has(> .filter-bar__more[open] :is(.field__hint, .field__error)) > .filter-bar__actions {
    flex-basis: 100%;
  }

  .filter-bar__sort {
    display: none;
  }

  /* MT-15: where <details> exposes its content box (::details-content), the open panel and its field list are
     `display: contents`: the fields are flex items of the main row like the search, so they flow from the left with no
     hole beside a two-row panel grid, and the action ends the last line, bottom-aligned with the controls. Browsers
     without it keep the panel grid above. */
  @supports selector(::details-content) {
    .filter-bar__more[open],
    .filter-bar__more[open]::details-content,
    .filter-bar__more[open] > .filter-bar__fields {
      display: contents;
    }

    .filter-bar__more[open] > .filter-bar__fields > .field {
      flex: 1 1 9.5rem;
      min-width: min(100%, 9.5rem);
      max-width: 16rem;
    }

    /* A select shows a person's or a status name: a wider start, so "Wiktor Wizytowy" is not cut. */
    .filter-bar__more[open] > .filter-bar__fields > .field:has(> select) {
      flex-basis: 12rem;
    }

    .filter-bar__main:has(> .filter-bar__more[open]) > .filter-bar__search {
      flex: 2 1 12rem;
      max-width: 26rem;
    }

    /* Four or more panel fields: the search takes the first line; the fields and the action follow. */
    .filter-bar__main:has(> .filter-bar__more[open] > .filter-bar__fields > .field:nth-of-type(4)) > .filter-bar__search {
      flex-basis: 100%;
      max-width: none;
    }

    /* A hint of the whole panel is a full line after the action; an error under a control top-aligns the line and
       places the action by the label offset, as for loose fields. */
    .filter-bar__more[open] > .filter-bar__fields > .field__hint {
      flex: 1 1 100%;
      order: 1;
      margin: 0;
    }

    .filter-bar__main:has(> .filter-bar__more[open] :is(.field__hint, .field__error)) > .filter-bar__actions {
      flex-basis: auto;
    }

    .filter-bar__main:has(> .filter-bar__more[open] .field :is(.field__hint, .field__error)) {
      align-items: flex-start;
    }

    .filter-bar__main:has(> .filter-bar__more[open] .field :is(.field__hint, .field__error)) > .filter-bar__actions {
      padding-top: calc(0.88rem * 1.5 + var(--space-1));
    }
  }
}

@media (max-width: 720px) {
  .filter-bar__search {
    flex-basis: 100%;
  }

  .filter-bar__more {
    flex: 1 1 auto;
  }

  .filter-bar__more[open] {
    flex-basis: 100%;
  }

  .filter-bar__more[open] > .filter-bar__fields {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar__fields > .field {
    flex: none;
  }

  .filter-bar__main > .filter-bar__fields {
    flex: 1 1 100%;
    margin-top: 0;
  }

  .filter-bar__main > .filter-bar__fields > .field {
    flex: 1 1 100%;
  }
}

/* MT-11 fix: ONE pattern for every form with fields and an action in one row ("Pokaż", "Szukaj", "Filtruj", day and
   week jumps): form.filter-bar > .filter-bar__main > (.field… | .filter-bar__search | details.filter-bar__more)
   + .filter-bar__actions. The row is flex, wraps, bottom-aligned, gap --space-3; the action is as tall as the controls
   (3rem) and stays on the fields' line on desktop whenever they fit. On phones the fields stack and the action takes
   the full width under them (gallery /dev/ui#filter-bar). Pages add no row classes of their own. */
/* Small flex bases decide the line breaks (so the action stays on the line in narrow cards and in a shrink-to-fit
   form); the fields then grow up to a comfortable width. */
.filter-bar__main > .field:not(.filter-bar__search) {
  flex: 1 1 11rem;
  min-width: min(100%, 11rem);
  max-width: 18rem;
}

.filter-bar__main > .field:not(.filter-bar__search):has(input[type="search"]) {
  flex-basis: 14rem;
  max-width: 40rem;
}

/* A hint or an error under a control must not push the action off the controls' line or move the controls apart:
   the row is then top-aligned and the action is placed by the label offset (one label line + the field gap). */
.filter-bar__main:has(> .field :is(.field__hint, .field__error)) {
  align-items: flex-start;
}

.filter-bar__main:has(> .field :is(.field__hint, .field__error)) > .filter-bar__actions {
  padding-top: calc(0.88rem * 1.5 + var(--space-1));
}

@media (max-width: 720px) {
  .filter-bar__main > .field:not(.filter-bar__search),
  .filter-bar__main > .field:not(.filter-bar__search):has(input[type="search"]) {
    flex: 1 1 100%;
    max-width: none;
  }

  .filter-bar__main > .filter-bar__actions {
    flex: 1 1 100%;
  }

  .filter-bar__main:has(> .field :is(.field__hint, .field__error)) > .filter-bar__actions {
    padding-top: 0;
  }

  .filter-bar__main > .filter-bar__actions > .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* MT-15 CR-11 (brief §8): the primary action ("Filtruj", "Pokaż") takes the full width on a phone; "Wyczyść" and
     other secondary actions share the next line. */
  .filter-bar__main > .filter-bar__actions > .btn--primary {
    flex-basis: 100%;
  }
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.filter-chips__label {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 32px;
  padding: 0.2rem 0.4rem 0.2rem 0.75rem;
  border: 1px solid var(--c-border-strong);
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.chip:hover {
  border-color: var(--c-accent);
  color: var(--c-text);
}

@media (pointer: coarse) {
  .chip {
    min-height: var(--touch);
  }
}

/* ---------- Data table additions (sorting, row links, cell roles) ---------- */

.table__sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: inherit;
  text-decoration: none;
}

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

.table__sort-idle {
  opacity: 0.5;
}

.table .table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table__meta {
  display: block;
}

.table--rows-link tbody tr {
  position: relative;
}

.table--rows-link tbody tr:hover {
  background: rgb(255 255 255 / 4%);
}

.table--rows-link tbody tr:hover .table__row-link {
  color: var(--c-accent);
}

.table__row-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.table--rows-link td a:not(.table__row-link),
.table--rows-link td button,
.table--rows-link td summary,
.table--rows-link td details,
.table--rows-link td form,
.table__layered {
  position: relative;
  z-index: 1;
}

.table--rows-link tbody tr:has(.table__row-link:focus-visible) {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.table__changes {
  width: 40%;
}

.changes > summary {
  cursor: pointer;
  color: var(--c-text-muted);
}

.changes[open] > summary {
  margin-bottom: var(--space-2);
}

@media (max-width: 720px) {
  .table--responsive tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) fit-content(45%);
    grid-template-areas: "primary status";
    gap: var(--space-1) var(--space-3);
  }

  .table--responsive tbody td {
    grid-column: 1 / -1;
  }

  .table--responsive td.table__primary-cell {
    grid-area: primary;
  }

  .table--responsive td.table__primary-cell .table__primary a {
    font-size: 1rem;
  }

  .table--responsive td.table__status-cell {
    grid-area: status;
    align-self: start;
    display: block;
  }

  .table--responsive td.table__status-cell::before {
    content: none;
  }

  .table--responsive td[data-label]::before {
    flex: 0 1 40%;
  }

  .table--responsive td.table__cell--stack {
    display: grid;
    gap: 2px;
    text-align: left;
  }

  .table--responsive td.table__cell--desktop {
    display: none;
  }

  .table--responsive td.table__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--c-border);
    text-align: left;
    white-space: normal;
  }

  .table--responsive td.table__actions:empty {
    display: none;
  }

  .table--responsive td.table__actions + td.table__actions {
    margin-top: 0;
    padding-top: var(--space-1);
    border-top: 0;
  }

  .table--responsive td.table__actions .btn {
    min-height: var(--touch);
  }

  .table--responsive td.table__actions::before {
    content: none;
  }

  .table__changes {
    width: auto;
  }
}

/* ---------- Pager ---------- */

.pager__summary,
.pager__size {
  margin: 0;
}

.pager__pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pager__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  font-weight: 600;
  text-decoration: none;
}

.pager__page:hover {
  background: var(--c-surface-3);
  color: var(--c-text);
}

.pager__page[aria-current="page"] {
  background: var(--c-accent);
  color: var(--c-accent-text);
}

.pager__gap {
  padding: 0 var(--space-1);
}

.pager__position {
  display: none;
}

.pager__size a {
  display: inline-block;
  min-width: 28px;
  padding: 0 var(--space-1);
  color: var(--c-text-muted);
  text-align: center;
}

.pager__size a[aria-current="true"] {
  color: var(--c-text);
  font-weight: 700;
  text-decoration: none;
}

@media (pointer: coarse) {
  .pager__page,
  .pager__size a {
    min-width: var(--touch);
    min-height: var(--touch);
    line-height: var(--touch);
  }
}

@media (max-width: 720px) {
  .pager__page,
  .pager__gap {
    display: none;
  }

  .pager__position {
    display: block;
    padding: 0 var(--space-2);
  }

  .pager__pages li:has(.pager__page) {
    display: none;
  }
}

/* ---------- Empty states ---------- */

.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.empty-state__icon {
  width: 40px;
  height: 40px;
  color: var(--c-text-muted);
}

.empty-state__title {
  margin: 0;
  font-size: 1.05rem;
}

.empty-state__text {
  max-width: 52ch;
  margin: 0;
  color: var(--c-text-muted);
}

.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* MT-24: compact left-aligned variant (the legacy file placeholder inside cards and above the photo grid). */
.empty-state--inline {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  justify-items: start;
  gap: var(--space-3);
  padding: var(--space-3);
  text-align: left;
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.empty-state--inline .empty-state__icon {
  width: 24px;
  height: 24px;
  margin-top: 2px;
}

.empty-state--inline .empty-state__body {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.empty-state--inline .empty-state__title {
  font-size: 1rem;
}

.empty-state--inline .empty-state__actions {
  justify-content: flex-start;
  margin-top: var(--space-1);
}

/* ---------- Breadcrumbs ---------- */

.breadcrumbs {
  margin-bottom: var(--space-3);
  font-size: 0.9rem;
}

.breadcrumbs__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs__list li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.breadcrumbs__list li + li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-top: 2px solid var(--c-text-muted);
  border-right: 2px solid var(--c-text-muted);
  transform: rotate(45deg);
}

.breadcrumbs__list a {
  min-width: 0;
  color: var(--c-text-muted);
  font-weight: 600;
  text-decoration: none;
}

.breadcrumbs__list a:hover {
  color: var(--c-text);
}

.breadcrumbs__list a[aria-current="page"] {
  max-width: 40ch;
  overflow: hidden;
  color: var(--c-text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumbs__back {
  display: none;
}

@media (max-width: 720px) {
  .breadcrumbs__list li {
    display: none;
  }

  .breadcrumbs__list li.breadcrumbs__parent {
    display: inline-flex;
  }

  .breadcrumbs__list li.breadcrumbs__parent::before {
    content: none;
  }

  .breadcrumbs__list .breadcrumbs__parent a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--touch);
  }

  .breadcrumbs__back {
    display: inline-block;
  }
}

/* ---------- Detail page ---------- */

.detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.detail-header__main {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  flex: 1 1 320px;
}

.detail-header__eyebrow {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.detail-header__title {
  margin: 0;
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}

.detail-header__meta {
  margin-top: var(--space-1);
}

.detail-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

@media (max-width: 720px) {
  .detail-header__actions {
    width: 100%;
  }

  .detail-header__actions > form,
  .detail-header__actions > form .btn,
  .detail-header__actions > .btn--primary {
    flex: 1 1 100%;
    width: 100%;
  }

  .detail-header__secondary {
    display: none;
  }
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}

.facts__item {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
}

.facts__item dt {
  color: var(--c-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.facts__item dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

@media (max-width: 720px) {
  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.definition--cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--space-4);
  margin: 0;
}

.definition__item {
  display: grid;
  align-content: start;
  gap: var(--space-1);
  min-width: 0;
}

.definition__item dt {
  color: var(--c-text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.definition__item dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.definition__item--wide {
  grid-column: 1 / -1;
}

.definition--compact {
  display: grid;
  grid-template-columns: fit-content(45%) minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  margin: var(--space-2) 0 0;
  font-size: 0.9rem;
  min-width: 0;
}

.definition--compact > div {
  display: contents;
}

.definition--compact dt {
  color: var(--c-text-muted);
}

.definition--compact dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.cluster--sm {
  gap: var(--space-1);
}

:where(:not(.grid, .stack, .form)) > :is(.card + .card, .card + .cluster, .card + .label-page, .alert + .alert, .alert + .form),
.alert + .tabs,
.facts + .alert,
:where(main) > :is(.run-timer + .alert, .run-timer + .card, .alert + .card) {
  margin-top: var(--space-4);
}

/* MT-11 fix (audit check "gap"): stacked blocks that touched (0 px). An alert at the top of the content keeps its
   distance from whatever follows (filter bar, detail header, a context line); a saved form from the card below it
   (history); a card from the action row below it; a section title inside a card body from its content; a form from
   the next filter-bar row. Margins collapse with an existing margin, so nothing that was spaced moves. */
:where(main) > .alert:not(:last-child) {
  margin-bottom: var(--space-4);
}

:where(main) > .form + .card,
:where(main) > form + .card {
  margin-top: var(--space-5);
}

/* MT-14: a section card above the running timer (job details) and the logo card above the company form. */
:where(main) > .card + .run-timer {
  margin-top: var(--space-4);
}

:where(main) > .card + :is(.form, form) {
  margin-top: var(--space-5);
}

.card + .form-actions {
  margin-top: var(--space-2);
}

:where(.card__body) > .form-section__title + * {
  margin-top: var(--space-2);
}

:is(form, .form) + .filter-bar {
  margin-top: var(--space-4);
}

.qr-card > .alert + .qr-card__body {
  margin-top: var(--space-4);
}

.card__title {
  margin-bottom: var(--space-3);
}

.alert__title {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
}

.alert--block {
  margin-bottom: var(--space-4);
}

.alert--block > div {
  min-width: 0;
  flex: 1;
}

.item-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-list__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--c-border);
}

.item-list__icon {
  color: var(--c-text-muted);
}

.item-list__body {
  display: grid;
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}

.item-list__end {
  flex: none;
}

.timeline {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  padding-left: 1.1rem;
}

.message-body,
.error-text {
  max-height: 30em;
  margin: var(--space-2) 0 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-text {
  max-height: 20lh;
  margin: 0 0 var(--space-2);
  color: inherit;
}

/* ---------- Tabs (links: bookmarkable, only the active panel is rendered) ---------- */

.tabs {
  margin: 0 0 var(--space-4);
}

.tabs__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: 0 var(--space-4);
  border: 1px solid var(--c-accent);
  border-radius: 999px;
  color: var(--c-accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.tabs__tab:hover {
  background: var(--c-accent-soft);
  color: var(--c-accent-hover);
}

.tabs__tab[aria-current="page"] {
  background: var(--c-accent);
  color: var(--c-accent-text);
}

.tabs__count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: rgb(255 255 255 / 10%);
  font-size: 0.8rem;
  text-align: center;
}

.tabs__tab[aria-current="page"] .tabs__count {
  background: rgb(0 0 0 / 18%);
}

@media (max-width: 720px) {
  .tabs__list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: var(--space-1);
    scroll-padding-inline: var(--space-1);
    scroll-snap-type: x proximity;
  }

  .tabs__list li {
    scroll-snap-align: start;
  }
}

/* ---------- Overflow menu (details-based disclosure) ---------- */

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu__panel {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: var(--z-menu);
  min-width: 220px;
  margin: 0;
  padding: var(--space-1) 0;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  box-shadow: var(--shadow);
  list-style: none;
}

/* Keep table menus visible inside the table's scroll container. */
.table__actions .menu__panel {
  position: static;
  min-width: 0;
  margin-top: var(--space-1);
  white-space: normal;
}

.menu__panel a,
.menu__panel button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--touch);
  padding: 0 var(--space-4);
  border: 0;
  background: none;
  color: var(--c-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu__panel a:hover,
.menu__panel button:hover {
  background: var(--c-surface-3);
}

.menu__panel li:has(.menu__danger) {
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px solid var(--c-border);
}

.menu__panel .menu__danger {
  color: var(--c-danger);
}

.menu__item--phone {
  display: none;
}

@media (max-width: 720px) {
  .menu__item--phone {
    display: block;
  }

  .menu__label {
    display: none;
  }

  /* MT-09: on phones the "Więcej" button wraps to the start of the header's action row, so its panel opens to the
     right of it (anchored right, it ran ~150 px off the left edge of the screen). */
  .detail-header__actions .menu__panel {
    right: auto;
    left: 0;
  }
}

/* ---------- Confirmation dialog ---------- */

.dialog {
  width: min(480px, calc(100% - 2 * var(--space-4)));
  max-width: 480px;
  padding: 0;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-lg);
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dialog);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 60%);
}

.dialog__body {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
}

.dialog__title {
  margin: 0;
  font-size: 1.15rem;
}

.dialog__text {
  margin: 0;
  color: var(--c-text-muted);
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

@media (max-width: 720px) {
  .dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .dialog__body {
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  }

  .dialog__actions {
    flex-direction: column-reverse;
  }

  .dialog__actions .btn {
    width: 100%;
  }
}

.confirm-page {
  display: grid;
  gap: var(--space-3);
}

.confirm-page__title {
  margin: 0;
}

.confirm-page__text {
  margin: 0;
  color: var(--c-text-muted);
}

.confirm-page .dialog__actions {
  justify-content: flex-start;
  flex-direction: row;
}

/* ---------- "Historia zmian" (audit history) and diffs ---------- */

.history,
.history__entries {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history {
  display: grid;
  gap: var(--space-4);
}

.history__date {
  margin: 0 0 var(--space-2);
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.history__entries {
  display: grid;
  gap: var(--space-3);
}

.history-entry {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.history-entry__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.history-entry__actor {
  font-weight: 600;
}

.history-entry__time {
  margin-left: auto;
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.history__footer {
  margin-top: var(--space-3);
}

.history__footer p {
  margin: 0;
}

.history-event p {
  margin: 0;
}

.diff {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.diff th,
.diff td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word; /* MT-15 text-fit: whole words, as in .table */
}

.diff thead th {
  color: var(--c-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.diff tbody th {
  width: 25%;
  font-weight: 600;
}

.diff__old {
  border-left: 3px solid rgb(248 113 113 / 50%);
  color: var(--c-text-muted);
}

.diff__new {
  border-left: 3px solid rgb(52 211 153 / 60%);
}

.diff--values .diff__new {
  border-left-color: var(--c-border-strong);
}

.diff__empty {
  color: var(--c-text-muted);
  font-style: italic;
}

.diff__value {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.diff__value.is-clamped {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.diff__more > summary {
  color: var(--c-accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.diff__more[open] > summary {
  margin-bottom: var(--space-2);
}

.diff__value.is-clamped:has(+ .diff__more[open]) {
  display: none;
}

.diff__row--sensitive td {
  color: var(--c-text-muted);
}

@media (max-width: 720px) {
  .diff thead {
    display: none;
  }

  .diff,
  .diff tbody,
  .diff tr,
  .diff th,
  .diff td {
    display: block;
    width: 100%;
  }

  .diff tr {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--c-border);
  }

  .diff th,
  .diff td {
    padding: var(--space-1) 0 var(--space-1) var(--space-2);
    border-bottom: 0;
  }

  .diff tbody th {
    width: 100%;
    padding-left: 0;
  }

  .diff td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--c-text-muted);
    font-size: 0.8rem;
    font-weight: 700;
  }
}

/* ---------- Badges, buttons and loading (delta) ---------- */

.badge--info {
  background: var(--c-info-soft);
  border-color: rgb(96 165 250 / 40%);
  color: #a8cbfd;
}

.nav__badge {
  flex: none;
  margin-left: auto;
  white-space: nowrap;
}

.btn--icon {
  width: var(--touch);
  padding: 0;
}

.btn.is-loading {
  position: relative;
  cursor: progress;
}

.btn.is-loading::after {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after {
    animation: none;
    border-right-color: currentColor;
    opacity: 0.6;
  }
}

@media (pointer: coarse) {
  .btn--sm {
    min-height: var(--touch);
  }
}

/* ---------- Flash messages and toasts ---------- */

.flash-stack {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.flash {
  align-items: center;
}

.flash__text {
  flex: 1;
  margin: 0;
}

.flash__close {
  width: 36px;
  height: 36px;
  background: transparent;
  border-color: transparent;
  color: inherit;
}

/* MT-09: the close button is a 44 px touch target on touch screens (36 px with a mouse). */
@media (pointer: coarse) {
  .flash__close {
    width: var(--touch);
    height: var(--touch);
  }
}

.toast-region {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: var(--z-toast);
  display: grid;
  gap: var(--space-2);
  width: min(380px, calc(100% - 2 * var(--space-4)));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface-3);
  box-shadow: var(--shadow);
  color: var(--c-text);
  pointer-events: auto;
}

.toast p {
  flex: 1;
  margin: 0;
}

.toast--success {
  border-color: rgb(52 211 153 / 50%);
}

.toast--warning {
  border-color: rgb(251 191 36 / 50%);
}

.toast--error {
  border-color: rgb(248 113 113 / 60%);
}

@media (max-width: 960px) {
  .toast-region {
    right: 50%;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + var(--space-3));
    transform: translateX(50%);
  }
}

/* ---------- Forms: validation summary, sections, sticky save bar ---------- */

.validation-summary {
  margin-bottom: var(--space-4);
}

.validation-summary__title {
  margin: 0 0 var(--space-1);
  font-size: 1rem;
}

.validation-summary a {
  color: inherit;
  font-weight: 600;
}

.field__required {
  color: var(--c-danger);
  font-weight: 700;
}

.form__legend-note {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.field__error .icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.form-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}

.form-section__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

/* MT-09: a fieldset used as a section card looks like the <section> cards: no UA side margin (it was indented by
   2 px), and the legend is laid out inside the card like a heading instead of on its top border. */
fieldset.form-section {
  margin: 0;
  min-inline-size: 0;
}

fieldset.form-section > legend.form-section__title {
  float: left;
  width: 100%;
  padding: 0;
}

fieldset.form-section > legend.form-section__title + .form-section__help {
  margin-top: calc(var(--space-1) - var(--space-4));
}

.form-section__help {
  margin: var(--space-1) 0 0;
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

@media (min-width: 1100px) {
  .form-section--split {
    grid-template-columns: min(33.333%, 20rem) minmax(0, 1fr);
  }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

@media (max-width: 720px) {
  html:has(.form-actions--sticky) {
    scroll-padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 10rem);
  }

  .form-section {
    padding: var(--space-4);
  }

  .form-actions--sticky {
    position: sticky;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + var(--space-2));
    z-index: 10;
    margin-inline: calc(-1 * var(--space-3));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: var(--space-3);
    border-top: 1px solid var(--c-border);
    background: rgb(11 15 19 / 96%);
    box-shadow: 0 -8px 24px rgb(0 0 0 / 35%);
  }

  .form-actions--sticky > .btn {
    padding-inline: var(--space-2);
    text-align: center;
  }

  .form-actions--sticky > .btn:only-child,
  .form-actions--sticky:has(> .btn:nth-child(3)) > .btn--primary {
    grid-column: 1 / -1;
  }

  /* MT-09: the closing ghost "Anuluj" takes only its own width and the button beside it the rest, so labels such as
     "Zapisz urządzenie", "Zapisz harmonogram" or "Dodaj i wpisz kolejne" stay on one line (in half-width columns they
     wrapped to two lines; the three-button bar grew to 137 px). */
  .form-actions--sticky:has(> .btn--ghost:last-child) {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

/* ---------- File upload ---------- */

.upload {
  display: grid;
  gap: var(--space-2);
}

.upload__zone {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-surface-2);
  text-align: center;
}

.upload__zone.is-dragover {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
}

.upload__zone-icon {
  width: 32px;
  height: 32px;
  color: var(--c-text-muted);
}

.upload__zone-text {
  margin: 0;
  color: var(--c-text-muted);
}

.upload__camera {
  display: none;
}

/* MT-16 (K136): photo-only zones say "Wybierz zdjęcia" on fine pointers, "Wybierz z galerii" next to the camera. */
.upload__pick-coarse {
  display: none;
}

@media (pointer: coarse) {
  .upload__camera {
    display: inline-flex;
  }

  .upload__pick-coarse {
    display: inline;
  }

  .upload__pick-fine {
    display: none;
  }

  .upload__zone-text {
    display: none;
  }
}

.upload__list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.upload__list:empty {
  display: none;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--c-surface);
}

.upload-item__thumb,
.upload-item__icon {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.upload-item__icon {
  padding: 14px;
  background: var(--c-surface-3);
  color: var(--c-text-muted);
}

.upload-item__body {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.upload-item__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.upload-item__meta {
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.upload-item__progress {
  width: 100%;
  height: 6px;
  accent-color: var(--c-accent);
}

.upload-item__error {
  margin: 0;
  color: var(--c-danger);
  font-size: 0.88rem;
}

.upload-item__actions {
  display: flex;
  gap: var(--space-1);
}

.upload-item.is-queued {
  opacity: 0.75;
}

.upload-item.is-done {
  border-left-color: var(--c-success);
}

.upload-item.is-error,
.upload-item.is-rejected {
  border-left-color: var(--c-danger);
}

.upload-item:not(.is-uploading) .upload-item__progress {
  display: none;
}

.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--c-border);
}

.file-list__item:first-child {
  border-top: 0;
}

.file-list__icon {
  color: var(--c-text-muted);
}

.file-list__body {
  display: grid;
  min-width: 0;
  flex: 1 1 200px;
  overflow-wrap: anywhere;
}

.file-list__actions {
  display: flex;
  gap: var(--space-2);
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
}

.thumb-grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--c-surface-3);
}

@media (max-width: 720px) {
  .thumb-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- Component gallery (/dev/ui, Development only) ---------- */

.gallery {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.gallery__toc {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-3));
}

.gallery__toc ol {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.gallery__toc-phone {
  display: none;
}

.gallery-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.gallery-section > h2 {
  margin: 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--c-border);
}

.gallery-sample {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
}

.gallery-sample > h3 {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.gallery-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-2);
}

.gallery-swatch {
  display: grid;
  gap: var(--space-1);
  font-size: 0.8rem;
}

.gallery-swatch__color {
  height: 48px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
}

.gallery-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.gallery-icons li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.swatch-bg { background: var(--c-bg); }
.swatch-surface { background: var(--c-surface); }
.swatch-surface-2 { background: var(--c-surface-2); }
.swatch-surface-3 { background: var(--c-surface-3); }
.swatch-border { background: var(--c-border); }
.swatch-text { background: var(--c-text); }
.swatch-text-muted { background: var(--c-text-muted); }
.swatch-text-subtle { background: var(--c-text-subtle); }
.swatch-accent { background: var(--c-accent); }
.swatch-success { background: var(--c-success); }
.swatch-warning { background: var(--c-warning); }
.swatch-danger { background: var(--c-danger); }
.swatch-info { background: var(--c-info); }
.swatch-input-border { background: var(--c-input-border); }

.is-forced-hover {
  filter: brightness(1.12);
}

.is-forced-focus {
  outline: 3px solid var(--c-accent);
  outline-offset: 2px;
}

@media (max-width: 960px) {
  .gallery {
    grid-template-columns: minmax(0, 1fr);
  }

  .gallery__toc {
    display: none;
  }

  .gallery__toc-phone {
    display: block;
    margin-bottom: var(--space-4);
  }
}

/* ---------- Contrast and Windows High Contrast ---------- */

/* G3: --c-text-subtle passes AA only on --c-bg/--c-surface; raised surfaces use the lighter token. */
:is(.history-entry, .upload__zone, .menu__panel, .tile, .toast, .diff thead) :is(.text-subtle, .field__hint) {
  color: var(--c-text-subtle-on-raised);
}

/* ===== MT-03: customers, global search ===== */

/* Top-bar search: a form on desktop, a link to /szukaj in the drawer layout. */
.topbar__search {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: min(360px, 34vw);
}

.topbar__search .input {
  padding-inline: 0.7rem;
}

.topbar__search-link {
  display: none;
}

@media (max-width: 960px) {
  .topbar__search {
    display: none;
  }

  .topbar__search-link {
    display: inline-grid;
  }
}

/* Global search results. */
.search-results__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.search-results__note {
  margin: var(--space-3) 0 0;
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

.item-list__item--link:hover {
  background: var(--c-surface-3);
}

.item-list__link {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.item-list__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.item-list__link:focus-visible {
  outline: none;
}

.item-list__item--link:focus-within {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.item-list__arrow {
  flex: none;
  color: var(--c-text-muted);
}

.card__body {
  padding: var(--space-4) var(--space-5);
}

.card__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--c-border);
}

/* Customer tiles (K1 stretched tile in a responsive grid). */
.tile-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

/* MT-09: a tile list used as the body of a flush card keeps the card's inner padding (it touched the card edges). */
.tile-list.card__body {
  padding: var(--space-4) var(--space-5);
}

.tile-list > li {
  display: flex;
}

.tile-list .tile {
  flex: 1;
  min-width: 0;
}

.tile .tile__sub {
  margin: 0 0 var(--space-1);
  font-size: 0.85rem;
}

.tile__lines {
  display: grid;
  gap: 2px;
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

.tile__lines li {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tile__lines .icon {
  flex: none;
  align-self: center;
}

.tile__label {
  color: var(--c-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

.tile__arrow {
  flex: none;
  align-self: center;
  color: var(--c-text-muted);
}

.tile__meta-links .chip {
  position: relative;
  z-index: 1;
}

.customer-count {
  margin: 0 0 var(--space-3);
  color: var(--c-text-muted);
}

.customer-results[aria-busy="true"] {
  opacity: 0.6;
}

/* GUS lookup: NIP field with its button. */
.gus {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: flex-start;
}

.gus > .field {
  flex: 0 1 260px;
}

.gus__button {
  margin-top: 1.7rem;
}

.gus__status:empty {
  display: none;
}

.gus__status:focus {
  outline: none;
}

@media (max-width: 720px) {
  .gus > .field {
    flex-basis: 100%;
  }

  .gus__button {
    margin-top: 0;
    width: 100%;
  }
}

/* K16: "Porównanie z GUS" with a checkbox per row. */
.diff--pick td.diff__pick {
  width: 7rem;
  text-align: center;
}

.diff--pick .diff__pick input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--c-accent);
}

.diff__pick-label {
  display: none;
}

@media (max-width: 720px) {
  .diff--pick td.diff__pick {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    width: 100%;
    text-align: left;
  }

  .diff__pick-label {
    display: inline;
  }
}

/* K18: blocker list of a refused delete. */
.blockers {
  margin: var(--space-2) 0;
  padding-left: 1.2rem;
}

.blockers li + li {
  margin-top: var(--space-1);
}

/* Branch items on the customer page (K9 extended to item lists). */
.branch-item {
  align-items: flex-start;
}

.branch-item:focus {
  outline: none;
}

.branch-item__contact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
}

.branch-item__contact a {
  display: inline-flex;
  gap: var(--space-1);
  align-items: center;
}

.branch-item__notes {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: pre-wrap;
}

.item-list__item.is-new {
  box-shadow: inset 3px 0 0 var(--c-accent);
}

.detail-header__note {
  margin: 0;
  align-self: center;
}

@media (max-width: 720px) {
  .branch-item {
    flex-wrap: wrap;
  }

  .branch-item .item-list__end {
    width: 100%;
  }

  .branch-item .item-list__end .btn {
    width: 100%;
  }
}

.danger-zone {
  margin-top: var(--space-6);
}


/* Devices (MT-04): tiles with a photo, due line, muted withdrawn tiles, photo card, computed dates, K25/K28. */
.tile__thumb {
  width: 64px;
  height: 64px;
  flex: none;
  overflow: hidden;
  border-radius: 10px;
  background: var(--c-surface-3);
}

.tile__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile__due {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin: var(--space-2) 0 0;
  font-size: 0.9rem;
}

.tile--muted {
  background: var(--c-surface);
}

.tile--muted.tile--stretched:hover {
  border-color: var(--c-border);
  background: var(--c-surface);
}

.tile__address span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.photo-card {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}

.photo-card img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius);
}

.photo-card__current {
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}

.choice-grid--inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.field--computed output {
  display: block;
  font-weight: 600;
}

/* K25: dependent fields hidden while their checkbox is unchecked (no JS; browsers without :has() show them). */
.form-section:has([data-controls="udt"]:not(:checked)) [data-depends-on="udt"],
.form-section:has([data-controls="insulation"]:not(:checked)) [data-depends-on="insulation"] {
  display: none;
}

/* K28: one tbody per serial. */
.table--grouped caption {
  padding: var(--space-2) var(--space-4);
  text-align: left;
}

.table--grouped tbody + tbody {
  border-top: 2px solid var(--c-border);
}

.table--grouped th[scope="rowgroup"] {
  vertical-align: top;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Actions in a group header keep the normal button text (the header itself is small caps-like uppercase). */
.table--grouped th[scope="rowgroup"] .btn {
  font-size: 0.9rem;
  letter-spacing: normal;
  text-transform: none;
}

@media (max-width: 720px) {
  .table--grouped th[scope="rowgroup"] {
    grid-column: 1 / -1;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
  }
}

@media (prefers-contrast: more) {
  :root {
    --c-text-muted: #c8d0d8;
    --c-border: #4a5966;
  }

  .badge {
    border-color: rgb(255 255 255 / 60%);
  }
}

@media (forced-colors: active) {
  .badge,
  .chip,
  .tabs__tab,
  .pager__page,
  .facts__item,
  .history-entry,
  .upload-item {
    border: 1px solid CanvasText;
  }

  .tabs__tab[aria-current="page"],
  .pager__page[aria-current="page"],
  .nav__link.is-active {
    outline: 2px solid Highlight;
    forced-color-adjust: none;
  }

  :focus-visible {
    outline-color: Highlight;
  }

  .dot {
    background: CanvasText;
  }

  .btn.is-loading::after {
    border-color: CanvasText;
    border-right-color: transparent;
  }

  .table tr.is-new > :first-child {
    border-left: 3px solid Highlight;
  }

  .tile--stretched:focus-within,
  .item-list__item--link:focus-within {
    outline-color: Highlight;
  }

  .item-list__item.is-new {
    border-left: 3px solid Highlight;
  }

  .diff__old,
  .diff__new {
    border-left-color: CanvasText;
  }

  .tile__thumb,
  .photo-card img {
    border: 1px solid CanvasText;
  }

  .table--grouped tbody + tbody {
    border-top-color: CanvasText;
  }
}

@media print {
  .sidebar,
  .topbar,
  .bottom-nav,
  .no-print {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .shell {
    display: block;
  }

  .card {
    border-color: #cccccc;
    background: #ffffff;
  }
}

/* ---------- MT-05: QR codes, labels, Zebra printing ---------- */

/* K35: QR thumbnail and placeholder (device page "Kod QR"). */
.qr--sm {
  padding: var(--space-2);
}

.qr--sm img {
  width: 120px;
  height: 120px;
}

.qr-placeholder {
  display: inline-grid;
  place-items: center;
  align-content: center;
  gap: var(--space-2);
  width: 136px;
  height: 136px;
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--radius);
  color: var(--c-text-muted);
  font-size: 0.88rem;
  text-align: center;
}

.qr-placeholder .icon {
  width: 32px;
  height: 32px;
}

.qr-card__body {
  align-items: flex-start;
  gap: var(--space-5);
}

.qr-card__hint {
  max-width: 136px;
}

.qr-card__manage {
  align-items: center;
}

.qr-card__manage-label {
  display: none;
  margin: 0;
}

@media (max-width: 720px) {
  .qr-card__body {
    justify-content: center;
  }

  .qr-card__actions,
  .qr-card__actions .cluster {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .qr-card__actions .btn,
  .qr-card__actions form {
    width: 100%;
  }

  .qr-card__manage-label {
    display: block;
  }
}

/* K36: exact label preview (white 1-bit raster, 8:5). */
.label-preview {
  margin: 0 0 var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.label-preview img {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  aspect-ratio: 8 / 5;
  background: #ffffff;
  border: 1px solid var(--c-border-strong);
  border-radius: 4px;
  image-rendering: pixelated;
}

.label-preview figcaption {
  color: var(--c-text-muted);
  font-size: 0.88rem;
}

.label-page {
  align-items: start;
}

.label-page__dpi > form {
  align-items: end;
  margin-top: var(--space-2);
}

@media (max-width: 720px) {
  .label-page__pdf {
    width: 100%;
    justify-content: center;
    background: var(--g-accent);
    color: var(--c-accent-text);
  }
}

/* K37: tile selection for batch labels. */
.tile--selectable .tile__title-row {
  padding-right: calc(var(--touch) - var(--space-2));
}

.tile__select {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  cursor: pointer;
}

.tile__select input {
  width: 20px;
  height: 20px;
  accent-color: var(--c-accent);
  cursor: pointer;
}

.select-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
}

.select-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.select-bar__error,
.select-bar__note {
  flex-basis: 100%;
  margin: 0;
}

@media (max-width: 720px) {
  .select-bar {
    column-gap: var(--space-2);
  }

  /* MT-18: select-all and the count share one row at 360 px ("Zaznaczono: 14 z 14" never splits). */
  .select-bar__count {
    margin-left: auto;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .select-bar__actions,
  .select-bar__actions .btn {
    width: 100%;
  }
}

/* K38: Zebra printer panel. */
.printer-panel {
  display: grid;
  gap: var(--space-4);
}

.printer-panel__status {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin: 0;
  font-weight: 600;
}

.printer-panel__alert:empty {
  display: none;
}

.printer-panel__actions {
  gap: var(--space-3);
}

.printer-panel [data-zebra-printer] {
  flex: 1 1 12rem;
  width: auto;
}

.printer-panel__settings > div {
  display: grid;
  margin-top: var(--space-2);
}

.printer-panel details > summary {
  cursor: pointer;
  font-weight: 600;
}

.status-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-text-subtle);
}

.status-dot--ready {
  background: var(--c-success);
}

.status-dot--action {
  background: var(--c-warning);
}

.status-dot--stopped {
  background: var(--c-danger);
}

/* K39: progress bar. */
.progress {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 4px;
  background: var(--c-surface-3);
  accent-color: var(--c-accent);
  appearance: none;
}

.progress::-webkit-progress-bar {
  background: var(--c-surface-3);
  border-radius: 4px;
}

.progress::-webkit-progress-value {
  background: var(--c-accent);
  border-radius: 4px;
}

.progress::-moz-progress-bar {
  background: var(--c-accent);
  border-radius: 4px;
}

.table tr[aria-current="true"] {
  background: var(--c-accent-soft);
}

/* K40: public layout (QR pages opened by a phone scan). */
.public-body {
  background: radial-gradient(circle at 50% 0, var(--c-bg-glow) 0, var(--c-bg) 60%);
}

.public {
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--space-4);
  display: grid;
  gap: var(--space-5);
}

.public__brand {
  margin: 0;
  color: var(--c-accent);
  font-size: 1.15rem;
  font-weight: 800;
}

.public__main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  overflow-wrap: anywhere;
}

.public__eyebrow {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.public__title {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
}

.public__intro p {
  margin: var(--space-1) 0 0;
}

.public__actions {
  display: grid;
  gap: var(--space-2);
}

.public__actions .btn {
  min-height: 48px;
  justify-content: center;
}

.public__footer {
  color: var(--c-text-muted);
  font-size: 0.94rem;
}

.public__address {
  display: grid;
  gap: var(--space-1);
  font-style: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .public-body {
    font-size: 1.0625rem;
  }
}

@media (min-width: 721px) {
  .public {
    padding: var(--space-5);
  }
}

@media (forced-colors: active) {
  .label-preview img,
  .qr-placeholder,
  .tile__select input {
    border: 1px solid CanvasText;
  }

  .progress::-moz-progress-bar,
  .progress::-webkit-progress-value {
    background: Highlight;
  }

  .status-dot {
    border: 1px solid CanvasText;
  }
}

/* ---------- MT-08: jobs, timers, technician panel ---------- */

.nowrap {
  white-space: nowrap;
}

.pre-wrap {
  white-space: pre-wrap;
}

.btn--xl {
  min-height: 56px;
  font-size: 1.1rem;
  font-weight: 800;
}

.choice-grid--separated {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--c-border);
}

.detail-header__sub {
  margin: var(--space-1) 0 var(--space-3);
}

.facts--compact {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.facts--compact .facts__item {
  padding: var(--space-2) var(--space-3);
}

.facts--compact .facts__item dd {
  font-size: 1rem;
}

@media (max-width: 720px) {
  .facts__item--desktop {
    display: none;
  }
}

/* Panel header and sections (/moje-zlecenia) */
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
}

.panel-head p {
  margin: 0;
}

.panel-head__state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.panel-section {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  scroll-margin-top: calc(var(--topbar-height) + var(--space-3));
}

.panel-section__title {
  margin: 0;
  font-size: 1.15rem;
}

.panel-section__subtitle {
  margin: var(--space-3) 0 0;
  color: var(--c-text-muted);
  font-size: 0.95rem;
}

.panel-section > p {
  margin: 0;
}

/* K43 job card */
.job-card {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  scroll-margin-top: calc(var(--topbar-height) + var(--space-3));
}

.job-card p {
  margin: 0;
}

.job-card--current {
  border-color: var(--c-accent);
  box-shadow: inset 4px 0 0 var(--c-accent);
}

.job-card--private {
  border-color: var(--c-info);
  box-shadow: inset 4px 0 0 var(--c-info);
}

.job-card--closed {
  opacity: 0.85;
  background: var(--c-surface-2);
}

.job-card--details {
  margin-bottom: var(--space-4);
}

.job-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.job-card__planned {
  color: var(--c-text-muted);
  font-weight: 700;
}

.job-card__title {
  margin: 0;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.job-card__meta,
.job-card__source,
.job-card__device-more {
  color: var(--c-text-muted);
  font-size: 0.92rem;
}

.job-card__device,
.job-card__address {
  display: grid;
  gap: var(--space-1);
}

.job-card__address {
  justify-items: start;
}

.job-card__device-name,
.job-card__address-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  overflow-wrap: anywhere;
}

.job-card__note {
  padding: var(--space-3);
  border-left: 3px solid var(--c-info);
  border-radius: var(--radius-sm);
  background: var(--c-info-soft);
}

.job-card__note-title {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.job-card__note-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.job-card__note-more[open] + .job-card__note-text,
.job-card__note-more[open] ~ .clamp-3 {
  display: none;
}

.job-card__note-more summary,
.job-card__more > summary,
.travel-kind > summary {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
  color: var(--c-accent);
  font-weight: 700;
}

.job-card__more > summary {
  justify-content: center;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
}

.job-card__more[open] > summary {
  margin-bottom: var(--space-3);
}

.job-card__work {
  display: grid;
  gap: var(--space-3);
}

.job-card__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.job-card__links a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--touch);
}

.job-card__danger-zone {
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-border);
}

.job-card__readonly,
.job-card__flag-text,
.job-card__closed-note {
  color: var(--c-text-muted);
}

.job-card--upcoming {
  padding: 0;
}

.job-card--upcoming > summary {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.job-card--upcoming .job-card__body {
  display: grid;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-4);
}

/* K44 actions */
.job-actions {
  display: grid;
  gap: var(--space-3);
}

.job-actions__secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
}

.job-actions__state {
  font-weight: 700;
}

.job-actions form {
  margin: 0;
}

/* K45 running timer */
.run-timer {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent);
}

.run-timer--private {
  background: var(--c-info-soft);
  border-color: var(--c-info);
}

.run-timer p {
  margin: 0;
}

.run-timer__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
}

.run-timer__value {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.run-timer__meta {
  color: var(--c-text-muted);
}

/* K50 travel kind */
.travel-kind > summary {
  font-weight: 400;
  color: var(--c-text);
}

.travel-kind > summary strong {
  color: var(--c-accent);
}

.travel-kind .field {
  margin-top: var(--space-2);
}

/* K47 time totals */
.time-totals {
  display: grid;
  margin: 0 0 var(--space-3);
}

.time-totals__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--c-border);
}

.time-totals__row dt {
  margin: 0;
}

.time-totals__row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.time-totals__row--total {
  font-weight: 800;
  border-bottom-color: var(--c-border-strong);
}

/* K46 timeline */
.job-timeline__day {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 1rem;
}

.job-timeline {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.job-timeline__row {
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.job-timeline__row--event {
  border-left-color: var(--c-border);
  background: transparent;
}

.job-timeline__row--running {
  border-left-color: var(--c-accent);
}

.job-timeline__row--flagged {
  border-left-color: var(--c-warning);
}

.job-timeline__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.job-timeline__time,
.job-timeline__dur {
  font-variant-numeric: tabular-nums;
}

.job-timeline__time {
  font-weight: 700;
}

.job-timeline__detail {
  margin: var(--space-1) 0 0;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  .job-card,
  .job-card__more > summary {
    transition: none;
  }
}

@media (forced-colors: active) {
  .job-card,
  .run-timer,
  .job-card__note,
  .job-timeline__row {
    border: 1px solid CanvasText;
  }

  .job-card--current,
  .job-timeline__row--running,
  .job-timeline__row--flagged {
    border-width: 3px;
    box-shadow: none;
  }
}

/* ===== MT-09 workday and approvals (K51–K62) ===== */

/* K57 flash with an action: phone below the text, desktop at the end of the text block. */
.flash:has(.alert__action) {
  flex-wrap: wrap;
}

.alert__action {
  display: flex;
  margin: 0;
}

@media (max-width: 720px) {
  .flash:has(.alert__action) .alert__action {
    flex-basis: 100%;
    padding-left: calc(1.25rem + var(--space-3));
  }
}

/* K51 day card (in the MT-08 slot of the panel head). */
.day-card {
  flex: 1 1 100%;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  scroll-margin-top: calc(var(--topbar-height) + var(--space-3));
}

.day-card p {
  margin: 0;
}

.day-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.day-card__title {
  margin: 0;
  font-size: 1.05rem;
}

.day-card__totals {
  font-variant-numeric: tabular-nums;
}

.day-card__action {
  display: flex;
}

.day-card__action > form {
  display: flex;
}

.day-card__action .btn {
  min-height: 48px;
}

@media (max-width: 720px) {
  .day-card__action,
  .day-card__action > form,
  .day-card__action .btn {
    width: 100%;
  }

  .day-card__action .btn {
    white-space: normal;
  }
}

.day-card__note {
  padding: var(--space-3);
  border-left: 3px solid var(--c-warning);
  border-radius: var(--radius-sm);
  background: var(--c-warning-soft);
}

.day-card__note-title {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.day-card__earlier {
  font-size: 0.9rem;
}

.day-card__footer a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--touch);
  font-weight: 700;
}

.day-detail__actions {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.day-detail__actions:empty {
  display: none;
}

.day-detail__actions p {
  margin: 0;
}

.day-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 0;
}

.day-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-1) 0 0;
}

/* K52 balance text: word + icon, never colour only. */
.balance {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-2);
}

.balance__main {
  font-weight: 700;
}

.balance__note {
  flex-basis: 100%;
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.balance--missing .balance__main,
.balance--missing > .icon,
.balance--warning .balance__main,
.balance--warning > .icon {
  color: var(--c-warning);
}

.balance--extra .balance__main,
.balance--extra > .icon,
.balance--ok .balance__main,
.balance--ok > .icon {
  color: var(--c-success);
}

.balance--info .balance__main,
.balance--info > .icon {
  color: var(--c-info);
}

.balance--muted .balance__main {
  color: var(--c-text-muted);
  font-weight: 600;
}

/* K54 day and week summary rows (extend K47). */
.time-totals__row dd .balance {
  justify-content: flex-end;
  text-align: right;
  white-space: normal;
}

.time-totals__note {
  font-size: 0.85rem;
  font-weight: 400;
}

.time-totals__of {
  font-weight: 400;
}

.time-totals__row--sentence dd,
.time-totals__row--note dd {
  white-space: normal;
}

.time-totals__footer {
  margin: 0 0 var(--space-1);
  font-size: 0.9rem;
}

@media (max-width: 959px) {
  .time-totals__row--desktop {
    display: none;
  }
}

.balance-help > summary {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--c-accent);
  font-weight: 700;
}

.balance-help p {
  margin: var(--space-2) 0 0;
  color: var(--c-text-muted);
}

/* K59 week header and navigation. */
.week-head {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.week-head__title {
  margin: 0;
  font-size: 1.2rem;
}

.week-head__number {
  font-size: 0.95rem;
  font-weight: 400;
}

.week-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.week-nav .btn {
  min-height: var(--touch);
}

.week-nav__current {
  border-color: var(--c-accent);
  cursor: default;
}

@media (max-width: 400px) {
  .week-nav {
    flex-wrap: nowrap;
  }

  .week-nav .btn {
    flex: 1 1 0;
    min-width: var(--touch);
    padding-inline: var(--space-2);
  }

  .week-nav__long {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* MT-11 fix (screenshot check): on desktop the week table no longer breaks words letter by letter ("PRAC A",
   "Poniedział ek", "Roboc zy"): `.content { overflow-wrap: anywhere }` shrank its min-content, so the auto table layout
   squeezed the columns. Words wrap at spaces only; numbers, badges and column titles stay on one line. */
@media (min-width: 721px) {
  .week-table :is(th, td) {
    overflow-wrap: normal;
  }

  .week-table :is(.table__num, thead th, .badge) {
    white-space: nowrap;
  }
}

/* K53 week rows: the today row carries the accent border (plus "(dziś)" and aria-current). */
.week-table__today > td:first-child {
  box-shadow: inset 3px 0 0 var(--c-accent);
}

@media (max-width: 720px) {
  .week-table__today {
    box-shadow: inset 3px 0 0 var(--c-accent);
  }

  .week-table__today > td:first-child {
    box-shadow: none;
  }

  .week-table tfoot th {
    display: block;
    padding: var(--space-3) var(--space-4) 0;
  }
}

.week-table tfoot th,
.week-table tfoot td {
  font-weight: 700;
}

.week-picker {
  margin-top: var(--space-4);
}

/* D2 warning page. */
.submit-warning__list {
  display: grid;
  gap: var(--space-2);
}

.submit-warning__item {
  overflow-wrap: anywhere;
}

/* K56 decision card and the office two-column layout. */
.day-office {
  display: grid;
  gap: var(--space-4);
  align-items: start;
  margin-bottom: var(--space-4);
}

@media (min-width: 960px) {
  .day-office:has(.decision) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.day-office > .card {
  margin: 0;
}

.decision__form {
  display: grid;
  gap: var(--space-3);
}

.decision__ack {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-warning);
  border-radius: var(--radius-sm);
  background: var(--c-warning-soft);
}

.decision__ack--error {
  border-width: 2px;
}

.decision__hint {
  margin: 0 0 var(--space-1);
  padding-left: calc(22px + var(--space-3));
}

@media (max-width: 720px) {
  .decision__actions {
    display: grid;
  }
}

/* K58 job context line of the day timeline. */
.job-timeline__job {
  margin: var(--space-1) 0 0;
  overflow-wrap: anywhere;
}

/* Office list: week shortcuts under the dates. */
.filter-bar__shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.filter-bar__shortcuts .btn {
  min-height: var(--touch);
}

/* K60 unit input. */
.input-unit {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.input-unit__unit {
  flex: none;
  color: var(--c-text-muted);
  white-space: nowrap;
}

@media (forced-colors: active) {
  .day-card,
  .day-card__note,
  .decision__ack {
    border: 1px solid CanvasText;
  }

  .balance > .icon {
    fill: CanvasText;
  }
}

/* ===== MT-10 leave and absence (K64–K76) ===== */

/* K64 balance card: four figures, 2 x 2 on phones, one row from 520 px. */
.leave-balance__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.leave-balance__head .card__title {
  margin: 0;
}

.leave-balance {
  container-type: inline-size;
}

.leave-balance__figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}

/* Four in a row only where every label fits on one line (the card is half the page next to the form). */
@container (min-width: 34rem) {
  .leave-balance__figures {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.leave-balance__item {
  display: grid;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.leave-balance__item dt {
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.leave-balance__item dd {
  margin: 0;
}

.leave-balance__item--main {
  border-left: 3px solid var(--c-accent);
}

.leave-balance__item--main .leave-balance__value {
  font-weight: 800;
}

.leave-balance__item--over {
  border-left-color: var(--c-warning);
}

.leave-balance__item--over dt {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--c-warning);
}

.leave-balance__value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.leave-balance__unit {
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.leave-balance__line {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0 0 var(--space-2);
}

.leave-balance__ondemand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.leave-balance__label {
  font-weight: 600;
}

.leave-balance__meter {
  display: inline-flex;
  gap: 3px;
}

.leave-balance__segment {
  width: 18px;
  height: 10px;
  border: 1px solid var(--c-border-strong);
  border-radius: 3px;
}

.leave-balance__segment--on {
  border-color: var(--c-accent);
  background: var(--c-accent);
}

.leave-balance__details {
  margin-top: var(--space-3);
}

.leave-balance__details summary {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  cursor: pointer;
  font-weight: 600;
}

.leave-balance__details p {
  margin: var(--space-2) 0 0;
}

.leave-balance__note {
  white-space: pre-wrap;
}

/* K66 request form. */
.leave-form-card > summary {
  list-style: none;
  cursor: pointer;
}

.leave-form-card > summary::-webkit-details-marker {
  display: none;
}

.leave-form-card > summary .card__title {
  margin: 0 0 var(--space-3);
}

.leave-form-card:not([open]) > summary .card__title {
  margin: 0;
}

.leave-form-card > summary .card__title::after {
  content: " ▸";
  color: var(--c-text-muted);
}

.leave-form-card[open] > summary .card__title::after {
  content: " ▾";
}

.leave-form__dates {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.leave-form__dates .form__row {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
}

.leave-types {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.leave-preview {
  padding: var(--space-3);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.leave-preview p {
  margin: 0;
}

.leave-preview p + p {
  margin-top: var(--space-1);
}

@media (max-width: 720px) {
  .leave-form__submit {
    width: 100%;
  }
}

/* K67 own list and the leave tables. */
.leave-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-3);
}

.leave-section-head__title {
  margin: 0;
}

/* The year picker is the shared filter-bar row, beside the section title (a definite width: a shrink-to-fit form
   would be measured without the fields' flex basis and wrap its action; no bottom margin); on
   phones it takes the full width under the title like any filter-bar row. */
.leave-year {
  flex: 0 1 20rem;
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .leave-year {
    flex: 1 1 100%;
  }
}

.leave-table .badge,
.leave-table .table__actions .btn {
  white-space: nowrap;
}

@media (min-width: 721px) {
  .leave-table .table__num {
    white-space: nowrap;
  }
}

.leave-history {
  margin-top: var(--space-2);
}

.leave-history > summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  cursor: pointer;
  font-weight: 600;
}

.leave-table tr:target {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.leave-tabs {
  margin-bottom: var(--space-4);
}

/* K71 period navigation (month / year). */
.period-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}

.period-nav .btn {
  min-height: var(--touch);
}

.period-nav__current {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.leave-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* K68 job conflicts. */
.leave-conflicts__list {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.leave-conflicts__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--c-border);
}

.leave-conflicts__main {
  display: flex;
  flex: 1 1 16rem;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  min-width: 0;
}

.leave-details {
  margin-bottom: var(--space-4);
}

.alert + .leave-top {
  margin-top: var(--space-4);
}

.leave-total {
  margin: 0;
  font-weight: 600;
}

/* K70 month calendar: the table scrolls inside its card, never the page. */
.leave-calendar__hint,
.leave-calendar__legend {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: 0.88rem;
}

@media (min-width: 961px) {
  .leave-calendar__hint {
    display: none;
  }
}

.leave-calendar__wrap {
  overflow-x: auto;
}

.leave-calendar {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.leave-calendar th,
.leave-calendar td {
  border-bottom: 1px solid var(--c-border);
  text-align: center;
}

.leave-calendar__name {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 7rem;
  max-width: 9rem;
  padding: var(--space-2);
  background: var(--c-surface);
  text-align: left;
}

.leave-calendar__person {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leave-calendar__day {
  min-width: 2rem;
  padding: var(--space-1) 2px;
  font-weight: 600;
  line-height: 1.2;
}

.leave-calendar__day--off,
.leave-calendar__cell--off {
  background-image: repeating-linear-gradient(135deg, var(--c-surface-2) 0 4px, transparent 4px 8px);
}

.leave-calendar__day--today {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.leave-calendar__cell {
  width: 2rem;
  min-width: 2rem;
  height: var(--touch);
  padding: 0;
  font-weight: 700;
}

.leave-calendar__cell a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--touch);
  color: inherit;
  text-decoration: none;
}

.leave-calendar__cell--vacation,
.leave-calendar__cell--on_demand {
  background-color: var(--c-accent-soft);
}

.leave-calendar__cell--sick,
.leave-calendar__cell--care {
  background-color: var(--c-info-soft);
}

.leave-calendar__cell--unpaid,
.leave-calendar__cell--other {
  background-color: var(--c-surface-3);
}

.leave-calendar__cell--pending {
  outline: 1px dashed var(--c-border-strong);
  outline-offset: -3px;
}

/* K72 approvers. */
.approver-row--missing > td:first-child {
  box-shadow: inset 3px 0 0 var(--c-warning);
}

.approver-list {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.approver-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.approver-list__item--inactive > span:first-child {
  color: var(--c-text-muted);
  text-decoration: line-through;
}

.approver-rows {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.approver-rows__item {
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-border);
}

.approver-rows__name {
  margin: 0 0 var(--space-2);
}

.approver-rows__forms,
.approver-rows__rights {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.approver-rights {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/* K73 days off. */
.days-off {
  margin: 0;
  padding: 0;
  list-style: none;
}

.days-off__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--c-border);
}

.days-off__date {
  grid-column: 1 / -1;
  color: var(--c-text-muted);
  font-size: 0.88rem;
}

.days-off__name {
  min-width: 0;
}

.days-off__tags,
.days-off__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.days-off__actions:empty {
  display: none;
}

@media (min-width: 721px) {
  .days-off__item {
    grid-template-columns: 14rem minmax(0, 1fr) auto auto;
  }

  .days-off__date {
    grid-column: auto;
    font-size: inherit;
  }
}

.days-off__item--disabled .days-off__name {
  color: var(--c-text-muted);
}

.days-off__disable {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

/* P1 technician panel line ("Masz zatwierdzony urlop: …"). */
.panel-head__notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
}

@media (forced-colors: active) {
  .leave-balance__segment--on {
    background: CanvasText;
  }

  .leave-calendar__cell--pending,
  .leave-calendar__day--off,
  .leave-calendar__cell--off {
    border: 1px solid CanvasText;
  }
}

/* ---------- MT-11: planner, pending orders, technician jobs, catalogue requests ---------- */

.form--narrow {
  max-width: 36rem;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.steps-line {
  margin: 0 0 var(--space-1);
  font-size: 1.1rem;
}

/* The step title sits on its description line (4 px) but keeps a block distance from a form or an alert. */
.steps-line + :is(form, .alert, .filter-bar) {
  margin-top: var(--space-3);
}

.or-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-2);
  color: var(--c-text-muted);
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--c-border);
}

@media (max-width: 720px) {
  .btn--block-phone {
    width: 100%;
    justify-content: center;
  }
}

/* K25: the new-device fields follow their radio (no JS; browsers without :has() show them). */
.tech-device:has([data-controls="new-device"]:not(:checked)) [data-depends-on="new-device"],
.catalog-device:has([data-controls="catalog-new-device"]:not(:checked)) [data-depends-on="catalog-new-device"] {
  display: none;
}

.tech-device .choice-grid--separated,
.catalog-device .choice-grid--separated {
  grid-auto-flow: row dense;
}

.tech-device [data-depends-on="new-device"],
.catalog-device [data-depends-on="catalog-new-device"] {
  grid-column: 1 / -1;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--c-border);
}

/* The approval hint only when a new customer or device is involved. */
.form:not(:has([name="Form.NewCustomer"])):not(:has([data-controls="new-device"]:checked)) .tech-form__approval {
  display: none;
}

.own-job {
  margin-top: var(--space-3);
}

.own-job__blocked {
  margin-top: var(--space-3);
}

.job-card__marker {
  margin: var(--space-1) 0;
}

.pending-table__meta {
  display: block;
}

.pending-table td,
.pending-table th {
  overflow-wrap: normal;
}

.pending-table__service {
  min-width: 9rem;
}

.pending-table__device {
  min-width: 8rem;
}

.catalog-review {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-4) 0;
}

.catalog-review > .card {
  margin: 0;
}

.catalog-review .form-section__title {
  margin-top: var(--space-4);
}

@media (min-width: 1100px) {
  .catalog-review {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    align-items: start;
  }
}

.catalog-review__outcome {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  color: var(--c-text-muted);
}

.catalog-review__reject {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.catalog-review__reject-summary {
  color: var(--c-danger);
  font-weight: 700;
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
}

/* Planner toolbar (K86). */
.planner-toolbar {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.planner-toolbar__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.planner-toolbar__actions {
  margin-left: auto;
}

.planner-toolbar__actions .btn .badge {
  min-height: 0;
  padding-block: 0;
}

.planner-toolbar__state {
  margin: 0;
}

.planner-jump {
  margin-top: var(--space-4);
}

/* K77 week grid (> 720 px) and the phone list (≤ 720 px) render from the same view model. */
.planner-list {
  display: none;
}

.planner-week__wrap,
.planner-day__wrap {
  /* The wide grid scrolls inside its frame and never widens the page; "relative" keeps the visually hidden texts
     (absolutely positioned) inside the scroll frame. */
  position: relative;
  contain: inline-size;
}

.planner-week__wrap {
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}

.planner-week {
  width: 100%;
  min-width: 72rem;
  border-collapse: collapse;
  table-layout: fixed;
}

.planner-week th,
.planner-week td {
  padding: var(--space-2);
  border: 1px solid var(--c-border);
  vertical-align: top;
  text-align: left;
}

.planner-week thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--c-surface-2);
  font-size: 0.85rem;
}

.planner-week__corner,
.planner-week__person {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 9.5rem;
  background: var(--c-surface-2);
}

.planner-week__corner {
  z-index: 3;
}

.planner-week__person {
  font-size: 0.9rem;
}

.planner-week__name,
.planner-week__load,
.planner-week__weekday,
.planner-week__date,
.planner-week__today,
.planner-week__holiday {
  display: block;
}

.planner-week__load {
  font-size: 0.8rem;
  font-weight: 400;
}

.planner-week__today {
  color: var(--c-accent);
}

.planner-week__holiday-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.planner-week__day.is-weekend {
  color: var(--c-text-muted);
}

.planner-week .is-narrow {
  width: 4.5rem;
}

.planner-week .is-today {
  border-top: 3px solid var(--c-accent);
}

.planner-week__cell {
  min-height: 6rem;
}

.planner-week__cell > * + * {
  margin-top: var(--space-2);
}

.planner-week__cell.is-holiday,
.planner-day__absence {
  background-image: repeating-linear-gradient(135deg, var(--c-surface-2) 0 4px, transparent 4px 8px);
}

.planner-week__add {
  width: 100%;
  justify-content: center;
}

.planner-week__none {
  margin: 0;
  font-size: 0.8rem;
}

.planner-absence {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  margin: 0;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background-image: repeating-linear-gradient(135deg, var(--c-surface-3) 0 4px, var(--c-surface-2) 4px 8px);
  font-size: 0.8rem;
  font-weight: 700;
}

.is-drop-target {
  outline: 2px dashed var(--c-accent);
  outline-offset: -2px;
}

.is-drop-refused {
  outline: 2px dashed var(--c-danger);
  outline-offset: -2px;
}

.planner-drop-label {
  position: fixed;
  z-index: var(--z-menu);
  max-width: 20rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--c-surface-3);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  pointer-events: none;
}

.planner-drop-label--refused {
  color: var(--c-danger);
}

.planner-ghost {
  position: fixed;
  z-index: var(--z-menu);
  width: 12rem;
  opacity: 0.85;
  pointer-events: none;
}

/* MT-11 fix: a movable card is grabbed, not selected or dragged as a link by the browser (planner.js K82). */
@media (min-width: 721px) {
  .planner[data-can-plan] .plan-card[data-movable="true"] {
    -webkit-touch-callout: none;
    user-select: none;
  }

  .planner[data-can-plan] .plan-card[data-movable="true"] .plan-card__link {
    -webkit-user-drag: none;
  }
}

.planner-dragging,
.planner-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.plan-card.is-armed {
  outline: 2px solid var(--c-accent);
  outline-offset: 1px;
}

/* K78 planner card. */
.plan-card {
  position: relative;
  padding: var(--space-2);
  padding-right: 1.75rem;
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: 0.82rem;
  line-height: 1.3;
}

.plan-card p {
  margin: 0;
}

.plan-card,
.planner-absence,
.planner-week th {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: auto;
}

.plan-card .badge {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.plan-card__time {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.plan-card__grip {
  margin-left: auto;
  color: var(--c-text-muted);
  cursor: grab;
}

.plan-card__customer {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 700;
}

.plan-card__link {
  color: var(--c-text);
  text-decoration: none;
}

.plan-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.plan-card__link:focus-visible {
  outline: none;
}

.plan-card:has(.plan-card__link:focus-visible) {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.plan-card__meta,
.plan-card__address,
.plan-card__number {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-card .plan-card__replan {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  color: var(--c-warning);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Grid cards keep a column for the "Przenieś…" icon at the top only; the marker line may use it. */
@media (pointer: fine) {
  .plan-card:not(.plan-card--phone) .plan-card__replan {
    margin-right: -1.4rem;
  }
}

.plan-card__missing {
  color: var(--c-warning);
}

.plan-card--pending-customer .plan-card__customer {
  font-weight: 400;
}

.plan-card__move {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  z-index: 1;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
}

.plan-card__move:hover,
.plan-card__move:focus-visible {
  background: var(--c-surface-3);
  color: var(--c-accent);
}

.plan-card__move-text {
  display: none;
}

@media (pointer: coarse) {
  .plan-card {
    padding-right: var(--space-2);
  }

  .plan-card__move {
    position: relative;
    top: auto;
    right: auto;
    display: inline-flex;
    gap: var(--space-1);
    width: auto;
    height: var(--touch);
    margin-top: var(--space-1);
  }

  .plan-card__move-text {
    display: inline;
  }

  .plan-card__grip {
    display: none;
  }
}

.plan-card--open,
.plan-card--private {
  border-left-color: var(--c-border-strong);
}

.plan-card--driving,
.plan-card--working {
  border-left-color: var(--c-accent);
}

.plan-card--arrived {
  border-left-color: var(--c-info);
}

.plan-card--private {
  border-left-color: var(--c-warning);
}

.plan-card--completed {
  border-left-color: var(--c-success);
}

.plan-card--canceled {
  border-left-color: var(--c-text-subtle);
}

.plan-card--replan {
  border-left-color: var(--c-warning);
}

.plan-card--closed,
.plan-card--canceled {
  color: var(--c-text-muted);
}

.plan-card--canceled .plan-card__time .nowrap {
  text-decoration: line-through;
}

.plan-card--placeholder {
  border-style: dashed;
  opacity: 0.75;
}

.plan-card--open-end {
  border-bottom-style: dashed;
}

.plan-card.is-dragging {
  border-style: dashed;
  opacity: 0.5;
}

.plan-card.is-moved {
  outline: 2px solid var(--c-accent);
  outline-offset: 1px;
}

.plan-card[aria-busy="true"] {
  opacity: 0.6;
}

.plan-card__resize {
  position: absolute;
  right: 0;
  bottom: -6px;
  left: 0;
  z-index: 1;
  height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ns-resize;
}

.plan-card__resize::before {
  content: "";
  position: absolute;
  right: 30%;
  bottom: 5px;
  left: 30%;
  height: 3px;
  border-radius: 2px;
  background: var(--c-border-strong);
}

.plan-card__resize:focus-visible::before,
.plan-card__resize:hover::before {
  background: var(--c-accent);
}

/* Planner day (K80): a CSS grid per technician, one row per 15 minutes (no inline styles, open point 5). */
.planner-day__wrap {
  overflow: auto;
  max-height: 80vh;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}

.planner-day {
  --slot: 1.5rem;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: auto auto;
  grid-template-columns: 4.5rem;
  grid-auto-columns: minmax(13rem, 1fr);
  width: 100%;
  min-width: min-content;
}

/* Column contents (long, unwrapped card texts) must not size the columns. */
.planner-day__head,
.planner-day__col {
  contain: inline-size;
}

.planner-day__corner,
.planner-day__head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--space-2);
  border-bottom: 1px solid var(--c-border);
  border-left: 1px solid var(--c-border);
  background: var(--c-surface-2);
}

.planner-day__corner {
  left: 0;
  z-index: 3;
  border-left: 0;
}

.planner-day__head p {
  margin: 0;
}

.planner-day__name {
  font-weight: 700;
}

.planner-day__load {
  font-size: 0.8rem;
}

.planner-day__nostart {
  display: grid;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}

.planner-day__axis,
.planner-day__col {
  display: grid;
  grid-auto-rows: var(--slot);
}

.planner-day__axis {
  position: sticky;
  left: 0;
  z-index: 1;
  grid-template-columns: 1fr;
  background: var(--c-surface-2);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.planner-day__hour {
  grid-column: 1;
  padding: 0 var(--space-1);
  border-top: 1px solid var(--c-border);
  color: var(--c-text-muted);
}

.planner-day__now-label {
  grid-column: 1;
  white-space: nowrap;
  font-size: 0.7rem;
  z-index: 1;
  align-self: start;
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--c-accent);
  color: var(--c-accent-text);
  font-weight: 700;
}

.planner-day__col {
  gap: 0 2px;
  padding: 0 2px;
  border-left: 1px solid var(--c-border);
  background-image: repeating-linear-gradient(to bottom, var(--c-border) 0 1px, transparent 1px calc(var(--slot) * 4));
}

.planner-day__col--lanes-1 {
  grid-template-columns: minmax(0, 1fr) 0.6rem;
}

.planner-day__col--lanes-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr)) 0.6rem;
}

.planner-day__col--lanes-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr)) 0.6rem;
}

.planner-day__spacer {
  grid-column: 1;
  pointer-events: none;
}

.planner-day__col .plan-card {
  overflow: hidden;
  margin: 1px 0;
}

.plan-card--short .plan-card__customer,
.plan-card--short .plan-card__meta {
  display: none;
}

.planner-day__now {
  z-index: 2;
  align-self: start;
  height: 0;
  border-top: 2px solid var(--c-accent);
  pointer-events: none;
}

.planner-actual {
  margin: 1px 0;
  border-radius: 3px;
  background: var(--c-success);
}

.planner-actual--running {
  background-image: repeating-linear-gradient(135deg, var(--c-accent) 0 4px, transparent 4px 8px);
  background-color: transparent;
  border: 1px solid var(--c-accent);
}

.tl-lane-1 { grid-column: 1; }
.tl-lane-2 { grid-column: 2; }
.tl-lane-3 { grid-column: 3; }
.tl-lane-full { grid-column: 1 / -1; }
.tl-lane-actual { grid-column: -2 / -1; }

.planner-day__col--lanes-1 .plan-card--block.tl-lane-1 {
  grid-column: 1;
}

/* Planner status bar (K83). */
.planner-status {
  position: sticky;
  bottom: var(--space-3);
  z-index: var(--z-menu);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 40rem;
  margin: var(--space-3) auto 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border-strong);
  border-left: 4px solid var(--c-info);
  border-radius: var(--radius);
  background: var(--c-surface-3);
  box-shadow: var(--shadow);
}

.planner-status[hidden] {
  display: none;
}

.planner-status__text {
  flex: 1;
  margin: 0;
}

.planner-status--success {
  border-left-color: var(--c-success);
}

.planner-status--warning {
  border-left-color: var(--c-warning);
}

.planner-status--danger {
  border-left-color: var(--c-danger);
}

/* Legend (§3.8, §4.1). */
.planner-legend {
  margin-top: var(--space-4);
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.planner-legend summary {
  cursor: pointer;
  font-weight: 700;
}

.planner-legend__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.planner-legend__list li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.planner-legend__hatch,
.planner-legend__plan,
.planner-legend__actual,
.planner-legend__running,
.planner-legend__now {
  display: inline-block;
  width: 1rem;
  height: 0.75rem;
  border-radius: 2px;
}

.planner-legend__hatch {
  background-image: repeating-linear-gradient(135deg, var(--c-surface-3) 0 3px, var(--c-surface-2) 3px 6px);
}

.planner-legend__plan {
  border: 1px solid var(--c-border-strong);
  border-left-width: 4px;
}

.planner-legend__actual {
  width: 0.4rem;
  background: var(--c-success);
}

.planner-legend__running {
  width: 0.4rem;
  border: 1px solid var(--c-accent);
  background-image: repeating-linear-gradient(135deg, var(--c-accent) 0 2px, transparent 2px 4px);
}

.planner-legend__now {
  height: 0;
  border-top: 2px solid var(--c-accent);
}

/* K84 preview: the popover (aria-hidden, informational only) and the fallback page. */
.planner-popover {
  position: fixed;
  z-index: var(--z-menu);
  width: 22rem;
  max-width: calc(100vw - 24px);
  max-height: 70vh;
  overflow: auto;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-surface-2);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
}

.planner-popover[hidden] {
  display: none;
}

.job-preview p {
  margin: 0 0 var(--space-1);
}

.job-preview__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.job-preview__title {
  margin: var(--space-3) 0 var(--space-1);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-muted);
}

.job-preview__note {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

.planner-preview-page .job-preview__note {
  display: block;
  overflow: visible;
}

.job-preview__warning {
  color: var(--c-warning);
}

@media (max-width: 720px) {
  .planner-week__wrap,
  .planner-day__wrap,
  .planner-status {
    display: none;
  }

  .planner-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .planner-list__day {
    grid-template-columns: minmax(0, 1fr);
  }

  .planner-list__chips {
    position: relative;
    overflow-x: auto;
  }

  .planner-list__chips ul {
    display: flex;
    gap: var(--space-2);
    margin: 0;
    padding: 0 0 var(--space-2);
    list-style: none;
  }

  .planner-list__chip {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 var(--space-3);
    border: 1px solid var(--c-border-strong);
    border-radius: 999px;
    color: var(--c-text);
    text-decoration: none;
    white-space: nowrap;
  }

  .planner-list__chip.is-today {
    border-color: var(--c-accent);
    color: var(--c-accent);
  }

  .planner-list__day {
    display: grid;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--c-border);
    scroll-margin-top: calc(var(--topbar-height) + var(--space-2));
  }

  .planner-list__title {
    margin: 0;
    font-size: 1rem;
  }

  .planner-list__person {
    margin: var(--space-2) 0 0;
    font-size: 0.9rem;
  }

  .planner-list__absence,
  .planner-list__actual,
  .planner-list__idle {
    margin: 0;
  }

  .planner-preview-page__actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (forced-colors: active) {
  .plan-card,
  .planner-actual,
  .planner-absence {
    border: 1px solid CanvasText;
  }

  .planner-day__now {
    border-top-color: Highlight;
  }
}

/* Generated: timeline rows (1 = the first quarter-hour of the visible window). */
.tl-at-1 { grid-row-start: 1; }
.tl-at-2 { grid-row-start: 2; }
.tl-at-3 { grid-row-start: 3; }
.tl-at-4 { grid-row-start: 4; }
.tl-at-5 { grid-row-start: 5; }
.tl-at-6 { grid-row-start: 6; }
.tl-at-7 { grid-row-start: 7; }
.tl-at-8 { grid-row-start: 8; }
.tl-at-9 { grid-row-start: 9; }
.tl-at-10 { grid-row-start: 10; }
.tl-at-11 { grid-row-start: 11; }
.tl-at-12 { grid-row-start: 12; }
.tl-at-13 { grid-row-start: 13; }
.tl-at-14 { grid-row-start: 14; }
.tl-at-15 { grid-row-start: 15; }
.tl-at-16 { grid-row-start: 16; }
.tl-at-17 { grid-row-start: 17; }
.tl-at-18 { grid-row-start: 18; }
.tl-at-19 { grid-row-start: 19; }
.tl-at-20 { grid-row-start: 20; }
.tl-at-21 { grid-row-start: 21; }
.tl-at-22 { grid-row-start: 22; }
.tl-at-23 { grid-row-start: 23; }
.tl-at-24 { grid-row-start: 24; }
.tl-at-25 { grid-row-start: 25; }
.tl-at-26 { grid-row-start: 26; }
.tl-at-27 { grid-row-start: 27; }
.tl-at-28 { grid-row-start: 28; }
.tl-at-29 { grid-row-start: 29; }
.tl-at-30 { grid-row-start: 30; }
.tl-at-31 { grid-row-start: 31; }
.tl-at-32 { grid-row-start: 32; }
.tl-at-33 { grid-row-start: 33; }
.tl-at-34 { grid-row-start: 34; }
.tl-at-35 { grid-row-start: 35; }
.tl-at-36 { grid-row-start: 36; }
.tl-at-37 { grid-row-start: 37; }
.tl-at-38 { grid-row-start: 38; }
.tl-at-39 { grid-row-start: 39; }
.tl-at-40 { grid-row-start: 40; }
.tl-at-41 { grid-row-start: 41; }
.tl-at-42 { grid-row-start: 42; }
.tl-at-43 { grid-row-start: 43; }
.tl-at-44 { grid-row-start: 44; }
.tl-at-45 { grid-row-start: 45; }
.tl-at-46 { grid-row-start: 46; }
.tl-at-47 { grid-row-start: 47; }
.tl-at-48 { grid-row-start: 48; }
.tl-at-49 { grid-row-start: 49; }
.tl-at-50 { grid-row-start: 50; }
.tl-at-51 { grid-row-start: 51; }
.tl-at-52 { grid-row-start: 52; }
.tl-at-53 { grid-row-start: 53; }
.tl-at-54 { grid-row-start: 54; }
.tl-at-55 { grid-row-start: 55; }
.tl-at-56 { grid-row-start: 56; }
.tl-at-57 { grid-row-start: 57; }
.tl-at-58 { grid-row-start: 58; }
.tl-at-59 { grid-row-start: 59; }
.tl-at-60 { grid-row-start: 60; }
.tl-at-61 { grid-row-start: 61; }
.tl-at-62 { grid-row-start: 62; }
.tl-at-63 { grid-row-start: 63; }
.tl-at-64 { grid-row-start: 64; }
.tl-at-65 { grid-row-start: 65; }
.tl-at-66 { grid-row-start: 66; }
.tl-at-67 { grid-row-start: 67; }
.tl-at-68 { grid-row-start: 68; }
.tl-at-69 { grid-row-start: 69; }
.tl-at-70 { grid-row-start: 70; }
.tl-at-71 { grid-row-start: 71; }
.tl-at-72 { grid-row-start: 72; }
.tl-at-73 { grid-row-start: 73; }
.tl-at-74 { grid-row-start: 74; }
.tl-at-75 { grid-row-start: 75; }
.tl-at-76 { grid-row-start: 76; }
.tl-at-77 { grid-row-start: 77; }
.tl-at-78 { grid-row-start: 78; }
.tl-at-79 { grid-row-start: 79; }
.tl-at-80 { grid-row-start: 80; }
.tl-at-81 { grid-row-start: 81; }
.tl-at-82 { grid-row-start: 82; }
.tl-at-83 { grid-row-start: 83; }
.tl-at-84 { grid-row-start: 84; }
.tl-at-85 { grid-row-start: 85; }
.tl-at-86 { grid-row-start: 86; }
.tl-at-87 { grid-row-start: 87; }
.tl-at-88 { grid-row-start: 88; }
.tl-at-89 { grid-row-start: 89; }
.tl-at-90 { grid-row-start: 90; }
.tl-at-91 { grid-row-start: 91; }
.tl-at-92 { grid-row-start: 92; }
.tl-at-93 { grid-row-start: 93; }
.tl-at-94 { grid-row-start: 94; }
.tl-at-95 { grid-row-start: 95; }
.tl-at-96 { grid-row-start: 96; }
.tl-len-1 { grid-row-end: span 1; }
.tl-len-2 { grid-row-end: span 2; }
.tl-len-3 { grid-row-end: span 3; }
.tl-len-4 { grid-row-end: span 4; }
.tl-len-5 { grid-row-end: span 5; }
.tl-len-6 { grid-row-end: span 6; }
.tl-len-7 { grid-row-end: span 7; }
.tl-len-8 { grid-row-end: span 8; }
.tl-len-9 { grid-row-end: span 9; }
.tl-len-10 { grid-row-end: span 10; }
.tl-len-11 { grid-row-end: span 11; }
.tl-len-12 { grid-row-end: span 12; }
.tl-len-13 { grid-row-end: span 13; }
.tl-len-14 { grid-row-end: span 14; }
.tl-len-15 { grid-row-end: span 15; }
.tl-len-16 { grid-row-end: span 16; }
.tl-len-17 { grid-row-end: span 17; }
.tl-len-18 { grid-row-end: span 18; }
.tl-len-19 { grid-row-end: span 19; }
.tl-len-20 { grid-row-end: span 20; }
.tl-len-21 { grid-row-end: span 21; }
.tl-len-22 { grid-row-end: span 22; }
.tl-len-23 { grid-row-end: span 23; }
.tl-len-24 { grid-row-end: span 24; }
.tl-len-25 { grid-row-end: span 25; }
.tl-len-26 { grid-row-end: span 26; }
.tl-len-27 { grid-row-end: span 27; }
.tl-len-28 { grid-row-end: span 28; }
.tl-len-29 { grid-row-end: span 29; }
.tl-len-30 { grid-row-end: span 30; }
.tl-len-31 { grid-row-end: span 31; }
.tl-len-32 { grid-row-end: span 32; }
.tl-len-33 { grid-row-end: span 33; }
.tl-len-34 { grid-row-end: span 34; }
.tl-len-35 { grid-row-end: span 35; }
.tl-len-36 { grid-row-end: span 36; }
.tl-len-37 { grid-row-end: span 37; }
.tl-len-38 { grid-row-end: span 38; }
.tl-len-39 { grid-row-end: span 39; }
.tl-len-40 { grid-row-end: span 40; }
.tl-len-41 { grid-row-end: span 41; }
.tl-len-42 { grid-row-end: span 42; }
.tl-len-43 { grid-row-end: span 43; }
.tl-len-44 { grid-row-end: span 44; }
.tl-len-45 { grid-row-end: span 45; }
.tl-len-46 { grid-row-end: span 46; }
.tl-len-47 { grid-row-end: span 47; }
.tl-len-48 { grid-row-end: span 48; }
.tl-len-49 { grid-row-end: span 49; }
.tl-len-50 { grid-row-end: span 50; }
.tl-len-51 { grid-row-end: span 51; }
.tl-len-52 { grid-row-end: span 52; }
.tl-len-53 { grid-row-end: span 53; }
.tl-len-54 { grid-row-end: span 54; }
.tl-len-55 { grid-row-end: span 55; }
.tl-len-56 { grid-row-end: span 56; }
.tl-len-57 { grid-row-end: span 57; }
.tl-len-58 { grid-row-end: span 58; }
.tl-len-59 { grid-row-end: span 59; }
.tl-len-60 { grid-row-end: span 60; }
.tl-len-61 { grid-row-end: span 61; }
.tl-len-62 { grid-row-end: span 62; }
.tl-len-63 { grid-row-end: span 63; }
.tl-len-64 { grid-row-end: span 64; }
.tl-len-65 { grid-row-end: span 65; }
.tl-len-66 { grid-row-end: span 66; }
.tl-len-67 { grid-row-end: span 67; }
.tl-len-68 { grid-row-end: span 68; }
.tl-len-69 { grid-row-end: span 69; }
.tl-len-70 { grid-row-end: span 70; }
.tl-len-71 { grid-row-end: span 71; }
.tl-len-72 { grid-row-end: span 72; }
.tl-len-73 { grid-row-end: span 73; }
.tl-len-74 { grid-row-end: span 74; }
.tl-len-75 { grid-row-end: span 75; }
.tl-len-76 { grid-row-end: span 76; }
.tl-len-77 { grid-row-end: span 77; }
.tl-len-78 { grid-row-end: span 78; }
.tl-len-79 { grid-row-end: span 79; }
.tl-len-80 { grid-row-end: span 80; }
.tl-len-81 { grid-row-end: span 81; }
.tl-len-82 { grid-row-end: span 82; }
.tl-len-83 { grid-row-end: span 83; }
.tl-len-84 { grid-row-end: span 84; }
.tl-len-85 { grid-row-end: span 85; }
.tl-len-86 { grid-row-end: span 86; }
.tl-len-87 { grid-row-end: span 87; }
.tl-len-88 { grid-row-end: span 88; }
.tl-len-89 { grid-row-end: span 89; }
.tl-len-90 { grid-row-end: span 90; }
.tl-len-91 { grid-row-end: span 91; }
.tl-len-92 { grid-row-end: span 92; }
.tl-len-93 { grid-row-end: span 93; }
.tl-len-94 { grid-row-end: span 94; }
.tl-len-95 { grid-row-end: span 95; }
.tl-len-96 { grid-row-end: span 96; }

/* ---------- MT-13: DISPO checklists (K100 segmented, K101 checklist, K102 status bar, K105 entries) ---------- */

/* K100: single choice of 2–4 short options with tones (/dev/ui#segmented). Native radios, visually hidden, placed
   before their labels. The container query switches 2 × 2 (narrow) and 1 × 4. */
.segmented {
  container: segmented / inline-size;
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.segmented__label {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.segmented__label + .field__hint {
  margin-top: calc(var(--space-1) - var(--space-2));
}

.segmented__options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.segmented__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0;
}

.segmented__option {
  --tone: var(--c-text-muted);
  --tone-soft: var(--c-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-input-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  overflow-wrap: break-word;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.segmented__option .icon {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--tone);
}

.segmented__option--success {
  --tone: var(--c-success);
  --tone-soft: var(--c-success-soft);
}

.segmented__option--warning {
  --tone: var(--c-warning);
  --tone-soft: var(--c-warning-soft);
}

.segmented__option--danger {
  --tone: var(--c-danger);
  --tone-soft: var(--c-danger-soft);
}

.segmented__option--info {
  --tone: var(--c-info);
  --tone-soft: var(--c-info-soft);
}

.segmented__option--muted {
  --tone: var(--c-text-muted);
  --tone-soft: var(--c-surface-3);
}

@media (hover: hover) and (pointer: fine) {
  .segmented__input:not(:disabled) + .segmented__option:hover {
    border-color: var(--c-border-strong);
  }
}

.segmented__input:checked + .segmented__option {
  padding: calc(var(--space-2) - 1px) calc(var(--space-3) - 1px);
  border: 2px solid var(--tone);
  background: var(--tone-soft);
  font-weight: 700;
}

.segmented__input:focus-visible + .segmented__option,
.segmented__option.is-forced-focus {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.segmented__input:disabled + .segmented__option {
  opacity: 0.6;
  cursor: not-allowed;
}

/* One row of four: the icon goes above the label, so whole words ("Niesprawne", "Nie dotyczy") fit an option of
   ≈ 100 px instead of breaking letter by letter beside the icon. */
@container segmented (min-width: 440px) {
  .segmented__options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .segmented__option {
    flex-direction: column;
    gap: var(--space-1);
    padding-inline: var(--space-1);
  }

  .segmented__input:checked + .segmented__option {
    padding-inline: calc(var(--space-1) - 1px);
  }

  /* MT-15 CR-01: two options (Pozytywny / Negatywny) keep the icon beside the label and a readable width (≤ 12rem
     each) instead of stretching over the whole line; the four-option layout above is unchanged. */
  .segmented__options:has(> .segmented__option:nth-of-type(2):last-of-type) {
    grid-template-columns: repeat(2, minmax(0, 12rem));
  }

  .segmented__options:has(> .segmented__option:nth-of-type(2):last-of-type) > .segmented__option {
    flex-direction: row;
    gap: var(--space-2);
    padding-inline: var(--space-3);
  }

  .segmented__options:has(> .segmented__option:nth-of-type(2):last-of-type) > .segmented__input:checked + .segmented__option {
    padding-inline: calc(var(--space-3) - 1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .segmented__option {
    transition: none;
  }
}

/* K101: summary card. Desktop: text left, counter and state right, the bar under both; phone: the counter on the bar's
   line. */
.checklist-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "text count"
    "text state"
    "bar bar";
  column-gap: var(--space-4);
  align-items: start;
}

.checklist-summary__text {
  grid-area: text;
  min-width: 0;
}

.checklist-summary__text p {
  margin: 0;
  overflow-wrap: anywhere;
}

.checklist-summary__title {
  margin: 0;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.checklist-summary__count {
  grid-area: count;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: right;
}

.checklist-summary__state {
  grid-area: state;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  margin: var(--space-1) 0 0;
  font-size: 0.92rem;
}

.checklist-summary__bar {
  grid-area: bar;
  margin-top: var(--space-3);
}

.checklist-summary__warn {
  color: var(--c-warning);
}

.checklist-summary__done {
  color: var(--c-success);
}

@media (max-width: 720px) {
  .checklist-summary {
    grid-template-areas:
      "text text"
      "bar count"
      "state state";
    align-items: center;
  }

  .checklist-summary__count {
    margin-top: var(--space-3);
    font-size: 1rem;
  }

  .checklist-summary__state {
    justify-content: flex-start;
    margin-top: var(--space-2);
  }
}

/* K101: editable sections and items. */
.checklist__section {
  overflow: visible;
}

.checklist__form {
  display: block;
}

.checklist__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--c-border);
}

.checklist__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.checklist__head-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

@media (max-width: 720px) {
  .checklist__head-end {
    flex: 1 1 100%;
    justify-content: space-between;
  }
}

.checklist__errors {
  padding: var(--space-3) var(--space-4) 0;
}

.checklist__errors .validation-summary {
  margin: 0;
}

.checklist__item {
  container: checklist-item / inline-size;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  scroll-margin-top: calc(var(--topbar-height) + var(--space-3));
}

.checklist__item + .checklist__item {
  border-top: 1px solid var(--c-border);
}

.checklist__item:target,
.checklist__item.is-targeted {
  box-shadow: inset 3px 0 0 var(--c-accent);
}

@container checklist-item (min-width: 720px) {
  .checklist__item > .segmented {
    grid-template-columns: minmax(0, 1fr) 30rem;
    column-gap: var(--space-4);
    align-items: start;
  }

  .checklist__item > .segmented > .checklist__line,
  .checklist__item > .segmented > .checklist__hint {
    grid-column: 1;
  }

  .checklist__item > .segmented > .segmented__options {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

.checklist__line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
}

.checklist__hint {
  margin: 0;
}

/* CR-15: label → hint 4 px (title–subtitle pair, UX §3.2) in both layouts; the item grid gap is 8 px. */
.checklist__line + .checklist__hint {
  margin-top: calc(var(--space-1) - var(--space-2));
}

.checklist__state {
  flex: none;
  color: var(--c-text-muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.checklist__state > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.checklist__state--saved .icon {
  color: var(--c-success);
}

.checklist__state--warning {
  color: var(--c-warning);
}

.checklist__state--danger {
  color: var(--c-danger);
}

.checklist__desc {
  display: none;
}

.checklist__item:has(.segmented__input[value="fault"]:checked, .segmented__input[value="repaired"]:checked) .checklist__desc {
  display: grid;
}

.checklist__desc--missing .input {
  border-color: var(--c-warning);
}

.checklist__desc--missing .field__hint {
  color: var(--c-warning);
}

.checklist__desc-actions {
  display: flex;
  margin-top: var(--space-1);
}

.checklist__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--c-border);
}

.checklist__pick {
  margin: 0;
}

/* K102: status bar (form-actions with a status text and one button). */
.form-actions--status {
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.form-actions__status {
  margin: 0;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--c-text-muted);
}

.form-actions__status--success {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--c-success);
}

.form-actions__status--danger {
  color: var(--c-danger);
}

.form-actions--status > .btn {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .form-actions--sticky.form-actions--status {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
  }

  .form-actions--sticky.form-actions--status > .btn {
    grid-column: auto;
  }
}

/* K101: read-only table (coordinator, locked, closed, versions). */
.checklist-table__missing {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--c-warning);
}

.table__primary .checklist-table__number {
  display: none;
}

/* The item label keeps a readable width; the description column takes the rest. */
@media (min-width: 721px) {
  .checklist-table .table__primary-cell {
    min-width: 16rem;
  }
}

@media (max-width: 720px) {
  .table__primary .checklist-table__number {
    display: inline;
  }
}

/* K105: entry on the technician card and on the coordinator job page. */
.checklist-entry {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-border);
}

.checklist-entry p {
  margin: 0;
}

.checklist-entry__title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
}

.checklist-entry__button {
  justify-self: start;
}

@media (max-width: 720px) {
  .checklist-entry__button {
    justify-self: stretch;
  }
}

.checklist-entry__none {
  align-items: center;
  margin-bottom: var(--space-4);
}

.checklist-entry__none p {
  margin: 0;
}

/* Gallery only: a forced 320 px wrapper (K100 sample 5). */
.gallery-narrow {
  max-width: 320px;
}

/* Profile card (UX §5.2). */
.checklist-profile p {
  margin: 0;
}

.checklist-profile .filter-bar {
  margin: var(--space-2) 0 0;
}

/* The profile options are long ("Automatycznie (napęd elektryczny)"): the select may grow past the kit's 18rem. */
.checklist-profile .filter-bar__main > .field {
  max-width: 26rem;
}

/* Template draft editor (UX §7.3). */
.draft-table__section {
  font-weight: 700;
}

/* CR-11: the section header row is split into cells under "Kolejność" and the actions column; the cells share the
   group header surface. */
.draft-table__section-row > td {
  background: var(--c-surface-2);
}

.table--grouped .draft-table__section-row > th[scope="rowgroup"] {
  vertical-align: middle;
}

@media (max-width: 720px) {
  .draft-table__section-row {
    border-radius: var(--radius-sm);
    background: var(--c-surface-2);
  }

  .table--responsive .draft-table__section-row > td.table__actions {
    margin-top: 0;
    padding: 0 var(--space-2);
    border-top: 0;
  }

  .table--responsive .draft-table__section-row > td.draft-table__section-rename {
    padding-bottom: var(--space-2);
  }
}

/* "Edytuj" and "Usuń" stay side by side on the desktop row. */
@media (min-width: 721px) {
  .draft-table .table__actions > .cluster {
    flex-wrap: nowrap;
  }
}

.draft-removed > summary {
  cursor: pointer;
  font-weight: 600;
}

.draft-removed[open] > summary {
  margin-bottom: var(--space-3);
}

.draft-add:has([data-controls="new-section"] option[value="__new__"]:not(:checked)) [data-depends-on="new-section"] {
  display: none;
}

.draft-add__fallback {
  display: none;
}

@supports not selector(:has(*)) {
  .draft-add__fallback {
    display: block;
  }
}

/* "Zalecenia do wyceny" (UX §9). */
.quote-table__text p {
  margin: 0;
}

/* 1280 px: the customer and device share one column (customer on at most two lines, the full name in its title;
   the serial never breaks), so neither is squeezed to one word per line; the clamped recommendation text takes the
   rest and "Odrzuć…" stays inside the card. */
/* .table__client is shared by the MT-15 billing list. */
.table__client > * {
  display: block;
}

.table__client > .clamp-2 {
  display: -webkit-box;
}

@media (min-width: 721px) {
  .table__client {
    min-width: 13rem;
    max-width: 18rem;
  }

  .quote-table__text {
    min-width: 14rem;
  }
}

/* Phone cards: "Odrzuć…" takes the card width (UX §9.3). */
@media (max-width: 720px) {
  .quote-table td.table__actions .btn {
    width: 100%;
  }
}

.quote-table__more > summary {
  cursor: pointer;
  color: var(--c-accent);
}

.quote-table__more[open] {
  margin-top: var(--space-1);
}

.quote-table__text:has(.quote-table__more[open]) > p[aria-hidden] {
  display: none;
}

/* ---------- MT-14: service protocol, signature pad, documents (K108–K119) ---------- */

/* K113 summary card (generalises the K101 summary): text left, badge + meta right (tops equal); phones one column. */
.job-doc-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-4);
  align-items: start;
}

.job-doc-summary__text {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.job-doc-summary__text p {
  margin: 0;
  overflow-wrap: anywhere;
}

.job-doc-summary__title {
  margin: 0;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.job-doc-summary__state {
  display: grid;
  justify-items: end;
  gap: var(--space-1);
  text-align: right;
}

.job-doc-summary__meta {
  margin: 0;
  font-size: 0.9rem;
}

@media (max-width: 720px) {
  .job-doc-summary {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--space-3);
  }

  .job-doc-summary__state {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    text-align: left;
  }
}

/* A filter-bar row that is the last block of a card section needs no bottom margin (MTH, e-mail, logo rows). */
.form-section > .filter-bar:last-child,
.mail-send > .filter-bar,
.logo-card > .filter-bar {
  margin-bottom: 0;
}

/* K108 signature pad (ux-review §3.2): white paper surface 2:1, dashed when empty, green with ink, red on error. */
.signature-pad {
  display: grid;
  min-width: 0;
  max-width: 36rem;
}

.signature-pad__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--touch);
}

.signature-pad__label {
  margin: 0;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--c-text);
}

.signature-pad__clear {
  flex: none;
}

.signature-pad__surface {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  margin-top: var(--space-2);
  border: 2px dashed var(--c-input-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: border-color 0.15s ease;
}

.signature-pad[data-state="inked"] .signature-pad__surface {
  border-style: solid;
  border-color: var(--c-success);
}

.signature-pad[data-state="error"] .signature-pad__surface {
  border-style: solid;
  border-color: var(--c-danger);
}

.signature-pad__canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  touch-action: none;
  overscroll-behavior: contain;
  cursor: crosshair;
}

.signature-pad__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 1rem;
  pointer-events: none;
}

.signature-pad__placeholder::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 70%;
  border-top: 1px solid #9ca3af;
}

.signature-pad[data-state="inked"] .signature-pad__placeholder {
  display: none;
}

.signature-pad > .field__hint {
  margin-top: var(--space-1);
}

.signature-pad__status {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 1.35em;
  margin: var(--space-1) 0 0;
  font-size: 0.84rem;
  color: var(--c-success);
}

.signature-pad__status.field__error {
  color: var(--c-danger);
}

.signature-pad.is-locked .signature-pad__canvas {
  pointer-events: none;
}

.signature-pad.is-locked .signature-pad__surface {
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .signature-pad__surface {
    transition: none;
  }
}

/* K110 issue list: text left, the fix link right (wraps under the text on phones, same left edge). */
.issue-list__body {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.issue-list__body > p {
  margin: 0;
}

.issue-list__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.issue-list__items {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.issue-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-2);
}

.issue-list__item > span {
  flex: 1 1 16rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.issue-list__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

/* K109 parts editor: a table when the editor is at least 50rem wide, cards below, from the same markup. A container
   query, not the viewport: on a tablet (or a gallery column) the fixed columns would squeeze the name column to nothing. */
.parts-editor {
  container-type: inline-size;
}

.parts-editor__header {
  align-items: baseline;
}

.parts-editor__count,
.parts-editor__empty {
  margin: 0;
}

.parts-editor__table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.parts-editor__table th {
  padding: 0 var(--space-2) var(--space-1);
  color: var(--c-text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
}

.parts-editor__row > td {
  padding: 6px var(--space-2);
  vertical-align: top;
}

.parts-editor__row .field {
  margin: 0;
}

.parts-editor__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.parts-editor__add {
  margin-top: var(--space-3);
}

.parts-editor__add > p {
  margin: 0;
}

/* CR-13: the name takes the free width; number and QR stay compact (and unbroken, see the cell rules). */
@container (min-width: 50rem) {
  .parts-editor__col-lp {
    width: 2.5rem;
  }

  .parts-editor__col-no,
  .parts-editor__col-qr {
    width: 8rem;
  }

  .parts-editor__col-qty {
    width: 5.5rem;
  }

  .parts-editor__col-unit {
    width: 6rem;
  }

  .parts-editor__col-remove {
    width: 3.5rem;
  }

  .parts-editor__table th:first-child,
  .parts-editor__row > td:first-child {
    padding-left: 0;
  }

  .parts-editor__table th:last-child,
  .parts-editor__row > td:last-child {
    padding-right: 0;
  }

  .parts-editor__row .input {
    width: 100%;
    max-width: none;
  }

  .parts-editor__label,
  .parts-editor__title {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .parts-editor__lp-cell .parts-editor__lp {
    display: flex;
    align-items: center;
    height: 3rem;
  }

  .parts-editor__remove-cell {
    text-align: right;
  }

  /* The remove button and the inputs share the touch height: same top, same centre. */
  .parts-editor__remove {
    margin-top: 0;
  }
}

@container (max-width: 49.99rem) {
  .parts-editor__table thead {
    display: none;
  }

  .parts-editor__table,
  .parts-editor__table tbody {
    display: block;
  }

  .parts-editor__table tbody {
    display: grid;
    gap: var(--space-3);
  }

  .parts-editor__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-surface-2);
  }

  .parts-editor__row > td {
    display: block;
    grid-column: 1 / -1;
    padding: 0;
  }

  .parts-editor__row > .parts-editor__lp-cell {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    align-items: center;
    min-height: var(--touch);
  }

  .parts-editor__row > .parts-editor__remove-cell {
    display: flex;
    grid-column: 2;
    grid-row: 1;
    align-items: center;
    justify-content: flex-end;
  }

  .parts-editor__lp {
    display: none;
  }

  .parts-editor__add-button {
    width: 100%;
  }
}

/* MTH card: the recorded state. */
.mth-recorded {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
}

.mth-recorded > .icon {
  flex: none;
  color: var(--c-success);
}

/* K102 status bar of the draft: the status takes the free space; without a status (no JS) the buttons share the row. */
.form-actions--status > .form-actions__status {
  flex: 1 1 auto;
}

@media (max-width: 720px) {
  .form-actions--sticky.form-actions--status:not(:has(> .form-actions__status:not([hidden]))) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* K113 document preview and note block. */
.doc-preview {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.doc-preview__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.doc-preview__heading {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.doc-preview__eyebrow {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.doc-preview__title {
  margin: 0;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.doc-preview__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.doc-preview__panels {
  display: grid;
  gap: var(--space-3);
}

.doc-preview__panel {
  display: grid;
  align-content: start;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  overflow-wrap: anywhere;
}

.doc-preview__panel h3,
.doc-preview__section h3 {
  margin: 0 0 var(--space-1);
  font-size: 1rem;
  font-weight: 700;
}

.doc-preview__panel p,
.doc-preview__section p {
  margin: 0;
}

.doc-preview__section {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-border);
  overflow-wrap: anywhere;
}

.doc-preview__strong {
  font-weight: 600;
}

/* The section wraps anywhere (long names); the short columns of the parts table must not (the long name squeezed
   "Ilość" and "szt." to single letters): only the name column wraps. */
.doc-preview__parts :is(th, td):not(:nth-child(2)) {
  width: 1%;
  white-space: nowrap;
  overflow-wrap: normal;
}

.doc-preview__parts-list .item-list__item {
  padding-inline: 0;
}

.doc-preview__parts-list .item-list__item:first-child {
  border-top: 0;
}

.doc-preview__checklist > summary {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  color: var(--c-accent);
  cursor: pointer;
}

.doc-preview__checklist-section th {
  background: var(--c-surface-2);
  text-align: left;
}

@media (min-width: 721px) {
  .doc-preview__panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
  }

  .doc-preview__parts-list {
    display: none;
  }
}

@media (max-width: 720px) {
  .doc-preview__parts {
    display: none;
  }

  .doc-preview__actions {
    display: grid;
    width: 100%;
  }
}

.note-block {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.note-block > p {
  margin: 0;
}

.note-block__title {
  font-size: 0.88rem;
  font-weight: 600;
}

.note-block__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  justify-self: start;
}

/* Signing form (ux-review §5.5): the mode reveals its block (works without JS through :has()). */
.signing-form:has(input[name="mode"][value="wniosek"]:checked) [data-mode-block="klient"],
.signing-form:has(input[name="mode"][value="klient"]:checked) [data-mode-block="wniosek"] {
  display: none;
}

.signing__scope {
  margin: 0;
  font-weight: 600;
}

.signing__checks > .check {
  padding-block: var(--space-1);
}

@media (min-width: 721px) {
  .input.signing__signer {
    max-width: 28rem;
  }
}

@media (max-width: 720px) {
  .signing__actions {
    display: grid;
  }

  .doc-entry-card__actions,
  .doc-entry__actions,
  .mail-repeat__actions {
    display: grid;
  }

  .doc-entry-card__actions > .btn,
  .doc-entry__actions > .btn,
  .mail-repeat__actions .btn {
    width: 100%;
  }
}

/* Decision page (K56 extended): approve 3fr / reject 2fr from 1100 px, stacked below. */
@media (min-width: 960px) and (max-width: 1099px) {
  .day-office--split:has(.decision) {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 1100px) {
  .day-office--split:has(.decision + .decision) {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }

  .day-office--split:has(.decision):not(:has(.decision + .decision)) {
    grid-template-columns: minmax(0, 1fr);
  }
}

.decision-signature {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.decision-signature > p {
  margin: 0;
}

.decision-signature__image {
  width: 240px;
  max-width: 100%;
  height: 120px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  object-fit: contain;
}

@media (min-width: 721px) {
  .input.decision__contact {
    max-width: 28rem;
  }
}

/* Archive viewer (ux-review §8). */
.document-viewer__lines p {
  margin: 0;
  overflow-wrap: anywhere;
}

.document-viewer__hash .btn {
  vertical-align: middle;
}

.document-viewer__iframe {
  display: block;
  width: 100%;
  height: 80vh;
  min-height: 32rem;
  border: 0;
  border-radius: inherit;
  background: #ffffff;
}

.document-viewer__mailing {
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

@media (min-width: 721px) {
  .document-viewer__open {
    display: none;
  }
}

@media (max-width: 720px) {
  .document-viewer__frame {
    display: none;
  }

  .document-viewer .detail-header__actions > .btn {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* E-mail page (ux-review §9). */
.mail-send > p,
.mail-send__body > p {
  margin: 0;
}

/* CR-12: a list-item summary keeps the native expand marker; the padding gives the touch height. */
.mail-send__body > summary {
  display: list-item;
  padding-block: calc((var(--touch) - 1.5em) / 2);
  cursor: pointer;
}

.mail-send__body[open] > summary {
  margin-bottom: var(--space-2);
}

.mail-history__address,
.mail-history__error {
  display: block;
  overflow-wrap: anywhere;
}

.mail-history__error {
  margin-top: var(--space-1);
}

.mail-history__addresses {
  display: grid;
  min-width: 0;
}

/* Phones: the label above the addresses, each address on its own full-width line (no "example.c om" breaks). */
@media (max-width: 720px) {
  .table--responsive td.mail-history__recipients {
    display: grid;
    gap: var(--space-1);
    text-align: left;
  }
}

/* K118 error tile of documents. */
.document-error__trace {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

/* K117 company logo card (Platform settings). */
.logo-card {
  display: grid;
  gap: var(--space-4);
}

.logo-card > p,
.logo-card > h2 {
  margin: 0;
}

.logo-card__current {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-4);
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 15rem;
  aspect-ratio: 150 / 68;
  padding: var(--space-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.logo-preview__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-preview__name {
  color: #374151;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}

.logo-card__meta {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.logo-card__meta > p {
  margin: 0;
}

/* A section head groups the title with its help text (the section gap stays between head and body). */
.form-section__head {
  display: grid;
  min-width: 0;
}

.clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Requests list: the reason column gets the free width (no squeezed column). */
@media (min-width: 721px) {
  .signature-requests__reason {
    min-width: 16rem;
  }
}

.signing__modes {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}

/* Shown on phones only (≤ 720 px), e.g. the TOTP hint for enrolling on the phone that holds the app (MT-07).
   Last in the file so it wins over component display rules such as .alert. */
.phone-only {
  display: none;
}

@media (max-width: 720px) {
  .phone-only {
    display: flex;
  }
}

/* ---------- MT-15: service panel, phases, closure, billing, technical results ---------- */

/* K121 phase switcher: one form per phase; the active phase is a paragraph, not a button. */
.phase-switch {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.phase-switch p {
  margin: 0;
}

.phase-switch__title {
  font-weight: 700;
}

.phase-switch__items {
  display: grid;
  gap: var(--space-2);
}

@media (min-width: 721px) {
  .phase-switch__items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.phase-switch__form {
  display: grid;
  margin: 0;
}

.phase-switch__item {
  display: grid;
  align-content: center;
  gap: var(--space-1);
  width: 100%;
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-input-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  color: var(--c-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.phase-switch__item:hover {
  border-color: var(--c-accent);
}

.phase-switch__item--primary {
  border-color: var(--c-accent);
}

.phase-switch .phase-switch__item--active {
  margin: 0;
  border: 2px solid var(--c-accent);
  background: var(--c-accent-soft);
  cursor: default;
}

.phase-switch__label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
}

.phase-switch__meta {
  color: var(--c-text-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.phase-switch__extra.job-actions {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
}

/* K122 visit clock (extends K45). */
.run-timer--waiting {
  background: var(--c-info-soft);
  border-color: var(--c-info);
}

.run-timer__totals {
  color: var(--c-text-muted);
  font-variant-numeric: tabular-nums;
}

.visit-clock {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface-2);
}

.visit-clock p,
.visit-clock__state {
  margin: 0;
}

.visit-clock__state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
}

.visit-clock__state--warning {
  color: var(--c-warning);
}

.visit-clock__totals {
  font-variant-numeric: tabular-nums;
}

.visit-clock__asof {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* K124 requirement rows: state icon + name + state text; the whole row is the link. */
.req-list__item {
  align-items: flex-start;
}

.req-list__icon {
  flex: none;
  margin-top: 2px;
  color: var(--c-text-muted);
}

.req-list__item[data-state="met"] .req-list__icon {
  color: var(--c-success);
}

.req-list__item[data-state="problem"] .req-list__icon {
  color: var(--c-danger);
}

.req-list__item[data-state="pending"] .req-list__icon {
  color: var(--c-info);
}

.req-list__item[data-state="warning"] .req-list__icon {
  color: var(--c-warning);
}

.req-list__body {
  gap: 2px;
}

.req-list__name {
  font-weight: 600;
}

.req-list__state {
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

.req-list__item .item-list__arrow {
  align-self: center;
}

/* K125 consequence list. */
.consequences {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.consequences:empty {
  display: none;
}

.consequences__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--c-accent);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  overflow-wrap: anywhere;
}

.consequences__item .icon {
  flex: none;
  margin-top: 2px;
}

.consequences__item--info {
  border-left-color: var(--c-info);
}

.consequences__item--warning {
  border-left-color: var(--c-warning);
}

.consequences__item--problem {
  border-left-color: var(--c-danger);
}

.consequences-card .card__title {
  margin-bottom: var(--space-3);
}

/* K123 billing decision: one column of options; the minutes field follows "Rozlicz część czasu" (K25, no JS). */
.decision__choices {
  grid-template-columns: minmax(0, 1fr);
}

.decision__form:not(:has([data-billing-choice][value="partial"]:checked)) [data-billing-partial] {
  display: none;
}

.billing-entries {
  display: grid;
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
}

.billing-entries__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--c-border);
}

.billing-entries__time,
.billing-entries__dur {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.billing-entries__dur {
  text-align: right;
}

.billing-entries__label {
  overflow-wrap: break-word;
}

@media (max-width: 480px) {
  .billing-entries__row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
  }

  .billing-entries__label {
    grid-column: 1 / -1;
    grid-row: 2;
    color: var(--c-text-muted);
  }
}

/* K130 entry on the technician card and the panel blocks. */
.visit-entry .cluster--between {
  align-items: center;
  gap: var(--space-2);
}

.visit-summary__link {
  margin: 0;
}

/* MT-15: collapsed, the card is one touch-high summary line (as the other collapsible cards), not a padded block. */
.visit-history {
  padding-block: var(--space-1);
}

.visit-history[open] {
  padding-bottom: var(--space-4);
}

.visit-history > .visit-history__summary {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  font-weight: 700;
  cursor: pointer;
}

.visit-history[open] > .visit-history__summary {
  margin-bottom: var(--space-3);
}

.visit-history > p:last-child {
  margin: var(--space-3) 0 0;
}

.confirm-page__list {
  display: grid;
  gap: var(--space-1);
  margin: var(--space-2) 0 0;
  padding-left: 1.2rem;
}

.udt-suggest {
  margin: calc(var(--space-1) - var(--space-3)) 0 0;
}

/* MT-18: the ghost "Wstaw <date>" button lines its text up with the hint above it (no padding indent). */
.udt-suggest .btn--ghost {
  margin-inline-start: -0.75rem;
}

/* MT-18: protocol results table — each line of a cell (next due, document) on its own row at every width. */
.doc-preview__section td.table__cell--stack > span {
  display: block;
}

/* Technical results: task sections follow their checkbox, the details follow a negative result (K25, no JS). */
.technical-form:has([data-controls="service"]:not(:checked)) [data-depends-on="service"],
.technical-form:has([data-controls="insulation"]:not(:checked)) [data-depends-on="insulation"],
.technical-form__task:not(:has(input[value="negative"]:checked)) [data-negative-only] {
  display: none;
}

.technical-form__task {
  display: grid;
  gap: var(--space-3);
}

.technical-form__task > p {
  margin: 0;
}

@media (forced-colors: active) {
  .phase-switch__item,
  .visit-clock,
  .consequences__item {
    border: 1px solid CanvasText;
  }
}

/* ---------- MT-16 K133: photo grid (square thumbnails, container-query columns) ---------- */

.photo-grid {
  container: photo-grid / inline-size;
  min-width: 0;
}

.photo-grid__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-grid--manage .photo-grid__list,
.photo-grid--pick .photo-grid__list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@container photo-grid (min-width: 30rem) {
  .photo-grid--manage .photo-grid__list,
  .photo-grid--pick .photo-grid__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container photo-grid (min-width: 36rem) {
  .photo-grid__list {
    gap: var(--space-3);
  }

  .photo-grid--compact .photo-grid__list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@container photo-grid (min-width: 48rem) {
  .photo-grid--manage .photo-grid__list,
  .photo-grid--pick .photo-grid__list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.photo-grid__item {
  display: flex;
  min-width: 0;
}

.photo-grid__item[hidden] {
  display: none;
}

.photo-grid__item.is-new .photo-tile__img {
  outline: 2px solid var(--c-accent);
}

.photo-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
}

.photo-tile__link {
  display: block;
  border-radius: var(--radius-sm);
  color: inherit;
}

.photo-tile__link:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.photo-tile__img,
.photo-tile__missing {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--c-surface-3);
  outline: 1px solid var(--c-border);
  outline-offset: -1px;
}

.photo-tile__missing {
  display: grid;
  place-items: center;
  color: var(--c-warning);
}

.photo-tile__missing .icon {
  width: 32px;
  height: 32px;
}

/* MT-24 (D1): a legacy photo without its file — muted, dashed, no link. */
.photo-grid__legacy {
  margin-bottom: var(--space-3);
}

.photo-tile--legacy .photo-tile__missing {
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  outline-style: dashed;
}

.photo-tile__legacy {
  font-size: 0.78rem;
}

.photo-tile__caption {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.3;
}

.photo-tile__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.photo-tile__caption .badge {
  justify-self: start;
}

.photo-tile__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: auto;
  padding-top: var(--space-2);
}

.photo-tile__actions > .btn:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.photo-tile__actions .inline-form {
  display: flex;
}

.photo-tile__locked {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 36px;
  margin: auto 0 0;
  padding-top: var(--space-2);
  box-sizing: content-box;
  color: var(--c-text-muted);
  font-size: 0.84rem;
}

@media (pointer: coarse) {
  .photo-tile__locked {
    min-height: var(--touch);
  }
}

.photo-tile__more {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  outline: 1px solid var(--c-border);
  outline-offset: -1px;
  color: var(--c-text);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

.photo-tile__more:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.photo-grid__note {
  margin: var(--space-3) 0 0;
}

/* ---------- MT-16 K137: photo pick (signing preview) ---------- */

.photo-pick {
  position: relative;
  cursor: pointer;
}

.photo-pick__input {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--c-accent);
  box-shadow: 0 0 0 2px #fff;
  border-radius: 4px;
}

.photo-pick__input:checked ~ .photo-tile__img {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.photo-pick__input:not(:checked) ~ .photo-tile__img {
  opacity: 0.45;
}

.photo-pick:has(.photo-pick__input:focus-visible) {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.photo-pick__state {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--c-text-muted);
  font-size: 0.84rem;
}

.photo-pick__state--on {
  color: var(--c-text);
}

.photo-pick__input:not(:checked) ~ .photo-pick__state--on,
.photo-pick__input:checked ~ .photo-pick__state--off {
  display: none;
}

.photo-pick.is-disabled {
  cursor: default;
}

/* ---------- MT-16 K134: lightbox ---------- */

.lightbox {
  --c-surface: #151a20;
  --c-surface-2: #1f262e;
  --c-surface-3: #2a333d;
  --c-text: #f3f4f6;
  --c-text-muted: #9ca3af;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(11 14 17 / 96%);
  color: var(--c-text);
}

.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.lightbox::backdrop {
  background: rgb(0 0 0 / 60%);
}

.lightbox__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}

.lightbox__counter {
  margin: 0;
  color: #e5e7eb;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.lightbox__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0 var(--space-3);
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.lightbox__image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox__problem {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  margin: 0;
}

.lightbox__problem[hidden] {
  display: none;
}

.lightbox__side {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 999px;
}

.lightbox__side--prev {
  left: var(--space-3);
}

.lightbox__side--next {
  right: var(--space-3);
}

.lightbox__side:disabled,
.lightbox__nav .btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.lightbox__footer {
  display: grid;
  gap: var(--space-1);
  max-height: 40dvh;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4) max(12px, env(safe-area-inset-bottom));
}

.lightbox__caption {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lightbox__caption.is-empty {
  color: var(--c-text-muted);
}

.lightbox__meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.84rem;
}

.lightbox__nav {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.lightbox__actions {
  margin-top: var(--space-2);
}

.lightbox__actions:empty {
  display: none;
}

@media (max-width: 720px) {
  .lightbox__side {
    display: none;
  }

  .lightbox__nav {
    display: grid;
  }

  .lightbox__nav .btn,
  .lightbox__actions .btn {
    min-height: var(--touch);
  }
}

/* ---------- MT-16 K135: sort list (one line on desktop, a card per item on phones) ---------- */

.sort-list-wrap {
  container: sort-list / inline-size;
  min-width: 0;
}

.sort-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  list-style: none;
}

.sort-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "body" "meta" "edit";
  row-gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.sort-list__item.is-new {
  border-color: var(--c-accent);
}

.sort-list__head {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--touch);
}

.sort-list__pos {
  display: none;
}

.sort-list__pos-text {
  color: var(--c-text-muted);
  font-size: 0.84rem;
}

.sort-list__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sort-list__controls .reorder__text {
  display: none;
}

.sort-list__controls .reorder .btn--icon {
  width: var(--touch);
  min-width: 0;
  padding: 0;
}

.sort-list__controls .btn {
  min-height: var(--touch);
}

.sort-list__controls .inline-form {
  display: flex;
}

.sort-list__body {
  grid-area: body;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sort-list__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.sort-list__title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.sort-list__help {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.sort-list__meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
  min-width: 0;
}

.sort-list__edit {
  grid-area: edit;
  display: grid;
}

@container sort-list (min-width: 40rem) {
  .sort-list {
    gap: 0;
    padding: 0;
  }

  .sort-list__item {
    grid-template-columns: 2.5rem minmax(0, 1fr) 13rem auto auto;
    grid-template-areas: "pos body meta edit controls";
    align-items: center;
    column-gap: var(--space-3);
    min-height: 56px;
    padding: var(--space-3) var(--space-4);
    border: 0;
    border-top: 1px solid var(--c-border);
    border-radius: 0;
  }

  .sort-list__item:first-child {
    border-top: 0;
  }

  .sort-list__head {
    display: contents;
  }

  .sort-list__pos {
    grid-area: pos;
    display: block;
    justify-self: end;
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .sort-list__pos-text {
    display: none;
  }

  .sort-list__controls {
    grid-area: controls;
  }

  .sort-list__controls .btn,
  .sort-list__controls .reorder .btn--icon {
    width: 36px;
    min-height: 36px;
    height: 36px;
  }

  .sort-list__help {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  .sort-list__edit {
    display: block;
  }
}

/* ---------- MT-16 K144: neutral tone of the segmented control ("Tak / Nie") ---------- */

.segmented__option--accent {
  --tone: var(--c-accent);
  --tone-soft: var(--c-accent-soft);
}

.segmented__options--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@container segmented (max-width: 25rem) {
  .segmented__options--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* The third option ("Bez odpowiedzi") takes the whole second row, so its label stays on one line. */
  .segmented__options--3 > .segmented__option:last-of-type {
    grid-column: 1 / -1;
  }
}

/* "Tak / Nie / Bez odpowiedzi" keeps the icon beside the label and ≤ 12rem per option, like the two-option rule. */
@container segmented (min-width: 440px) {
  .segmented__options--3 {
    grid-template-columns: repeat(3, minmax(0, 12rem));
  }

  .segmented__options--3 > .segmented__option {
    flex-direction: row;
    gap: var(--space-2);
    padding-inline: var(--space-3);
  }

  .segmented__options--3 > .segmented__input:checked + .segmented__option {
    padding-inline: calc(var(--space-3) - 1px);
  }
}

/* ---------- MT-16 K136: upload preparation state ---------- */

.upload-item.is-preparing .upload-item__progress {
  display: block;
}

.upload-item.is-waiting {
  opacity: 0.75;
}

/* ---------- MT-16 K138: document values ---------- */

.doc-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  margin: 0;
}

.doc-values dt {
  color: var(--c-text-muted);
  font-size: 0.84rem;
}

.doc-values dd {
  margin: 0 0 var(--space-2);
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* MT-24: "Protokół (system poprzedni)" card. */
.legacy-protocol__parts {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-left: var(--space-4);
  white-space: normal;
}

/* The list's markup indentation would otherwise render as blank lines under the pre-wrap of .doc-values dd. */
.doc-values dd.legacy-protocol__parts-cell {
  white-space: normal;
}

.legacy-protocol__signature-title {
  margin: 0;
  font-size: 1rem;
}

@media (min-width: 721px) {
  .doc-values {
    grid-template-columns: 14rem minmax(0, 1fr);
    align-items: baseline;
  }

  .doc-values dd {
    margin-bottom: 0;
  }
}

/* ---------- MT-16: photos card, photos page, photo page (ux-review §4.3, §5, §6) ---------- */
.photos-card__body {
  gap: var(--space-4);
}

.photos-card__upload {
  padding-top: var(--space-4);
  border-top: 1px solid var(--c-border);
}

.photos-card__note,
.photos-card__all,
.photos-page__back {
  margin: 0;
}

.photos-card__all a,
.photos-page__back a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
}

.photo-view {
  display: grid;
  gap: var(--space-2);
}

.photo-view__nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.photo-view__counter {
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
}

/* A phone has no room for "Poprzednie · 1 z 5 · Następne" on one line: the counter goes above two equal buttons. */
@media (max-width: 480px) {
  .photo-view__nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-view__counter {
    grid-area: 1 / 1 / auto / -1;
  }

  .photo-view__nav > .btn {
    justify-content: center;
  }
}

.photo-view__img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin-inline: auto;
  border-radius: var(--radius-sm, 4px);
}

.photo-view__caption,
.photo-view__meta,
.photo-view__full {
  margin: 0;
}

.photo-view__caption {
  overflow-wrap: anywhere;
}

.photo-page__delete {
  margin-top: var(--space-2);
}

@media (max-width: 720px) {
  .photos-card__upload .form-actions .btn,
  .photo-page__delete,
  .photo-page__delete .btn {
    width: 100%;
  }
}

/* ---------- MT-16: attachments and documents cards (ux-review §8.1, §10.1) ---------- */
.attachments-card__subtitle {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.attachments-card__form,
.documents-card__assign {
  padding-top: var(--space-4);
  border-top: 1px solid var(--c-border);
}

.documents-card__assign {
  margin-top: 0;
}

.file-list__note {
  margin: 0;
  overflow-wrap: anywhere;
}

/* MT-24 (D1): a legacy attachment — the name without a link, then the shared placeholder under the meta line. */
.file-list__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-list__body > .empty-state--inline {
  margin-top: var(--space-2);
}

/* The row is taller with the placeholder: the icon and the actions stay level with the name, not centred on the row. */
.file-list__item--legacy {
  align-items: flex-start;
}

.file-list__item--legacy .file-list__icon {
  margin-top: 2px;
}

.documents-card__canceled {
  margin-top: var(--space-2);
  padding: 0 var(--space-5) var(--space-4);
}

.documents-card__canceled > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--c-text-muted);
  cursor: pointer;
}

.doc-row .item-list__end {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* ---------- MT-16: document form and approval (ux-review §10.2–§10.4) ---------- */
.document-page__description {
  margin: 0;
  max-width: 60rem;
}

.document-page__danger {
  display: flex;
  justify-content: flex-end;
}

.document-form > .card {
  gap: var(--space-4);
}

.document-form__signatures {
  margin: 0;
}

@media (min-width: 721px) {
  .document-field--text .input {
    max-width: 40rem;
  }

  .approval-form__signer .input {
    max-width: 28rem;
  }
}

@media (max-width: 720px) {
  .document-form__actions .btn,
  .approval-form__actions .btn,
  .document-page__danger .btn {
    width: 100%;
  }

  /* "Dalej: podpisy i zatwierdzenie" does not fit half of a 360 px bar: one button per row (two rows at most). */
  .form-actions--sticky.document-form__actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A phone keeps the document title readable: the state badge moves under the title instead of beside it. */
@media (max-width: 480px) {
  .doc-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-1) var(--space-3);
  }

  .doc-row > .item-list__icon {
    grid-row: 1 / span 2;
    align-self: start;
  }

  .doc-row > .item-list__body {
    grid-area: 1 / 2;
  }

  .doc-row > .item-list__end {
    grid-area: 2 / 2;
    justify-self: start;
  }

  .doc-row > .item-list__arrow {
    grid-area: 1 / 3 / span 2;
  }
}

.template-preview__note {
  margin: 0;
}

/* ---------- MT-16: template admin (ux-review §9) ---------- */
.form__note {
  margin: calc(var(--space-2) * -1) 0 0;
  font-size: 0.875rem;
}

.template-data__types {
  gap: var(--space-2);
}

.template-data__types .check {
  min-height: 44px;
}

.field-form {
  gap: var(--space-4);
}

.field-form__main {
  align-items: start;
}

.field-form__options {
  margin: 0;
}

.field-form__number .input {
  width: 100%;
}

@supports selector(:has(*)) {
  .field-form__fallback {
    display: none;
  }

  .field-form-host:has([data-controls="field-type"] option[value="number"]:not(:checked)) [data-depends-on="number"],
  .field-form-host:has([data-controls="field-type"] option[value="signature"]:not(:checked)) [data-depends-on="signature"] {
    display: none;
  }
}

@media (min-width: 560px) {
  .field-form__roles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.publish-changes {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-left: 1.25rem;
}

/* ---------- MT-17 K150: counter strip (filter links with a count, ux-review §2.4) ---------- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

@media (min-width: 721px) {
  .stat-strip {
    grid-template-columns: repeat(3, minmax(9rem, 13rem));
    gap: var(--space-3);
  }
}

.stat-strip__item {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  min-height: var(--touch);
  padding: var(--space-3);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}

.stat-strip__item:hover {
  color: inherit;
  border-color: rgb(255 155 0 / 55%);
  background: var(--c-surface-3);
}

.stat-strip__item[aria-current] {
  border-color: var(--c-accent);
  box-shadow: inset 0 0 0 1px var(--c-accent);
}

.stat-strip__value {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-strip__item--danger .stat-strip__value {
  color: var(--c-danger);
}

.stat-strip__item--warning .stat-strip__value {
  color: var(--c-warning);
}

.stat-strip__item--zero .stat-strip__value {
  color: var(--c-text-muted);
}

.stat-strip__label {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  overflow-wrap: normal;
  hyphens: none;
}

.stat-strip__item[aria-current] .stat-strip__label {
  font-weight: 700;
}

/* MT-17 K151: a six-column work list on the wide layout (968 px) — the inner cells use half the side padding, the
   first and the last cell keep the card edge (16 px). Desktop only; the phone cards keep the kit padding. */
@media (min-width: 721px) {
  .table--dense th,
  .table--dense td {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }

  .table--dense th:first-child,
  .table--dense td:first-child {
    padding-left: var(--space-4);
  }

  .table--dense th:last-child,
  .table--dense td:last-child {
    padding-right: var(--space-4);
  }
}

/* MT-17: block lines in an action cell ("Zaplanowano:" + job links + hint) wrap between words and keep the
   right edge of the buttons above and below them; on phones each line takes the full width of the action row. */
.table--whole-words .table__actions > .table__meta {
  max-width: 12rem;
  margin-left: auto;
  white-space: normal;
}

@media (max-width: 720px) {
  .table--responsive.table--whole-words td.table__actions > .table__meta {
    flex-basis: 100%;
    max-width: none;
    margin: 0;
  }
}

/* ---------- MT-23 QR fault reports (K240–K244) ---------- */

/* Audit check "gap": an alert inside a public card keeps its distance from the next block (the success card's photo
   warning above "W pilnej sprawie zadzwoń"), and the responsible e-mail form from the body of the "Kod QR" card.
   Margins collapse with an existing margin, so nothing that was spaced moves. */
.public__main .card > .alert:not(:last-child) {
  margin-bottom: var(--space-3);
}

.qr-card > .qr-card__body + .form {
  margin-top: var(--space-4);
}

.public__main .alert ul:not(:last-child) {
  margin-bottom: var(--space-3);
}

/* ---------- MT-19 RESURS (K160–K164) ---------- */

/* K25: the "Ocena resursu" section of the technical results follows its checkbox. */
.technical-form:has([data-controls="resurs"]:not(:checked)) [data-depends-on="resurs"] {
  display: none;
}

/* K160: assessment rows — title + points, a two-option K100 choice and a reason; one aligned grid from 40rem. */
.assess-list {
  container: assess / inline-size;
  display: grid;
  min-width: 0;
}

.assess-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: start;
  min-width: 0;
  padding-block: var(--space-3);
  scroll-margin-top: var(--space-6);
}

.assess-row + .assess-row {
  border-top: 1px solid var(--c-border);
}

.assess-row:target,
.assess-row.is-targeted {
  box-shadow: inset 3px 0 0 var(--c-accent);
}

.assess-row__title {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.assess-row__points {
  margin: 0;
  font-size: 0.875rem;
  white-space: nowrap;
}

.assess-row__choice,
.assess-row__reason {
  grid-column: 1 / -1;
  min-width: 0;
}

.assess-row__reason {
  display: grid;
  gap: var(--space-1);
}

.assess-row__reason-label {
  font-weight: 600;
}

.assess-row__reason-value {
  margin: 0;
  min-width: 0;
}

.assess-row__answer {
  margin: 0;
}

@container assess (min-width: 40rem) {
  .assess-row {
    /* The reason column starts where the second column of a two-column .form__row starts (same gap). */
    grid-template-columns: 12rem max(15rem, calc((100% - var(--space-4)) / 2 - 12rem - var(--space-4))) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: var(--space-4);
    row-gap: var(--space-1);
  }

  .assess-row__choice,
  .assess-row__reason {
    display: contents;
  }

  .assess-row__title { grid-area: 1 / 1; }
  .assess-row__points { grid-area: 2 / 1; }
  .assess-row__choice > .segmented__label { grid-area: 1 / 2; }
  .assess-row__choice > .segmented__options { grid-area: 2 / 2; }
  .assess-row__choice > .assess-row__answer { grid-area: 2 / 2; }
  .assess-row__choice > .field__error { grid-area: 3 / 2; }
  .assess-row__reason-label { grid-area: 1 / 3; }
  .assess-row__reason-value { grid-area: 2 / 3; }
  .assess-row__reason-note { grid-area: 3 / 3; }
}

@supports selector(:has(*)) {
  .assess-row:has(.segmented__input[value="yes"]:checked) [data-when]:not([data-when~="yes"]),
  .assess-row:has(.segmented__input[value="no"]:checked) [data-when]:not([data-when~="no"]),
  .assess-row:not(:has(.segmented__input:checked)) [data-when]:not([data-when~="none"]) {
    display: none;
  }
}

@supports not selector(:has(*)) {
  .assess-row [data-when="yes"],
  .assess-row [data-when="no"] {
    display: none;
  }
}

/* K161: calculation result block (value, nowrap equation tokens, formula, verdict, note). */
.calc-result__body {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.calc-result__value {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.calc-result--threshold .calc-result__value {
  color: var(--c-danger);
}

.calc-result__equation {
  margin: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
}

.calc-result__equation > span {
  white-space: nowrap;
}

.calc-result__formula,
.calc-result__verdict {
  margin: 0;
}

.calc-result__note {
  margin: 0;
  font-size: 0.8rem;
}

.calc-result--flat {
  display: grid;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

.calc-result--flat > .card__header {
  padding: 0;
  border: 0;
}

/* K162: the suggestion button under a hint (the MT-18 .udt-suggest rules for any field). */
.field-suggest {
  margin: calc(var(--space-1) - var(--space-3)) 0 0;
}

.field-suggest .btn--ghost {
  margin-inline-start: -0.75rem;
}

/* K163: the RESURS draft bar on a phone with JS — "Zapisz szkic" and the short "Podgląd i podpis" in equal halves,
   the status on its own row. CR-07: only this bar, and only while the retry button is hidden; the no-JS pair ("Zapisz i
   przejdź do podpisu") and every other K102 bar (the MT-14 protocol draft) keep the K102 rule (primary on its own row). */
@media (max-width: 720px) {
  .resurs-draft__bar:has(> [data-draft-next]:not([hidden])):not(:has(> [data-draft-retry]:not([hidden]))) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .resurs-draft__bar:has(> [data-draft-next]:not([hidden])):not(:has(> [data-draft-retry]:not([hidden]))) > .form-actions__status {
    grid-column: 1 / -1;
  }

  /* Wins over the K102 "third child primary takes the row" rule: both visible buttons keep their halves. */
  .resurs-draft__bar:has(> [data-draft-next]:not([hidden])):not(:has(> [data-draft-retry]:not([hidden]))) > .btn {
    grid-column: auto;
  }
}

/* MT-19: the factor table of the RESURS preview is a list on a phone (doc-preview__parts-list shows it there). */
@media (max-width: 720px) {
  .resurs-factors {
    display: none;
  }
}

/* MT-19: three task checkboxes in the technical results — a wider gap so a long label does not run into the next box. */
.technical-form .choice-grid--inline {
  column-gap: var(--space-6);
}

/* ---------- MT-20 PWA and offline (K180–K185) ---------- */

/* K180 sync bar: the last child of the sticky topbar, on its own flex line, full bleed at its bottom edge. */
.sync-bar {
  --tone: var(--c-info);
  --tone-soft: var(--c-info-soft);
  --sync-line: 36px; /* the action button's height: the first text line is centred on it */
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  column-gap: var(--space-2);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-5);
  background: linear-gradient(var(--tone-soft), var(--tone-soft)), var(--c-surface);
  border-top: 1px solid color-mix(in srgb, var(--tone) 40%, transparent);
}

.sync-bar[hidden] {
  display: none;
}

.sync-bar[data-state="offline"],
.sync-bar[data-state="offline-pending"],
.sync-bar[data-state="auth-login"],
.sync-bar[data-state="auth-reauth"] {
  --tone: var(--c-warning);
  --tone-soft: var(--c-warning-soft);
}

.sync-bar[data-state="refused"] {
  --tone: var(--c-danger);
  --tone-soft: var(--c-danger-soft);
}

.sync-bar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: min(var(--sync-line), 1.5rem + 12px);
  color: var(--tone);
}

.sync-bar__icon .icon {
  width: 20px;
  height: 20px;
}

/* One line: centred on the button; more lines: they start at the top, beside the button (ux §4.2). */
.sync-bar__text {
  min-width: 0;
  min-height: var(--sync-line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sync-bar__text p {
  margin: 0;
}

.sync-bar__title {
  font-weight: 600;
  overflow-wrap: break-word;
}

.sync-bar__detail {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.sync-bar__action .btn {
  white-space: nowrap;
}

.sync-bar__action:empty {
  display: none;
}

.topbar:has(> .sync-bar:not([hidden])) {
  flex-wrap: wrap;
  padding-bottom: 0;
}

.topbar > .sync-bar {
  order: 10;
  flex: 1 0 100%;
  margin-inline: calc(-1 * var(--space-5));
}

html:has(.sync-bar:not([hidden])) {
  scroll-padding-top: calc(var(--topbar-height) + 4.5rem);
}

/* Gallery (standalone) variant. */
.sync-bar--standalone {
  border: 1px solid color-mix(in srgb, var(--tone) 40%, transparent);
  border-radius: var(--radius-sm);
}

@media (max-width: 960px) {
  .sync-bar {
    padding: var(--space-2) var(--space-3);
  }

  .topbar > .sync-bar {
    margin-inline: calc(-1 * var(--space-3));
  }
}

@media (pointer: coarse) {
  .sync-bar {
    --sync-line: var(--touch);
  }
}

@media (max-width: 720px) {
  .sync-bar__long {
    display: none;
  }

  /* ux §4.2: at most 76 px with the longest copy (two title lines and one detail line; the queue has the rest). */
  .sync-bar__title,
  .sync-bar__detail {
    line-height: 1.25;
  }

  .sync-bar__detail {
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  html:has(.sync-bar:not([hidden])) {
    scroll-padding-top: calc(var(--topbar-height) + 6.5rem);
  }
}

/* K181 queue rows: a refused row grows with its message; badge, time and buttons stay on its first line (ux §6.1). */
.sync-queue__table td {
  vertical-align: top;
}

/* K181 queue rows: the server message block. */
.sync-queue__message {
  --tone: var(--c-danger);
  margin-top: var(--space-2);
  border-left: 3px solid var(--tone);
  padding-left: var(--space-3);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.sync-queue__message[data-tone="warning"] {
  --tone: var(--c-warning);
}

.sync-queue__message p {
  margin: 0;
}

.sync-queue__message a {
  display: inline-block;
  margin-top: var(--space-1);
}

/* Review 17: on the phone the refusal reason takes the whole card width, not only the column beside the status badge
   (the first cell spans the card as a subgrid: title and target stay beside the badge, the message goes under both). */
@media (max-width: 720px) {
  .sync-queue__table tbody tr:has(.sync-queue__message:not([hidden])) > td.table__primary-cell {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 1 / span 3;
    grid-template-columns: subgrid;
    grid-template-rows: subgrid;
  }

  .sync-queue__table tbody tr:has(.sync-queue__message:not([hidden])) > td.table__status-cell {
    grid-area: auto;
    grid-column: 2;
    grid-row: 1;
  }

  .sync-queue__table td.table__primary-cell > .table__primary {
    grid-column: 1;
  }

  /* Under the title row the badge takes no room: the target and the reason use the whole card width. */
  .sync-queue__table td.table__primary-cell > :not(.table__primary) {
    grid-column: 1 / -1;
  }
}

/* K182 pending-sync line (the marker is a kit badge). */
.sync-line {
  --tone: var(--c-info);
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  margin: var(--space-2) 0 0;
  font-size: 0.9rem;
}

.sync-line[data-tone="danger"] {
  --tone: var(--c-danger);
}

.sync-line > .icon {
  flex: none;
  margin-top: 0.15rem;
  color: var(--tone);
}

.sync-line > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The overlay swaps the actions inside this wrapper: it adds no box of its own. */
.offline-actions {
  display: contents;
}

.checklist__state--queued {
  color: var(--c-info);
}

/* K183 offline-ready line. */
.offline-ready {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.offline-ready[hidden] {
  display: none;
}

.panel-head > .offline-ready {
  flex: 1 1 100%;
}

.offline-ready__icon {
  flex: none;
  color: var(--c-text-muted);
}

.offline-ready[data-state="done"] .offline-ready__icon {
  color: var(--c-success);
}

.offline-ready[data-state="partial"] .offline-ready__icon,
.offline-ready[data-state="stale"] .offline-ready__icon {
  color: var(--c-warning);
}

.offline-ready__text {
  min-width: 0;
}

.offline-ready__progress {
  width: 8rem;
}

.offline-ready .btn {
  white-space: nowrap;
}

/* Phone: the icon stays beside the text; the button and the progress go under the text (no lone icon row). */
@media (max-width: 720px) {
  .offline-ready {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: var(--space-1);
  }

  .offline-ready[hidden] {
    display: none;
  }

  .offline-ready__progress,
  .offline-ready .btn {
    grid-column: 2;
    justify-self: start;
  }
}

/* K184 install hint. */
.install-hint {
  flex: 1 0 100%;
}

.install-hint__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: 1.05rem;
}

.install-hint p {
  margin: 0;
}

/* MT-21 */
/* A split section head keeps its help text right under the title when the body column is taller (the grid used to
   spread its rows over the whole height, e.g. the GPS notice section). */
.form-section__head {
  align-content: start;
}

/* MT-22 — time verification (K220 state line and actions, K221 badges, the "Wpis" column). */
.job-timeline__state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin: var(--space-2) 0 0;
}

.job-timeline__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.job-timeline__main .badge,
.job-timeline__state .badge,
.table .cluster .badge {
  white-space: nowrap;
}

.time-review__entry {
  min-width: 11rem;
}

/* The weekly report: on a phone the verification badge keeps its own width in the stacked cell. */
.weekly-report td.table__cell--stack > .badge {
  justify-self: start;
}

/* Review round 1 (finding 13): the short "Km" and "Nieobecności" values ("—", "12,5", "2 dni") sit centred under their
   centred titles instead of at the right edge of a column as wide as its title. */
@media (min-width: 721px) {
  .weekly-report .weekly-report__short {
    text-align: center;
  }
}

/* Review round 1 (finding 15): the two words of a week button form one flex item, so they are separated by a normal
   space instead of the button's flex gap (the planner and "Mój czas pracy" keep their markup). */
.week-nav__label {
  white-space: nowrap;
}

/* The week table gained the Km column: the column titles may wrap at spaces ("Przejazd / zaliczony"; the MT-11 rule
   keeps words whole), so "Bilans" keeps a readable width at 1280 px without a sideways scroll. */
@media (min-width: 721px) {
  .table.week-table thead th {
    white-space: normal;
  }

  .week-table td[data-label="Bilans"] {
    min-width: 10rem;
  }
}

@media (max-width: 720px) {
  .job-timeline__actions .btn {
    min-height: var(--touch);
  }
}

/* MT-28 — company assets (ux-review §10).
   K295: fields shown by the asset type. The scope is the form (`[data-variant-scope]`); the controlling radios are inside
   a `[data-variant-control]` wrapper (the shared `_Segmented` cannot put attributes on its inputs). `data-variant` lists
   the type codes (or `none`) an element belongs to. Without `:has()` everything shows; the server drops values that do
   not apply.
   K296: the "Nowa wartość" field of a dictionary picker shows only while "＋ Dodaj wartość…" is selected (shown when
   `:has()` is unsupported).
   K297: the thumbnail cell of the asset list and the muted row of an inactive asset.
   K298: the thumbnail slot of the K135 sort list (asset gallery). */

[data-variant-scope]:has([data-variant-control] input[value="forklift"]:checked) [data-variant]:not([data-variant~="forklift"]),
[data-variant-scope]:has([data-variant-control] input[value="battery"]:checked) [data-variant]:not([data-variant~="battery"]),
[data-variant-scope]:has([data-variant-control] input[value="charger"]:checked) [data-variant]:not([data-variant~="charger"]),
[data-variant-scope]:has([data-variant-control] input[value="accessory"]:checked) [data-variant]:not([data-variant~="accessory"]),
[data-variant-scope]:has([data-variant-control]):not(:has([data-variant-control] input:checked)) [data-variant]:not([data-variant~="none"]),
[data-variant-scope]:has([data-variant-control] input:checked) [data-variant~="none"] {
  display: none;
}

.field:has(> select[data-dictionary]):not(:has(> select[data-dictionary] option[value="__nowa"]:checked)) > [data-dictionary-new] {
  display: none;
}

.field > [data-dictionary-new] {
  margin-top: var(--space-2);
}

.table__media {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.table__media > .table__primary {
  min-width: 0;
}

.table__thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--c-surface-3);
  color: var(--c-text-muted);
}

.table__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table__row--muted > td {
  color: var(--c-text-muted);
}

@media (max-width: 720px) {
  .table__thumb {
    width: 56px;
    height: 56px;
  }
}

.sort-list--thumbs .sort-list__item {
  grid-template-columns: 64px minmax(0, 1fr);
  grid-template-areas: "head head" "thumb body" "thumb meta" "edit edit";
  column-gap: var(--space-3);
}

.sort-list__thumb {
  grid-area: thumb;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--c-surface-3);
  color: var(--c-text-muted);
}

.sort-list__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@container sort-list (min-width: 40rem) {
  .sort-list--thumbs .sort-list__item {
    grid-template-columns: 2.5rem 64px minmax(0, 1fr) 13rem auto auto;
    grid-template-areas: "pos thumb body meta edit controls";
  }
}

/* MT-25 — K250 step strip, K252 square label preview, workshop pages. */
.step-strip {
  container: step-strip / inline-size;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}

.step-strip__summary,
.step-strip__next {
  margin: 0;
  overflow-wrap: break-word;
}

.step-strip__next {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  color: var(--c-text-muted);
}

.step-strip__next .icon {
  flex: none;
  margin-top: 0.2em;
}

.step-strip__list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Compact: equal segments, the text lives in the summary. */
.step-strip__step {
  height: 6px;
  border-radius: 999px;
  background: var(--c-surface-3);
}

.step-strip__step[data-state="done"] {
  background: var(--c-success);
}

.step-strip__step[data-state="current"] {
  background: var(--c-accent);
}

.step-strip__step[data-state="current"][data-tone="warning"] {
  background: var(--c-warning);
}

.step-strip__step[data-state="stopped"] {
  background: var(--c-danger);
}

.step-strip__step[data-state="skipped"] {
  background: repeating-linear-gradient(135deg, var(--c-surface-3) 0 4px, var(--c-border-strong) 4px 6px);
}

.step-strip__marker,
.step-strip__label,
.step-strip__meta {
  display: none;
}

@container step-strip (min-width: 46rem) {
  .step-strip__summary {
    display: none;
  }

  .step-strip__list {
    gap: var(--space-2);
  }

  .step-strip__step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--space-2);
    align-items: center;
    height: auto;
    padding: var(--space-2) 0 0;
    border-radius: 0;
    border-top: 4px solid var(--c-surface-3);
    background: none;
  }

  .step-strip__step[data-state="done"] {
    border-top-color: var(--c-success);
    background: none;
  }

  .step-strip__step[data-state="current"] {
    border-top-color: var(--c-accent);
    background: none;
  }

  .step-strip__step[data-state="current"][data-tone="warning"] {
    border-top-color: var(--c-warning);
    background: none;
  }

  .step-strip__step[data-state="stopped"] {
    border-top-color: var(--c-danger);
    background: none;
  }

  .step-strip__step[data-state="skipped"] {
    border-top-style: dashed;
    border-top-color: var(--c-border-strong);
    background: none;
  }

  .step-strip__marker {
    display: inline-grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    border: 1px solid var(--c-border-strong);
    color: var(--c-text-muted);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .step-strip__step[data-state="done"] .step-strip__marker {
    border-color: var(--c-success);
    color: var(--c-success);
  }

  .step-strip__step[data-state="current"] .step-strip__marker {
    border-color: var(--c-accent);
    background: var(--c-accent);
    color: var(--c-accent-text);
  }

  .step-strip__step[data-state="stopped"] .step-strip__marker {
    border-color: var(--c-danger);
    color: var(--c-danger);
  }

  .step-strip__label {
    display: block;
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 600;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: manual;
  }

  .step-strip__step[data-state="todo"] .step-strip__label,
  .step-strip__step[data-state="skipped"] .step-strip__label {
    color: var(--c-text-muted);
    font-weight: 500;
  }

  .step-strip__meta {
    display: block;
    grid-column: 2;
    color: var(--c-text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.label-preview--square img {
  max-width: 320px;
  aspect-ratio: 1 / 1;
}

/* K256: the workshop section right after the "Brak zleceń na dziś" empty state (scoped to that section only). */
.empty-state + .panel-section[id="warsztat"] {
  margin-top: var(--space-5);
}

/* Review fix 8: the list's date range (kind, from, to) starts a new line of the open filter panel. */
.workshop-filter__break {
  flex-basis: 100%;
  grid-column: 1 / -1;
  height: 0;
}

/* Fixed widths: the date fields do not stretch to (almost, never exactly) the columns of the line above. */
@media (min-width: 721px) {
  .filter-bar__more[open] > .filter-bar__fields > .field.workshop-filter__date {
    flex: 0 1 200px;
  }
}

/* The order header "Więcej" menu on phones: the button may sit second in the action row (no "Podgląd wydania"
   outside the release steps), so its panel is anchored to the full-width action row, not to the button. */
@media (max-width: 720px) {
  .workshop-header .detail-header__actions {
    position: relative;
  }

  .workshop-header .detail-header__actions > .menu {
    position: static;
  }
}

/* Review fix 23: the part cell of the parts table. Phone card: the name (normal weight, full width, left) with the
   part number muted on the next line; quantity and status keep their label rows. */
.workshop-part__no {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .table--responsive td.workshop-part {
    display: grid;
    gap: 2px;
    justify-items: start;
    text-align: left;
  }

  .table--responsive td.workshop-part::before {
    content: none;
  }

  .workshop-part__name {
    font-weight: 400;
    overflow-wrap: break-word;
  }
}

/* MT-29 */

/* K310: five counters (the rentals list). Phone: 2 + 2 + 1, the last one spans the row; desktop: one row. */
.stat-strip--5 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-strip--5 > .stat-strip__item:last-child {
  grid-column: 1 / -1;
}

@media (min-width: 721px) {
  .stat-strip--5 {
    grid-template-columns: repeat(5, minmax(8rem, 11.5rem));
  }

  .stat-strip--5 > .stat-strip__item:last-child {
    grid-column: auto;
  }
}

/* K314: K153 for choice radios — [data-choice] radios show or hide [data-hide-when~="auto|manual"] in the same
   .form-section (no JS; without :has() both blocks show and the server ignores the inactive one). */
.form-section:has(input[data-choice][value="auto"]:checked) [data-hide-when~="auto"],
.form-section:has(input[data-choice][value="manual"]:checked) [data-hide-when~="manual"] {
  display: none;
}

/* The rentals list: the date badge is a block under the period line (never beside the status badge). */
.rental-table__badge {
  display: block;
}

.rental-status-line {
  margin: 0 0 var(--space-3);
}

/* K313: the availability cell keeps its words (≥ 14rem on the wide layout). */
@media (min-width: 721px) {
  .rental-picker__avail {
    min-width: 14rem;
  }
}

.rental-picker .table__select-label {
  overflow-wrap: normal;
}

/* Folds of the rental card ("Usunięte z rezerwacji", "Wcześniejsze wersje", "Pokaż treść warunków"): a 44 px summary. */
.rental-fold > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  cursor: pointer;
  font-weight: 600;
}

.rental-fold[open] > summary {
  margin-bottom: var(--space-2);
}

.rental-items__removed {
  margin-top: var(--space-3);
}

/* The version buttons wrap onto their own line inside a phone card, ≥ 8 px apart. */
.rental-versions__actions {
  gap: var(--space-2);
}

/* K315: the preview is not a scroll box; the last good text greys while a build problem is shown. */
.rental-terms-preview[aria-disabled="true"] {
  opacity: 0.55;
}

.rental-terms-preview .issue-list {
  margin-bottom: var(--space-3);
}

/* MT-26 — K272 rows editor, K270/K271 send page and log, K275 transport variant fields, K276 transport card,
   K277 offer versions. */
.rows-editor__body {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.rows-editor__label {
  margin: 0;
  font-weight: 600;
}

.rows-editor__count,
.rows-editor__empty {
  margin: 0;
}

.rows-editor__list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.rows-editor__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2);
}

.rows-editor__field {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.rows-editor__field > .field__hint,
.rows-editor__field > .field__error {
  margin: 0;
}

.rows-editor__row.is-pending .input {
  color: var(--c-text-muted);
  text-decoration: line-through;
}

.rows-editor__add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.rows-editor__add > p {
  margin: 0;
}

.rows-editor__inactive > summary {
  display: list-item;
  padding-block: calc((var(--touch) - 1.5em) / 2);
  cursor: pointer;
}

.rows-editor__inactive-list {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.rows-editor__inactive-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.rows-editor__inactive-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.send-document .item-list__body {
  min-width: 0;
}

.send-document .item-list__body small {
  display: block;
  overflow-wrap: anywhere;
}

.send-form__subject,
.send-form__notes p {
  margin: 0;
  overflow-wrap: anywhere;
}

.send-form__notes {
  display: grid;
  gap: var(--space-1);
}

.send-status {
  display: inline-grid;
  justify-items: start;
  gap: 2px;
  min-width: 0;
}

.send-log__file {
  display: block;
  margin-top: var(--space-1);
}

@media (max-width: 720px) {
  .send-document {
    flex-wrap: wrap;
  }

  .send-document__end,
  .send-document__end > .btn {
    width: 100%;
  }

  .send-form .form-actions {
    display: grid;
  }

  .send-form .form-actions > .btn {
    width: 100%;
  }
}

/* K275: the fields that do not apply to the chosen variant (scope: the form; hidden values are kept). */
form:has(.segmented__input[name="Variant"][value="none"]:checked) [data-hide-when~="variant-none"],
form:has(.segmented__input[name="Variant"][value="one_way"]:checked) [data-hide-when~="variant-one-way"],
form:has(.segmented__input[name="Variant"][value="two_way"]:checked) [data-hide-when~="variant-two-way"] {
  display: none;
}

/* K276: the compact transport card (one facts row at 1280; the button under the facts on phones). */
.transport-card .card__header {
  margin-bottom: var(--space-2);
}

.transport-card__facts {
  /* The quote (badge + amount) and the carrier name get the room; the variant is short. */
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr) minmax(0, 1.15fr) minmax(0, 1fr);
  margin: 0;
}

.transport-card__facts dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ≤ 160 px at 1280 (brief §8): a tighter card and the RFQ badge beside its time. */
.transport-card {
  padding-block: var(--space-3) var(--space-4);
}

.transport-card .send-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--space-2);
}

.transport-card__quote {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.transport-card__empty,
.transport-card__note {
  margin: var(--space-2) 0 0;
}

.rfq-card__actions {
  gap: var(--space-2);
}

@media (max-width: 720px) {
  .transport-card {
    display: grid;
  }

  .transport-card .card__header {
    display: contents;
  }

  .transport-card .card__header > h2 {
    margin-bottom: var(--space-2);
  }

  /* Variant and RFQ side by side; the quote (badge + amount) and the carrier name on full rows, so neither wraps
     inside the badge nor loses the name to the clamp. */
  .transport-card__facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "variant rfq" "quote quote" "carrier carrier";
  }

  .transport-card__facts > :nth-child(1) { grid-area: variant; }
  .transport-card__facts > :nth-child(2) { grid-area: quote; }
  .transport-card__facts > :nth-child(3) { grid-area: carrier; }
  .transport-card__facts > :nth-child(4) { grid-area: rfq; }

  .transport-card__action {
    order: 10;
    width: 100%;
    margin-top: var(--space-3);
  }

  .rfq-card__actions {
    display: grid;
  }

  .rfq-card__actions > .btn {
    width: 100%;
  }
}

/* K277: offer versions — the version with its badge, the value stack right-aligned at 1280. */
.offers-table__version {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

@media (min-width: 721px) {
  .offers-table td.table__cell--stack {
    display: table-cell;
  }

  .offers-table td.table__cell--stack > * {
    display: block;
  }
}

/* MT-27 — parts inventory: K281 quantity field, K283 scanner, the protocol catalogue chip. */
.input-unit--large .input {
  max-width: 10rem;
  min-height: var(--touch);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.input-unit--large .input-unit__unit {
  font-size: 1.05rem;
}

.scanner {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.scanner__view {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 60vh;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}

.scanner__view[hidden],
.scanner__actions[hidden],
.scanner [hidden] {
  display: none;
}

.scanner__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner__frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(60%, 14rem);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border: 2px solid var(--c-accent);
  border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.35);
}

.scanner__status:empty {
  display: none;
}

.scanner-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.scanner-field > .input {
  flex: 1 1 12rem;
  min-width: 0;
}

.scanner--compact {
  display: contents;
}

.scanner--compact > .scanner__view,
.scanner--compact > .scanner__status,
.scanner--compact > .scanner__actions {
  flex: 1 1 100%;
}

.parts-editor .badge--catalog {
  white-space: normal;
}

@media (forced-colors: active) {
  .scanner__frame {
    border-color: Highlight;
  }
}

/* A cluster whose first item wraps its text instead of pushing the last item to a new line ("name … quantity"). */
.cluster--nowrap {
  flex-wrap: nowrap;
  align-items: baseline;
}

.cluster--nowrap > :first-child {
  min-width: 0;
}

/* A stacked phone cell keeps the full card width for its "name … quantity" lines (the td's flex `space-between`
   would otherwise shrink the grid column to its content). */
@media (max-width: 720px) {
  .table--responsive td.table__cell--stack:has(> .cluster--nowrap) {
    justify-content: normal;
  }
}

/* MT-30: rental operations (precheck, issue, return, swap, transport, revenue, invoices). */
/* Plain lists of the set (asset lines) inside cards and forms: no bullets, 8 px apart. */
.rental-ops-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* "Rozliczenia": a collapsible card whose summary is the one-line head (title + muted total). */
.rental-ops-fold > .rental-ops-fold__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
  margin: 0;
}

.rental-ops-fold__summary .card__title {
  margin: 0;
}

/* Invoice number per row: input and buttons on one line at 1280, wrapping (8 px gaps) on phones. */
.rental-invoices__form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.rental-invoices__form .input {
  flex: 1 1 10rem;
  min-width: 10rem;
  max-width: 14rem;
}

@media (min-width: 721px) {
  .rental-invoices__form:not(:has(.field__error)) {
    flex-wrap: nowrap;
  }
}

.rental-invoices__form .field__error {
  flex-basis: 100%;
  margin: 0;
}

/* The total row of "Przychód na sprzęt": one band across the row. On phones it is a full-width row of the card table
   ("Razem" label left, the amount right, as the item rows; the desktop label cell is hidden — the MT-27 pattern). */
.rental-ops-fold tfoot tr {
  background: var(--c-surface-2);
}

@media (max-width: 720px) {
  .rental-ops-fold .table--responsive tfoot {
    display: block;
    width: 100%;
  }

  .rental-ops-fold .table--responsive tfoot td {
    font-weight: 700;
  }
}

/* The revenue note keeps a readable width at 1280 (two lines, the full text in the title). */
@media (min-width: 721px) {
  .rental-ops-fold td[data-label="Opis"] {
    min-width: 10rem;
  }

  /* MT-30f: "Podział" has one line per item ("SS/61B · 280,00 zł (14 dni)"), then the rule and the day-split note
     (on phones the stacked cell is already a grid of lines). The days may wrap, so the table never overflows. */
  .rental-ops-fold td.table__cell--stack > * {
    display: block;
  }
}

/* The operation checklists sit between flush cards: their rows share the cards' 20 px inset. */
.rental-ops-checklist :is(.checklist__head, .checklist__item) {
  padding-inline: var(--space-5);
}

/* Phones: the rental "Więcej" button sits mid-row after the wrapped buttons, so its panel opens from the start of the
   action row (anchored to the button it ran ~70 px past the right edge at 360 px). */
@media (max-width: 720px) {
  .detail-header__actions:has(> .rental-ops-menu) {
    position: relative;
  }

  .detail-header__actions > .rental-ops-menu {
    position: static;
  }

  .detail-header__actions > .rental-ops-menu .menu__panel {
    max-width: 100%;
  }
}

/* K325: the technician's checklist one section at a time (rental-stepper.js): the progress line and its thin meter. */
.rental-stepper__progress {
  display: grid;
  gap: var(--space-2);
}

.rental-stepper__text {
  margin: 0;
  font-weight: 600;
}

.rental-stepper__meter {
  width: 100%;
  height: 0.375rem;
  border: 0;
  border-radius: 999px;
  background: var(--c-surface-3);
  accent-color: var(--c-accent);
  appearance: none;
}

.rental-stepper__meter::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--c-surface-3);
}

.rental-stepper__meter::-webkit-progress-value {
  border-radius: 999px;
  background: var(--c-accent);
}

.rental-stepper__meter::-moz-progress-bar {
  border-radius: 999px;
  background: var(--c-accent);
}

/* "Wstecz" at the start, "Dalej" at the end (alone on the first step it stays at the end). */
.rental-stepper__nav {
  justify-content: space-between;
}

.rental-stepper__nav > [data-stepper-next] {
  margin-inline-start: auto;
}

/* MT-35 */

/* K405: four counters — 2 + 2 on phones, one row from 721 px. */
.stat-strip--4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 721px) {
  .stat-strip--4 {
    grid-template-columns: repeat(4, minmax(9rem, 13rem));
  }
}

/* K406: a segmented choice with long labels ("Zdolny z ograniczeniami"). Below a 30rem container one option per
   row (full width, >= 48 px, 8 px apart, icon beside the label); from 30rem one row sized by the labels, so a label
   never breaks inside a word. Radio semantics, keys and tones are unchanged. */
.segmented__options.segmented__options--stack {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}

.segmented__options--stack > .segmented__option,
.segmented__options--stack > .segmented__option:last-of-type {
  grid-column: auto;
  flex-direction: row;
  justify-content: flex-start;
  gap: var(--space-2);
  padding-inline: var(--space-3);
  text-align: start;
}

.segmented__options--stack > .segmented__input:checked + .segmented__option {
  padding-inline: calc(var(--space-3) - 1px);
}

@container segmented (min-width: 30rem) {
  .segmented__options.segmented__options--stack {
    grid-template-columns: repeat(3, auto);
    justify-content: start;
  }

  .segmented__options--stack > .segmented__option {
    flex-direction: row;
    gap: var(--space-2);
    padding-inline: var(--space-3);
  }
}

/* K153 for "Wynik": "Ważne do" disappears with "Niezdolny" (without :has() it stays; the server refuses a date). */
.form-section:has(.segmented__input[value="unfit"]:checked) [data-hide-when~="unfit"] {
  display: none;
}

/* MT-35 U4: the hint under "Zapisz datę" sits in the form grid (16 px below the buttons), without its own margin. */
.medical-end__hint {
  margin: 0;
}

/* MT-35 U1/U2: in a flush card the phone row cards start at the card's content edge (the header's 24 px inset, not
   16 px), and the new-row marker sits on the row's edge with that inset as its gap instead of on the date text. */
@media (max-width: 720px) {
  .card--flush .table--card-inset tbody tr {
    padding-inline: var(--space-5);
  }

  .table--card-inset tr.is-new {
    box-shadow: inset 3px 0 0 var(--c-accent);
  }

  .table--card-inset tr.is-new > :first-child {
    box-shadow: none;
  }
}

@media (max-width: 720px) and (forced-colors: active) {
  .table--card-inset tr.is-new {
    border-left: 3px solid Highlight;
  }

  .table--card-inset tr.is-new > :first-child {
    border-left: 0;
  }
}

/* MT-35 S32: the holders list in a padded card — names start at the card's content edge, like its heading. */
.medical-holders > .item-list__item {
  padding-inline: 0;
}

/* MT-32 — quotations: K345 lines editor, K347 totals, K353 recipient, K354 history, the offer cards and hub,
   K355 SCP card and the quote-list SCP / offer columns. */
.offer-counters {
  margin-bottom: var(--space-4);
}

.offer-table .table__client {
  min-width: 14rem;
}

/* K345: the lines editor. A container query picks the layout: cards in a narrow form, a table with two visual rows
   per line (same grid tracks as the header, money right-aligned) in a wide one. */
.lines-editor {
  container: lines-editor / inline-size;
}

.lines-editor__lookup {
  margin-bottom: var(--space-4);
}

.lines-editor__results {
  display: grid;
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.lines-editor__result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--c-border);
}

.lines-editor__result-text {
  display: grid;
  min-width: 0;
  overflow-wrap: anywhere;
}

.lines-editor__head {
  display: none;
}

.lines-editor__list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lines-editor__line {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "title remove"
    "name name"
    "partno partno"
    "chip chip"
    "qty unit"
    "price discount"
    "vat value";
  gap: var(--space-2) var(--space-3);
  align-items: start;
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
}

.lines-editor--service .lines-editor__line {
  grid-template-areas:
    "title remove"
    "name name"
    "kind kind"
    "qty unit"
    "price vat"
    "value value";
}

.lines-editor__lp {
  grid-area: lp;
  display: none;
}

.lines-editor__title {
  grid-area: title;
  align-self: center;
  margin: 0;
  font-size: 0.95rem;
}

.lines-editor__remove {
  grid-area: remove;
  justify-self: end;
}

.lines-editor__name { grid-area: name; }
.lines-editor__partno { grid-area: partno; }
.lines-editor__chip { grid-area: chip; }
.lines-editor__kind { grid-area: kind; }
.lines-editor__qty { grid-area: qty; }
.lines-editor__unit { grid-area: unit; }
.lines-editor__price { grid-area: price; }
.lines-editor__discount { grid-area: discount; }
.lines-editor__vat { grid-area: vat; }
.lines-editor__value { grid-area: value; }

.lines-editor__chip:not(:has(.chip)) {
  display: none;
}

.lines-editor__cell {
  min-width: 0;
  margin: 0;
}

.lines-editor__cell .input {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.lines-editor__cell .input-unit .input {
  flex: 1 1 auto;
}

.lines-editor__num {
  text-align: right;
}

.lines-editor__value {
  display: grid;
  gap: var(--space-1);
  align-self: stretch;
  align-content: start;
}

.lines-editor__value .lines-editor__label {
  font-weight: 600;
}

.lines-editor__net {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lines-editor__add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-3);
}

.lines-editor__add > p {
  margin: 0;
}

.lines-editor__add > [hidden] {
  display: none;
}

.lines-editor .time-totals--money {
  margin: var(--space-4) 0 0;
}

.lines-editor__recalc {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}

.lines-editor__recalc > p,
.lines-editor__note {
  margin: 0;
}

.lines-editor__note {
  margin-top: var(--space-2);
  text-align: right;
}

/* Table: parts at >= 54rem of form width (lp, main, qty, unit, price, discount, vat, net, remove). */
@container lines-editor (min-width: 54rem) {
  .lines-editor--parts .lines-editor__head,
  .lines-editor--parts .lines-editor__line {
    grid-template-columns: 2rem minmax(0, 1fr) 5.5rem 6rem 8rem 5.5rem 5.5rem 8.5rem 2.75rem;
    grid-template-areas:
      "lp name name name name partno partno partno remove"
      ". chip qty unit price discount vat value .";
  }
}

/* Table: service at >= 50rem (no part no and discount; the kind in row B). */
@container lines-editor (min-width: 50rem) {
  .lines-editor--service .lines-editor__head,
  .lines-editor--service .lines-editor__line {
    grid-template-columns: 2rem minmax(0, 1fr) 5.5rem 6rem 8rem 5.5rem 8.5rem 2.75rem;
    grid-template-areas:
      "lp name name name name name name remove"
      ". kind qty unit price vat value .";
  }
}

@container lines-editor (min-width: 50rem) {
  .lines-editor--service .lines-editor__head,
  .lines-editor--service .lines-editor__line,
  .lines-editor--parts .lines-editor__head,
  .lines-editor--parts .lines-editor__line {
    gap: var(--space-2);
  }

  .lines-editor--service .lines-editor__head,
  .lines-editor--service .lines-editor__line {
    display: grid;
  }

  .lines-editor--service .lines-editor__head,
  .lines-editor--service .lines-editor__line {
    padding: var(--space-3) 0;
    border: 0;
    border-bottom: 1px solid var(--c-border);
    border-radius: 0;
  }

  .lines-editor--service .lines-editor__list {
    gap: 0;
  }

  .lines-editor--service .lines-editor__head {
    padding-top: 0;
    padding-bottom: var(--space-2);
    color: var(--c-text-muted);
    font-size: 0.84rem;
  }

  .lines-editor--service .lines-editor__title,
  .lines-editor--service .lines-editor__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .lines-editor--service .lines-editor__lp {
    display: flex;
    align-items: center;
    min-height: var(--touch);
    color: var(--c-text-muted);
  }

  .lines-editor--service .lines-editor__value {
    display: block;
  }

  .lines-editor--service .lines-editor__net,
  .lines-editor--service .lines-editor__h--net {
    justify-content: flex-end;
    text-align: right;
  }

  .lines-editor--service .lines-editor__h--qty,
  .lines-editor--service .lines-editor__h--price {
    text-align: right;
  }

  .lines-editor--service .time-totals--money {
    max-width: 24rem;
    margin-left: auto;
    margin-right: calc(2.75rem + var(--space-2));
  }

  .lines-editor--service .lines-editor__note {
    margin-right: calc(2.75rem + var(--space-2));
  }
}

@container lines-editor (min-width: 54rem) {
  .lines-editor--parts .lines-editor__head,
  .lines-editor--parts .lines-editor__line {
    display: grid;
    padding: var(--space-3) 0;
    border: 0;
    border-bottom: 1px solid var(--c-border);
    border-radius: 0;
  }

  .lines-editor--parts .lines-editor__list {
    gap: 0;
  }

  .lines-editor--parts .lines-editor__head {
    padding-top: 0;
    padding-bottom: var(--space-2);
    color: var(--c-text-muted);
    font-size: 0.84rem;
  }

  .lines-editor--parts .lines-editor__title,
  .lines-editor--parts .lines-editor__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .lines-editor--parts .lines-editor__lp {
    display: flex;
    align-items: center;
    min-height: var(--touch);
    color: var(--c-text-muted);
  }

  .lines-editor--parts .lines-editor__value {
    display: block;
  }

  .lines-editor--parts .lines-editor__chip:not(:has(.chip)) {
    display: block;
  }

  .lines-editor--parts .lines-editor__net,
  .lines-editor--parts .lines-editor__h--net {
    justify-content: flex-end;
    text-align: right;
  }

  .lines-editor--parts .lines-editor__h--qty,
  .lines-editor--parts .lines-editor__h--price,
  .lines-editor--parts .lines-editor__h--discount {
    text-align: right;
  }

  .lines-editor--parts .time-totals--money {
    max-width: 24rem;
    margin-left: auto;
    margin-right: calc(2.75rem + var(--space-2));
  }

  .lines-editor--parts .lines-editor__note {
    margin-right: calc(2.75rem + var(--space-2));
  }
}

.lines-editor__h--name { grid-area: name; }
.lines-editor__h--partno { grid-area: partno; }
.lines-editor__h--kind { grid-area: kind; }
.lines-editor__h--qty { grid-area: qty; }
.lines-editor__h--unit { grid-area: unit; }
.lines-editor__h--price { grid-area: price; }
.lines-editor__h--discount { grid-area: discount; }
.lines-editor__h--vat { grid-area: vat; }
.lines-editor__h--net { grid-area: value; }

.lines-editor__catalog {
  max-width: 100%;
}

/* K347 read-only totals under the saved lines. */
.offer-lines-totals {
  margin-top: var(--space-4);
}

@media (min-width: 721px) {
  .offer-lines-totals {
    max-width: 24rem;
    margin-left: auto;
  }
}

/* K350: photo pick with framing (legacy ratios: main 85.6 / 87.6, extra 40.6 / 41.6). */
.offer-photo-pick__counter {
  margin: 0 0 var(--space-2);
}

.offer-photo-pick__hint {
  margin: 0 0 var(--space-3);
}

.offer-photo-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.offer-photo-pick--framing {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.offer-photo-pick__item {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
}

.offer-photo-pick__item .field {
  margin: 0;
}

.offer-photo-pick__frame {
  overflow: hidden;
  aspect-ratio: 40.6 / 41.6;
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.offer-photo-pick__frame--main {
  aspect-ratio: 85.6 / 87.6;
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.offer-photo-pick__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}

.offer-photo-pick__frame--contain .offer-photo-pick__img {
  object-fit: contain;
  background: #fff;
}

.offer-photo-pick__item .input {
  width: 100%;
  max-width: none;
}

.offer-photo-pick__slider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.offer-photo-pick__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--touch);
  margin: 0;
  accent-color: var(--c-accent);
}

.offer-photo-pick__output {
  flex: none;
  min-width: 3.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.offer-totals {
  display: grid;
  gap: var(--space-1);
  justify-content: end;
  margin: var(--space-4) 0 0;
  padding: var(--space-3) var(--space-4) 0;
}

.offer-totals__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  margin: 0;
}

.offer-totals__row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.offer-totals__row--total {
  padding-top: var(--space-2);
  border-top: 1px solid var(--c-border);
  font-weight: 700;
}

.offer-recipient__subtitle {
  margin: 0;
  font-size: 1rem;
}

.offer-recipient__search {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}

.offer-recipient__chosen {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.offer-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  gap: var(--space-5);
  align-items: start;
}

.offer-context {
  margin-bottom: var(--space-4);
}

.offer-context .offer-fold {
  margin-top: var(--space-1);
}

.offer-edit__form,
.offer-form {
  min-width: 0;
}

.offer-fold {
  margin-top: var(--space-3);
}

.offer-fold > summary {
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  color: var(--c-accent);
  font-weight: 600;
}

.offer-fold[open] > summary {
  margin-bottom: var(--space-2);
}

.offer-fold + * {
  margin-top: var(--space-4);
}

.offer-receive__row {
  margin: 0;
}

.offer-events {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.offer-events__item {
  min-width: 0;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--c-border);
}

.offer-events__item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.offer-events__head,
.offer-events__details {
  margin: 0;
  overflow-wrap: anywhere;
}

.offer-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.offer-photos__item {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  min-width: 0;
}

.offer-photos__img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

.offer-device {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.offer-device__legend {
  padding: 0 var(--space-1);
  font-weight: 700;
}

.offer-devices-list {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.offer-devices-list__item {
  display: grid;
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--c-border);
}

.offer-devices-list__item:last-child {
  border-bottom: 0;
}

.offer-devices-list__title {
  margin: 0;
  font-size: 1rem;
}

.offer-upload {
  margin: 0;
}

.quote-table__scp {
  white-space: nowrap;
}

.quote-table__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
}

.quote-table__actions form {
  margin: 0;
}

.scp-card__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}

.scp-card__row .field {
  margin: 0;
}

.scp-card__form {
  margin: 0;
}

.scp-card__state {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

@media (max-width: 960px) {
  .offer-edit {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .offer-totals {
    justify-content: stretch;
    padding-inline: 0;
  }

  .offer-photos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-table__actions {
    justify-content: flex-start;
  }

  .scp-card__save {
    width: 100%;
  }
}

/* MT-37 — conversations, live badges, push settings (K445–K453). */
/* K448/K451 conversation list: header and search on one line at desktop, the search full width on phones. */
.contact-list .card__header {
  gap: var(--space-3);
}

.contact-list__search {
  width: min(20rem, 100%);
}

.contact-list__notice {
  margin: 0 var(--space-5) var(--space-3);
}

.contact-list__row {
  min-height: 56px;
}

.contact-list__avatar {
  width: 36px;
  height: 36px;
  font-size: 0.8rem;
  align-self: flex-start;
}

.contact-list__name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  overflow-wrap: break-word;
}

.contact-list__end {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  align-self: flex-start;
  margin-top: 2px;
  white-space: nowrap;
}

.contact-list__empty {
  margin: 0 var(--space-5) var(--space-4);
}

/* K446 technician panel "Więcej": the badge on the title line, rows ≥ 56 px. */
.panel-links .item-list__item {
  min-height: 56px;
}

.panel-links .item-list__end {
  display: flex;
  align-items: center;
}

@media (min-width: 961px) {
  .panel-links .card {
    max-width: 40rem;
  }
}

/* K451 notice and K452 state line. */
.inline-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgb(96 165 250 / 40%);
  border-radius: var(--radius-sm);
  background: var(--c-info-soft);
  color: var(--c-text);
}

.inline-notice[hidden] {
  display: none;
}

.inline-notice > .icon {
  flex: none;
  color: var(--c-info);
}

.inline-notice__text {
  flex: 1 1 12rem;
  min-width: 0;
}

.inline-notice .btn {
  margin-left: auto;
}

.state-line {
  --tone: var(--c-text-muted);
  --tone-soft: var(--c-surface-3);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--tone) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--tone-soft);
}

.state-line[data-tone="success"] {
  --tone: var(--c-success);
  --tone-soft: var(--c-success-soft);
}

.state-line[data-tone="info"] {
  --tone: var(--c-info);
  --tone-soft: var(--c-info-soft);
}

.state-line[data-tone="warning"] {
  --tone: var(--c-warning);
  --tone-soft: var(--c-warning-soft);
}

.state-line[data-tone="danger"] {
  --tone: var(--c-danger);
  --tone-soft: var(--c-danger-soft);
}

.state-line__icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--tone);
}

.state-line__text {
  min-width: 0;
  overflow-wrap: break-word;
}

/* Push settings page and the admin status page. */
.push-card,
.push-install {
  max-width: 42rem;
}

.push-card h2 {
  margin: 0;
}

.push-card p {
  margin: 0;
}

.push-card__kinds {
  margin: 0;
  padding-left: 1.25rem;
}

.push-card__actions {
  gap: var(--space-3);
}

.push-card__actions .btn {
  white-space: nowrap;
}

.push-card .divider {
  margin: 0;
}

.push-admin__key {
  overflow-wrap: anywhere;
}

/* K449 conversation thread: no card, bubbles on the page background. */
.conversation {
  display: flex;
  flex-direction: column;
  max-width: 52rem;
}

.conversation__back {
  margin: 0 0 var(--space-2);
}

.thread__older {
  margin: 0 0 var(--space-2);
}

.thread__day-title {
  margin: var(--space-4) 0 var(--space-2);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text-muted);
}

.thread__list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.thread__msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.thread__msg--own {
  align-items: flex-end;
}

.thread__bubble {
  max-width: min(85%, 36rem);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface-2);
  color: var(--c-text);
}

.thread__msg--own .thread__bubble {
  border-color: color-mix(in srgb, var(--c-accent) 40%, transparent);
  background: var(--c-accent-soft);
}

.thread__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

.thread__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-1);
  margin: var(--space-1) 0 0;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--c-text-muted);
}

.thread__state {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.thread__state .icon {
  width: 14px;
  height: 14px;
}

.thread__state .thread__check2 {
  margin-left: -8px;
}

.thread__new {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--c-info);
}

.thread__new::before,
.thread__new::after {
  content: "";
  flex: 1;
  height: 1px;
  background: currentcolor;
}

.thread__new,
.thread__msg,
.thread__end {
  scroll-margin-top: calc(var(--topbar-height) + var(--space-3));
  scroll-margin-bottom: calc(var(--compose-h, 5rem) + var(--space-3));
}

.thread .empty-state--inline {
  margin-top: var(--space-3);
}

/* K450 compose bar: sticky at the bottom (above the bottom navigation on phones). */
.compose {
  position: sticky;
  bottom: var(--space-3);
  z-index: 5;
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  box-shadow: var(--shadow);
}

.compose > p {
  margin: 0;
}

.compose__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-2);
}

.compose__input {
  min-height: var(--touch);
  max-height: 9.5em;
  resize: none;
  field-sizing: content;
}

.compose__send {
  white-space: nowrap;
}

.compose__offline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--c-warning);
}

.compose__offline[hidden] {
  display: none;
}

.compose__count,
.compose__restored {
  font-size: 0.85rem;
  text-align: end;
}

.conversation__inactive {
  margin-top: var(--space-4);
}

@media (max-width: 960px) {
  .compose {
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + var(--space-2));
  }

  /* K453: on a page with the compose bar the toasts sit under the topbar (never over the bar or the bottom nav). */
  body:has(.compose) .toast-region {
    top: calc(var(--topbar-height) + var(--space-2));
    bottom: auto;
  }
}

/* Phone keyboard rule: while typing the bar is in the flow and the bottom navigation steps aside. */
@media (max-width: 960px) and (pointer: coarse) {
  .compose:focus-within {
    position: static;
  }

  body:has(.compose:focus-within) .bottom-nav {
    display: none;
  }
}

@media (forced-colors: active) {
  .thread__bubble {
    border: 1px solid CanvasText;
  }

  .thread__msg--own .thread__bubble {
    border-width: 2px;
  }
}

/* K453 toast with an action link. */
.toast__action {
  flex: none;
  white-space: nowrap;
}

/* MT-33: buybacks and asset sales (K365 reveal values, K366 device picker, K367 sold banner). */
/* K365: the buyback form reveals (segmented subject / valuation, [data-choice] seller mode). Without :has() every block
   shows and the server ignores the inactive one. */
.form-section:has(.segmented__input[value="devices"]:checked) [data-hide-when~="devices"],
.form-section:has(.segmented__input[value="typed"]:checked) [data-hide-when~="typed"],
.form-section:has(.segmented__input[value="individual"]:checked) [data-hide-when~="individual"],
.form-section:has(.segmented__input[value="group"]:checked) [data-hide-when~="group"],
.form-section:has(input[data-choice][value="registered"]:checked) [data-hide-when~="registered"],
.form-section:has(input[data-choice][value="external"]:checked) [data-hide-when~="external"] {
  display: none;
}

.buyback-amount {
  max-width: 12rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.buyback-menu-note {
  max-width: 18rem;
  margin: 0;
  padding: var(--space-1) var(--space-4) var(--space-2);
  font-size: 0.85rem;
  line-height: 1.4;
}

.buyback-expired {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--c-warning);
}

.buyback-signatures,
.buyback-receipt__signatures {
  gap: var(--space-4);
}

.buyback-signature {
  display: block;
}

.buyback-signatures > figure {
  margin: 0;
}

/* Date and time stay side by side down to 360 px (the tracks shrink together). */
.buyback-receipt__when {
  align-items: start;
  grid-template-columns: minmax(0, 12rem) minmax(0, 9rem) minmax(0, 1fr);
}

.buyback-receipt__purposes {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.buyback-receipt__location {
  max-width: 30rem;
}

.buyback-snapshot > summary {
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
}

.buyback-snapshot[open] > summary {
  margin-bottom: var(--space-3);
}

/* K366: the customer-device picker. */
.device-picker {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.device-picker__title {
  margin: 0;
  font-size: 1rem;
}

.device-picker__search {
  align-items: end;
}

.device-picker__table .device-picker__price {
  width: 12rem;
}

.device-picker__price-input {
  justify-content: flex-end;
}

.device-picker__price-input .buyback-amount {
  width: 9rem;
}

.device-picker__serial {
  white-space: nowrap;
}

.device-picker__empty td {
  padding: var(--space-3) var(--space-4);
}

.device-picker__empty p {
  margin: 0;
}

.device-picker__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
}

.device-picker__count,
.device-picker__total {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.device-picker__total {
  font-weight: 700;
}

@media (min-width: 721px) {
  .device-picker__summary {
    position: sticky;
    bottom: var(--space-2);
    z-index: 1;
  }
}

/* The sale page: one buyer per row; the chosen buyer beside "Zmień nabywcę". */
.sale-buyers {
  grid-template-columns: minmax(0, 1fr);
}

.sale-buyer {
  gap: var(--space-2) var(--space-4);
}

.sale-buyer > p {
  margin: 0;
  min-width: 0;
}

/* The buyback card totals under the device table keep the card's bottom padding. */
.buyback-totals {
  padding-bottom: var(--space-4);
}

/* K367: the sold banner — long buyer names wrap between words only. */
.asset-sold__buyer {
  overflow-wrap: normal;
  word-break: normal;
}

.asset-sold__links {
  gap: var(--space-2) var(--space-4);
}

.asset-sold .alert__title {
  overflow-wrap: normal;
}

@media (max-width: 720px) {
  .asset-sold__links {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .asset-sold__links a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 2.75rem;
  }

  .buyback-receipt__when > :nth-child(3) {
    grid-column: 1 / -1;
  }

  /* The receipt bar has up to three buttons: the status and "Potwierdź przyjęcie" take whole rows, then the draft
     save beside the ghost "Anuluj" (K102 alone is one status and one button). */
  .form-actions--sticky.buyback-receipt__bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2) var(--space-3);
  }

  .buyback-receipt__bar > .form-actions__status,
  .form-actions--sticky.form-actions--status.buyback-receipt__bar > .btn--primary {
    grid-column: 1 / -1;
  }

  .asset-sale__button {
    width: 100%;
    justify-content: center;
  }

  .device-picker__table .device-picker__price {
    width: auto;
  }

  .device-picker__price-input .buyback-amount {
    width: 100%;
    max-width: none;
  }
}

/* MT-36 — entrusted company property: K425 card rows (field cards), the K153-like kind help and company line, the
   collapsible protocol cards, the attachment removal panel, the S22 focus shell of the signing view. */

/* K425: a card with a free field layout (title + remove on one line, the caller's fields below). */
.lines-editor--fields .lines-editor__line {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title remove"
    "body body";
}

.lines-editor__body {
  grid-area: body;
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

/* Rodzaj | Identyfikator | Nazwa: narrower kind, wider name; the uneven split also keeps the identifier's left edge
   clear of the split form sections' field column (an even split put it 6 px off that column at 1280 px). */
@media (min-width: 1100px) {
  .lines-editor--fields .lines-editor__body > .form__row:first-child {
    grid-template-columns: minmax(0, 4fr) minmax(0, 5fr) minmax(0, 6fr);
  }
}

/* Phones: "Więcej" sits mid-row after "Otwórz PDF", so its panel opens from the start of the action row (anchored
   to the button it ran ~35 px past the right edge at 360 px; the rental menu's pattern). */
@media (max-width: 720px) {
  .detail-header__actions:has(> .property-menu) {
    position: relative;
  }

  .detail-header__actions > .property-menu {
    position: static;
  }

  .detail-header__actions > .property-menu .menu__panel {
    max-width: 100%;
  }
}

/* Phones: the shorter submit label ("Zapisz i otwórz protokół") keeps the sticky bar on one line. */
@media (max-width: 720px) {
  .property-wide-word {
    display: none;
  }
}

/* The event kind: one help line per kind, the checked one shown (K153 pattern); without :has() all show. */
@supports selector(:has(*)) {
  [data-kind-section] [data-kind-help] {
    display: none;
  }

  [data-kind-section]:has(.segmented__input[value="return"]:checked) [data-kind-help="return"],
  [data-kind-section]:has(.segmented__input[value="damage"]:checked) [data-kind-help="damage"],
  [data-kind-section]:has(.segmented__input[value="loss"]:checked) [data-kind-help="loss"] {
    display: block;
  }

  /* The NIP and address line of the chosen company profile only (the name prefix is for the no-:has() fallback). */
  [data-company-section]:has([data-company-select]) [data-company-line] {
    display: none;
  }

  [data-company-section]:has([data-company-select] option[value="service"]:checked) [data-company-line="service"],
  [data-company-section]:has([data-company-select] option[value="rental"]:checked) [data-company-line="rental"] {
    display: block;
  }

  [data-company-section] [data-company-name] {
    display: none;
  }
}

/* The preview's item list carries the PDF's own "1." numbers, so the list has no markers. */
.property-items {
  padding-left: 0;
  list-style: none;
}

/* Collapsible protocol cards (preview of a signed protocol, terms): a one-touch-high summary line. */
.property-details {
  padding-block: var(--space-1);
}

.property-details[open] {
  padding-bottom: var(--space-4);
}

.property-details > .property-details__summary {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  cursor: pointer;
}

.property-details__summary h2 {
  margin: 0;
  font-size: 1.05rem;
}

.property-details[open] > .property-details__summary {
  margin-bottom: var(--space-3);
}

.property-terms h3 {
  margin: var(--space-2) 0 0;
  font-size: 1rem;
}

.property-terms p {
  margin: 0;
}

/* Attachment removal: the reason panel opens under the row's buttons, never over them. */
/* The "Dodaj załączniki" form starts a new block under the file list (it sat flush against the last row). */
#zalaczniki > * + form {
  margin-top: var(--space-5);
}

/* R5: "Usuń…" sits beside "Otwórz"; the opened reason form takes the whole row under the file. */
.file-list__actions:has(> .property-remove) {
  flex-wrap: wrap;
  align-items: flex-start;
}

.file-list__item:has(.property-remove[open]) > .file-list__actions,
.property-remove[open] {
  flex-basis: 100%;
}

.property-remove[open] > form {
  margin-top: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
}

.property-remove > summary {
  list-style: none;
}

.property-remove > summary::-webkit-details-marker {
  display: none;
}

/* S22: the focus shell of the signing view — brand and title, no navigation. */
.focus-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.focus-shell__bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}

.focus-shell__logo {
  width: auto;
  height: 2rem;
}

.focus-shell__title {
  margin: 0;
  font-size: 1.15rem;
}

.focus-shell__main {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
}

.signing-bar {
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}

.signing-bar__number {
  margin: 0;
  font-weight: 700;
}

.signing-done {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
}

.signing-done .card__title {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 1.25rem;
}

@media (max-width: 640px) {
  .focus-shell__bar {
    padding-inline: var(--space-4);
  }

  .signing-bar > .btn,
  .signing-done .btn {
    width: 100%;
  }
}

/* No bottom navigation in the focus shell: the content keeps the normal bottom padding. */
@media (max-width: 960px) {
  .focus-shell__main {
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  }
}

/* MT-36 review (return form at 360 px): in a K152 select table the checkbox takes the card's status area, so a status
   cell in the same row becomes an ordinary labelled line instead of sitting under the checkbox. */
@media (max-width: 720px) {
  .table--responsive.table--select tbody tr:has(td.table__select) > td.table__status-cell {
    grid-area: auto;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
  }

  .table--responsive.table--select tbody tr:has(td.table__select) > td.table__status-cell::before {
    content: attr(data-label);
  }
}

/* MT-34 */
/* K330 (MT-30 §2.3.6, built in MT-34): a select[data-reveal-source] in one .form-section shows [data-reveal-when="set"]
   while a value is chosen and [data-reveal-when="empty"] while the empty option is chosen. Without :has() both show
   and each hint says which one counts. */
.form-section:has(select[data-reveal-source] option[value=""]:checked) [data-reveal-when="set"],
.form-section:not(:has(select[data-reveal-source] option[value=""]:checked)) [data-reveal-when="empty"] {
  display: none;
}

/* K389: the text rows editor (bordered cards below 46rem of the container, one grid row per line above). */
.lines-editor--text .text-rows__line {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: none;
}

.lines-editor--text .lines-editor__line > .lines-editor__cell {
  grid-column: 1 / -1;
}

.lines-editor--text .text-rows__title {
  grid-column: 1;
  grid-row: 1;
}

.lines-editor--text .text-rows__remove {
  grid-column: 2;
  grid-row: 1;
}

.lines-editor--text .text-rows__label .field__required {
  color: inherit;
}

@container lines-editor (min-width: 46rem) {
  .lines-editor--text .lines-editor__head,
  .lines-editor--text .lines-editor__line {
    display: grid;
    grid-template-columns: var(--text-rows-tracks);
    gap: var(--space-2);
    align-items: start;
  }

  .lines-editor--text .lines-editor__line {
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .lines-editor--text .lines-editor__lp,
  .lines-editor--text .lines-editor__line > .lines-editor__cell,
  .lines-editor--text .text-rows__remove {
    grid-area: auto;
  }

  .lines-editor--text .lines-editor__head {
    margin-bottom: var(--space-1);
    color: var(--c-text-muted);
    font-size: 0.84rem;
  }

  .lines-editor--text .text-rows__title,
  .lines-editor--text .text-rows__cell-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .lines-editor--text .lines-editor__lp {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: var(--touch);
    color: var(--c-text-muted);
  }
}

/* K390: the problem page of a form posted to a new tab. */
.new-tab-problem {
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

/* Company documents: badges stacked in a status cell, the danger text of "Anuluj szkic…", one-column choices. */
.documents-badges {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.documents-danger-text {
  color: var(--c-danger);
}

.documents-choices {
  grid-template-columns: minmax(0, 1fr);
}

.documents-choices .choice__text {
  min-width: 0;
}

.documents-choices .badge {
  vertical-align: middle;
}

.documents-hub {
  align-items: stretch;
}

.documents-check-col {
  width: 3.5rem;
}

.documents-count {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

/* K314 values of the letter sender radios (an incomplete profile's alert shows only while it is chosen). */
.form-section:has(input[data-choice][value="serwis"]:checked) [data-hide-when~="serwis"],
.form-section:has(input[data-choice][value="wynajem"]:checked) [data-hide-when~="wynajem"] {
  display: none;
}

.documents-fill {
  margin: 0;
}

/* K389 layouts (CSP: the tracks cannot be an inline style): lp, the columns by width (s 8rem, m 10rem, f fill), remove. */
.lines-editor--text.text-rows--s-f-f-f-m {
  --text-rows-tracks: 2rem 8rem minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 10rem 2.75rem;
}

.lines-editor--text.text-rows--f-m-m-m {
  --text-rows-tracks: 2rem minmax(0, 1fr) 10rem 10rem 10rem 2.75rem;
}

/* A chosen customer / device line with its "Zmień" button. */
.note-block > .cluster > p {
  margin: 0;
}

/* Transfer list cards at phone width: a long number and two badges never share a row, the badges wrap under the number. */
@media (max-width: 720px) {
  .table--responsive.documents-transfers tbody tr {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "primary";
  }

  .table--responsive.documents-transfers td.table__status-cell {
    grid-area: auto;
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .documents-transfers .documents-badges {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* TZ sticky bar at phone width: the equipment summary takes its own line above the button (words never break). */
@media (max-width: 720px) {
  .form-actions--sticky.form-actions--status.documents-status-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-actions--sticky.form-actions--status.documents-status-bar > .form-actions__status {
    overflow-wrap: normal;
  }
}

/* The second word of a sticky-bar label at phone width stays in the accessible name only ("Zatwierdź przekazanie"). */
@media (max-width: 30rem) {
  .documents-wide-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* MT-38 — workshop tasks, grants, TV boards (K465 select filter, K466 switch, K526 one-time secret, task pages).
   The board itself (K468–K471, K475) lives in tv-board.css. */
.field > [data-select-filter] {
  margin-bottom: var(--space-2);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: 0 var(--space-1);
  border: 0;
  background: none;
  color: var(--c-text);
  font: inherit;
  cursor: pointer;
}

.switch:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.switch__track {
  position: relative;
  flex: none;
  inline-size: 2.75rem;
  block-size: 1.5rem;
  box-sizing: border-box;
  border-radius: 999px;
  border: 2px solid var(--c-input-border);
  background: var(--c-surface-3);
}

.switch__thumb {
  position: absolute;
  inset-block: 2px;
  inset-inline-start: 2px;
  inline-size: 1.05rem;
  border-radius: 50%;
  background: var(--c-text-muted);
  transition: transform 0.15s;
}

.switch[aria-checked="true"] .switch__track {
  background: var(--c-success-soft);
  border-color: var(--c-success);
}

.switch[aria-checked="true"] .switch__thumb {
  transform: translateX(1.2rem);
  background: var(--c-success);
}

.switch[aria-checked="true"] .switch__text {
  color: var(--c-success);
  font-weight: 700;
}

.switch[aria-checked="false"] .switch__text {
  color: var(--c-text-muted);
}

.switch-form {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .switch__thumb {
    transition: none;
  }
}

.grant-table td {
  vertical-align: middle;
}

.grant-table .grant-table__switch {
  width: 14rem;
}

.secret__label {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.secret--otp code {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  overflow-wrap: normal;
  flex-basis: 100%;
}

.secret--otp code > span {
  white-space: nowrap;
}

.code-card__steps {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding-left: 1.5rem;
}

.code-card__url {
  overflow-wrap: anywhere;
}

.tv-devices__note {
  display: block;
  font-size: 0.88rem;
}

.tv-devices td .cluster {
  flex-wrap: wrap;
}

.task-table__line {
  display: block;
}

.task-table .table__primary-cell {
  min-width: 16rem;
}

.job-card.is-new {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.job-card__note-more summary {
  cursor: pointer;
  color: var(--c-accent);
  min-height: var(--touch);
  display: flex;
  align-items: center;
}

.tasks-header__menu {
  display: none;
}

@media (max-width: 720px) {
  .tasks-header__extra {
    display: none;
  }

  .tasks-header__menu {
    display: block;
  }

  .task-row-actions .btn {
    min-height: var(--touch);
  }

  .tv-devices .table__actions .btn {
    min-height: var(--touch);
  }
}
/* end MT-38 */

/* MT-41: customer portal (K525 _PortalLayout, K527 print sheet, K529 scope choices, K533/K534 lists) */

.portal-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0, var(--c-bg-glow) 0, var(--c-bg) 60%);
}

.portal__header {
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}

.portal__bar,
.portal__main,
.portal__footer {
  width: 100%;
  max-width: 64rem;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.portal__bar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-3);
  min-height: 64px;
}

.portal__brand {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  margin: 0;
  color: var(--c-accent);
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.portal__brand small {
  color: var(--c-text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.portal__nav {
  display: flex;
  gap: var(--space-2);
}

.portal__nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 var(--space-2);
  border-bottom: 2px solid transparent;
  color: var(--c-text-muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.portal__nav a:hover {
  color: var(--c-text);
}

.portal__nav a[aria-current="page"] {
  border-bottom-color: var(--c-accent);
  color: var(--c-text);
}

.portal__account {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
}

.portal__who {
  display: grid;
  max-width: 18rem;
  text-align: right;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.portal__who small {
  color: var(--c-text-muted);
}

.portal__signout {
  margin: 0;
}

.portal__menu .menu__panel {
  max-width: calc(100vw - 32px);
}

.menu__head {
  display: grid;
  gap: 2px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text-muted);
  overflow-wrap: anywhere;
}

.menu__head strong {
  color: var(--c-text);
}

.portal__main {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--space-4);
  padding-block: var(--space-5);
}

.portal__main--narrow {
  justify-items: center;
}

.portal__main--narrow > .auth__card {
  margin-inline: auto;
}

.portal__main--narrow .auth__card > * + * {
  margin-top: var(--space-4);
}

.portal__footer {
  padding-block: var(--space-4);
  border-top: 1px solid var(--c-border);
  color: var(--c-text-muted);
  font-size: 0.94rem;
}

.portal__page-header h1 {
  margin: 0;
}

.portal__page-header p {
  margin: var(--space-1) 0 0;
}

.portal__message {
  max-width: 40rem;
}

.portal__help p {
  margin: 0 0 var(--space-2);
}

.portal__contact {
  margin: 0;
}

.portal__id {
  overflow-wrap: anywhere;
}

.portal__form-card {
  max-width: 40rem;
}

.portal__fold > summary {
  list-style: none;
  width: fit-content;
}

.portal__fold > summary::-webkit-details-marker {
  display: none;
}

.portal__fold[open] > summary {
  margin-bottom: var(--space-3);
}

.portal-devices td.table__primary-cell {
  min-width: 16rem;
}

.portal-documents td.table__actions .btn,
.portal__open {
  min-height: var(--touch);
}

/* The signature badge stays on one line ("Podpisany przez serwis"). */
.portal-documents .badge {
  white-space: nowrap;
}

.portal-accounts__devices {
  min-width: 8rem;
}

.portal-accounts__devices .badge {
  margin-top: var(--space-1);
  white-space: normal;
}

.portal-filter .portal-filter__customer {
  flex: 0 1 18rem;
  min-width: 0;
}

.portal-filter .portal-filter__status {
  flex: 0 1 12rem;
  min-width: 0;
}

.portal-scope__foreign .choice {
  background: var(--c-surface);
}

.portal-access__actions {
  gap: var(--space-2);
}

.portal-otp__url code {
  flex: 1 1 220px;
}

/* K527: the print-only sheet. */
.print-sheet {
  display: none;
}

@media (max-width: 720px) {
  .portal__nav,
  .portal__who,
  .portal__signout {
    display: none;
  }

  .portal__account--setup .portal__signout {
    display: block;
  }

  .portal__main--narrow {
    padding-block: var(--space-3);
  }

  .portal__main--narrow .auth__card {
    padding: var(--space-5) 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .portal-documents td.table__actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (min-width: 721px) {
  .portal__bar,
  .portal__main,
  .portal__footer {
    padding-inline: var(--space-5);
  }

  .portal__menu {
    display: none;
  }
}

@media print {
  body:has(.print-sheet) .portal__header,
  body:has(.print-sheet) .portal__footer,
  body:has(.print-sheet) main > *:not(.print-sheet),
  body:has(.print-sheet) .content > *:not(.print-sheet),
  body:has(.print-sheet) .stack > *:not(.print-sheet) {
    display: none !important;
  }

  body:has(.print-sheet) .stack:has(> .print-sheet) {
    display: block !important;
  }

  .print-sheet {
    display: block;
    color: #000000;
    background: #ffffff;
    font-size: 12pt;
  }

  .print-sheet__title {
    margin: 0 0 4pt;
    font-size: 18pt;
  }

  .print-sheet__data {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4pt 12pt;
  }

  .print-sheet__data dd {
    margin: 0;
  }

  .print-sheet__secret {
    font-family: var(--font-mono);
    font-size: 16pt;
    font-weight: 700;
  }

  .print-sheet__meta {
    font-size: 8pt;
    color: #555555;
  }
}
/* Review (K526 at 360): the MT-38 pairing-code card stacks its alert, secret and steps with the usual gap. */
.code-card > * + * {
  margin-top: var(--space-3);
}

/* /MT-41 */

/* MT-39: knowledge base shared additions (K485 auto-height text area, K486 character counter, K488 long-text
   definition value, K489 sideways-scrolling table). None is knowledge-specific. */
textarea[data-autogrow] {
  overflow-y: hidden;
  min-height: auto;
  resize: vertical;
}

textarea[data-autogrow][data-autogrow-max] {
  overflow-y: auto;
}

.field__count {
  margin: var(--space-1) 0 0;
  font-size: 0.82rem;
  color: var(--c-text-muted);
  font-variant-numeric: tabular-nums;
}

.field__count .icon {
  vertical-align: -0.15em;
}

.definition__item--prose dd {
  white-space: pre-wrap;
  max-width: 72ch;
  line-height: 1.55;
}

.table-wrap--scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.table-wrap--scroll:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.table--scroll {
  min-width: 52rem;
}

.table--scroll th,
.table--scroll td {
  overflow-wrap: normal;
  word-break: normal;
  vertical-align: top;
}

.table--scroll td.table--scroll__note {
  min-width: 14rem;
}

.table-wrap__hint {
  display: none;
  margin: 0 0 var(--space-2);
  font-size: 0.875rem;
  color: var(--c-text-muted);
}

@media (max-width: 720px) {
  .table-wrap__hint {
    display: block;
  }
}
/* end MT-39 */

/* MT-40 */
/* K506 (MT-40 §2.3.2): fields shown by the chosen option of a select in the same .form-section (slots 1–4; the option
   form of K330). The option carries data-reveal="1 2…" (K505 option-data). Without :has() the rules are dropped, every
   block shows and its [data-reveal-fallback] hint says which option it belongs to; the server ignores the others. */
.form-section:not(:has(select[data-reveal-source] option[data-reveal~="1"]:checked)) [data-reveal-when="1"],
.form-section:not(:has(select[data-reveal-source] option[data-reveal~="2"]:checked)) [data-reveal-when="2"],
.form-section:not(:has(select[data-reveal-source] option[data-reveal~="3"]:checked)) [data-reveal-when="3"],
.form-section:not(:has(select[data-reveal-source] option[data-reveal~="4"]:checked)) [data-reveal-when="4"] {
  display: none;
}

@supports selector(:has(*)) {
  .form-section [data-reveal-fallback] {
    display: none;
  }
}
/* /MT-40 */

/* MT-45: the start page dashboard (K546–K551). */
.dashboard {
  display: grid;
  gap: var(--space-5);
}

.dashboard > .page-header {
  margin-bottom: 0;
}

.dashboard__area {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.dashboard__area-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-3);
  row-gap: var(--space-1);
}

.dashboard__area-head h2,
.dashboard__area-head p {
  margin: 0;
}

.dashboard__area-head p {
  font-size: 0.92rem;
}

/* K550: quick actions — two columns on phones (an odd last one spans the row), one wrapping row on desktop. */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.quick-actions > .btn {
  flex: 1 1 auto;
  text-align: center;
}

.quick-actions > .btn > .icon {
  flex: none;
}

@media (max-width: 720px) {
  .quick-actions > .btn {
    flex-basis: calc(50% - var(--space-2) / 2);
    min-width: 0;
    padding-inline: var(--space-3);
  }

  .quick-actions > .btn:last-child:nth-of-type(odd) {
    flex-basis: 100%;
  }
}

/* K546: "Wymaga uwagi". */
.dashboard-attention .card__header {
  margin-bottom: var(--space-3);
}

.dashboard-attention .card__header h2 {
  font-size: 1.15rem;
}

.dashboard-attention .card__header p.dashboard-attention__count {
  margin: 0;
}

.dashboard-attention__row {
  align-items: flex-start;
}

.dashboard-attention__row > .item-list__end,
.dashboard-attention__row > .item-list__arrow {
  align-self: center;
}

.item-list__eyebrow {
  color: var(--c-text-subtle);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
}

.dashboard-attention__row .item-list__body {
  gap: 2px;
}

/* "Pokaż jeszcze n" is the card's footer (the divider line); the summary and the opened rows are full width. */
.dashboard__more.card__footer {
  padding: 0;
}

.dashboard__more > summary {
  list-style: none;
  border: 0;
  border-radius: 0;
}

.dashboard__more > summary::-webkit-details-marker {
  display: none;
}

.dashboard-attention__unchecked {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--c-border);
  font-size: 0.92rem;
}

.dashboard-attention__unchecked > .icon {
  flex: none;
  margin-top: 2px;
  color: var(--c-warning);
}

.dashboard-attention > .card__body {
  padding-top: 0;
}

/* K548: panel cards. */
.dashboard-card .card__header {
  margin-bottom: var(--space-2);
}

.dashboard-card .card__header h3 {
  font-size: 1rem;
}

.dashboard-card .card__header .dashboard-card__state {
  margin: 0;
}

.dashboard-card__summary {
  margin: 0 0 var(--space-3);
  padding: 0 var(--space-5);
  font-size: 0.92rem;
}

.dashboard-card > .card__body {
  padding-top: var(--space-2);
}

.dashboard-card__rows .item-list__body {
  gap: 2px;
}

.dashboard-card__more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--touch);
  font-weight: 600;
}

.dashboard-card > .card__footer {
  padding-block: 0;
}

/* K549: number cards. */
.dashboard-card--wide {
  grid-column: 1 / -1;
}

.figure-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.figure-list__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-5);
  border-top: 1px solid var(--c-border);
}

.figure-list__item:hover {
  background: var(--c-surface-3);
}

.figure-list__item:focus-within {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.figure-list__link {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.figure-list__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.figure-list__link:focus-visible {
  outline: none;
}

.figure-list__value {
  flex: none;
  min-width: 3ch;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-align: right;
}

.figure-list__value.is-zero {
  color: var(--c-text-muted);
}

.figure-list__label {
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
}

.figure-list__arrow {
  flex: none;
  color: var(--c-text-muted);
}
/* /MT-45 */

/* MT-46: grouped navigation (K556). A native details/summary per group; the title keeps the old section type. */
.nav__group-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent; /* as .nav__link: the group icon lines up with the item icons */
  border-radius: var(--radius-sm);
  color: var(--c-text-subtle);
  list-style: none;
  cursor: pointer;
}

.nav__group-toggle::-webkit-details-marker {
  display: none;
}

.nav__group:first-of-type > .nav__group-toggle {
  margin-top: var(--space-2);
}

.nav__group-toggle:hover {
  background: var(--c-surface-2);
  color: var(--c-text-muted);
}

.nav__group-icon,
.nav__group-chevron {
  width: 16px;
  height: 16px;
}

.nav__group-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav__group:not([open]) .nav__group-chevron {
  transform: rotate(-90deg);
}

/* The aggregate only while the group is closed (its items' badges are visible when it is open). */
.nav__group[open] .nav__group-badge {
  display: none;
}

/* The current group: accent title and icon plus a bar on the left edge (and the hidden ", bieżąca sekcja"). */
.nav__group.is-current > .nav__group-toggle {
  color: var(--c-accent);
}

.nav__group.is-current > .nav__group-toggle::before {
  content: "";
  position: absolute;
  top: var(--space-2);
  bottom: var(--space-2);
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--c-accent);
}

.nav__list {
  display: grid;
  gap: var(--space-1);
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 960px) {
  .nav__group-toggle {
    min-height: var(--touch);
  }

  /* The drawer may focus the active link after a tap (code review 1): its ring shows whatever the input was. */
  .sidebar.is-open .nav__link.is-active:focus {
    outline: 3px solid var(--c-accent);
    outline-offset: 2px;
  }
}

@media (forced-colors: active) {
  .nav__group.is-current > .nav__group-toggle::before {
    background: Highlight;
    forced-color-adjust: none;
  }
}

/* /MT-46 */
