/* Komponenty: formularze, przyciski, tabele, odznaki, podpisy. */

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.field .optional { color: var(--text-muted); font-weight: 400; }

input, select, textarea {
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius);
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 96, 160, 0.2);
}
textarea { resize: vertical; min-height: 70px; }

.field-error { color: var(--danger-soft-text); font-size: 12px; }
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--danger); }

.non-field-errors {
    background: var(--danger-soft-bg);
    border: 1px solid var(--danger-soft-border);
    color: var(--danger-soft-text);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    margin-bottom: 20px;
}
.non-field-errors div + div { margin-top: 4px; }
.notice {
    background: var(--success-soft-bg);
    border: 1px solid var(--success-soft-border);
    color: var(--success-soft-text);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---------- Zwijane: ramka "Info" i karty stawek (<details>) ---------- */
.notice-info { padding: 0; }
.notice-info:not([open]) { width: fit-content; border-radius: 999px; }
.notice-summary,
.rate-card-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
}
.notice-summary::-webkit-details-marker,
.rate-card-summary::-webkit-details-marker { display: none; }
.notice-summary { padding: 6px 14px; font-size: 12px; font-weight: 600; }
.notice-info:not([open]) .notice-summary { padding: 4px 12px; }
.notice-body { padding: 0 14px 10px; }
.notice-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border: 1.5px solid currentColor; border-radius: 50%;
    font-size: 10px; font-weight: 700; font-style: italic; line-height: 1;
}
.rate-card-summary { justify-content: space-between; min-height: 24px; }
.rate-card-summary .section-title { margin: 0; }
.rate-card[open] > .rate-card-summary { margin-bottom: 14px; }
/* Strzałka: w dół = zwinięte, w górę = rozwinięte. */
.notice-summary::after,
.rate-card-summary::after {
    content: '';
    width: 6px; height: 6px; flex-shrink: 0;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}
.rate-card-summary::after { color: var(--text-subtle); }
.notice-info[open] > .notice-summary::after,
.rate-card[open] > .rate-card-summary::after { transform: translateY(2px) rotate(-135deg); }
.notice-summary:focus-visible,
.rate-card-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
@media (prefers-reduced-motion: no-preference) {
    .notice-summary::after,
    .rate-card-summary::after { transition: transform 0.15s ease; }
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}
.checkbox-field input { width: 16px; height: 16px; flex-shrink: 0; }

.form-row { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
/* Checkbox obok pola z etykietą (Stawka IC w kosztach): na osi pola, nie etykiety. */
.form-row > .checkbox-field { min-height: 38px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 20px; }
/* Pole zaczyna nowy wiersz siatki (np. godziny w kosztach pod ceną, rabatem i km). */
.form-grid > .field-row-start { grid-column-start: 1; }
/* Czynniki w kosztach: stałe 4 kolumny — dwa wiersze po cztery pola (cena, rabat, noclegi, km / godziny). */
.form-grid.cost-factors-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.filter-grid { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.filter-grid .field { flex: 1 1 160px; min-width: 160px; }
.filter-grid .field-search { flex: 2 1 260px; }
.filter-actions { display: flex; gap: 10px; margin-top: 16px; }
.filter-grid .field-checkbox { flex: 0 0 auto; min-width: 0; display: flex; align-items: flex-end; }
.filter-grid .field-checkbox .checkbox-field { padding-bottom: 8px; white-space: nowrap; }
/* Filtry w dwóch wierszach (Koszty): kto/kiedy, pod spodem obieg i księgowość.
   Węższe minimum, żeby sześć pól pierwszego wiersza zmieściło się od ~1280px. */
.filter-grid-rows .field { flex: 1 1 130px; min-width: 130px; }
.filter-grid-rows .field-search { flex: 2 1 180px; }
.filter-grid-rows + .filter-grid-rows { margin-top: 14px; }
.field-narrow { max-width: 220px; }

/* Collapsible filters — toggle only appears on mobile (see media query below) */
.filter-toggle {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    padding: 2px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
}
.filter-toggle-label { display: flex; align-items: center; gap: 8px; }
.filter-toggle .filter-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: none; flex-shrink: 0; }
.filter-card.has-active-filters .filter-toggle .filter-dot { display: inline-block; }
.filter-toggle .chev { width: 16px; height: 16px; color: var(--text-muted); transition: transform var(--transition); flex-shrink: 0; }
.filter-card.collapsed .filter-toggle .chev { transform: rotate(-90deg); }

/* ---------- Buttons ---------- */
.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-subtle);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-soft-text); }

.btn-cancel {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border-strong);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.btn-cancel:hover { background: var(--surface-alt); color: var(--text); }

.btn-outline {
    text-decoration: none;
    padding: 7px 13px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-dim);
    border: 1px solid var(--border-strong);
    background: transparent;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-soft-text); }

.remove-row {
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    border-radius: var(--radius);
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    font-family: inherit;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.remove-row:hover { background: var(--danger-soft-bg); border-color: var(--danger); color: var(--danger-soft-text); }

.btn-remove-group {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    border-radius: var(--radius);
    padding: 4px 12px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn-remove-group:hover { background: var(--danger-soft-bg); border-color: var(--danger); color: var(--danger-soft-text); }

/* ---------- Tables ---------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table-wrap thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    letter-spacing: 0;
}
.table-wrap tbody td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.table-wrap tbody tr:last-child td { border-bottom: none; }
.table-wrap tbody tr[data-href] { cursor: pointer; }
.table-wrap tbody tr[data-href]:hover { background: var(--surface-alt); }
.table-wrap tfoot td {
    padding: 13px 16px;
    font-size: 13px;
    font-weight: 700;
    background: var(--surface-alt);
    border-top: 1px solid var(--border-strong);
    font-variant-numeric: tabular-nums;
}
/* Bez tego ".table-wrap thead th { text-align: left }" (wyższa specyficzność)
   wygrywał z .text-right i nagłówki kolumn liczbowych nie stały nad liczbami. */
.table-wrap th.text-right, .table-wrap td.text-right,
.card th.text-right, .card td.text-right { text-align: right; }
/* Wąskie kolumny o stałej szerokości treści (checkbox, kropki podpisów,
   linki PDF, godziny) — nagłówek i treść na jednej osi, pośrodku. */
.table-wrap th.text-center, .table-wrap td.text-center,
.card th.text-center, .card td.text-center { text-align: center; }
td.text-center .sign-status,
td.text-center .pdf-links,
td.text-center .checkbox-field { justify-content: center; }
/* Kolumny statusu/ikon (wyśrodkowane) — szerokie jak treść, nie jak reszta
   tabeli: tekstowe kolumny dostają miejsce, a checkboxy i kropki nie wiszą
   w połowie pustej kolumny. :where — żeby stałe szerokości (.col-narrow)
   wciąż wygrywały. Tylko listy (.table-wrap) — w małej tabeli w karcie
   (dni pracy) godziny zbiegały się wtedy w jedną kolumnę. */
.table-wrap :where(th.text-center) { width: 1%; white-space: nowrap; }
:where(.table-wrap, .card) :where(th, td) { vertical-align: middle; }

/* Akceptacja / faktura. Etykieta wokół checkboksa daje pole dotyku 44px —
   sam checkbox ma 20px. Tekst (.status-text) widać tylko w kartach na telefonie,
   na desktopie opisuje go nagłówek kolumny. */
.status-toggle { display: inline-flex; margin: 0; }
.status-hit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: var(--tap-target);
    min-height: var(--tap-target);
    cursor: pointer;
    font-size: 13px;
}
.status-hit:has(input:disabled) { cursor: not-allowed; }
.status-text { display: none; }
.status-toggle input {
    width: 20px; height: 20px; margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.status-toggle input:disabled { cursor: not-allowed; opacity: 0.55; }
.status-toggle input:disabled:checked { opacity: 0.8; }

/* Akcje strony w treści — na telefonie zastępują przyciski z topbaru. */
.page-actions { display: none; flex-wrap: wrap; gap: 8px; margin-bottom: var(--space-4); }
.page-actions > .btn-primary,
.page-actions > .btn-outline,
.page-actions > .more-menu > summary {
    flex: 1 1 0;
    justify-content: center;
    min-height: var(--tap-target);
    display: inline-flex;
    align-items: center;
}
.page-actions > .more-menu { flex: 1 1 0; display: flex; }

/* "Więcej": natywne <details> — klawiatura i czytniki obsługują je same. */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; white-space: nowrap; gap: 6px; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary::after { content: '▾'; font-size: 11px; }
.more-menu[open] > summary { border-color: var(--accent); color: var(--accent-soft-text); }
.more-menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.more-menu-list a {
    display: flex;
    align-items: center;
    min-height: var(--tap-target);
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}
.more-menu-list a:hover,
.more-menu-list a:focus-visible { background: var(--surface-alt); }

.workflow-row { display: flex; flex-wrap: wrap; gap: var(--space-4) 40px; }
.workflow-item { display: flex; align-items: flex-start; gap: 10px; }
.workflow-item label { font-size: 14px; cursor: pointer; }
/* Tu tekst obok to <label for> — sam jest polem dotyku, więc checkbox
   nie potrzebuje 44px i równa się z pierwszą linią tekstu. */
.workflow-item .status-hit { min-width: 0; min-height: 0; margin-top: 1px; }
.workflow-item .field-hint:empty { display: none; }

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

/* Compact table inside a .card (no wrapping box) */
.card table { width: 100%; border-collapse: collapse; }
.card thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.card tbody td { padding: 11px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.card tbody tr:last-child td { border-bottom: none; }
/* Kompaktowa tabela nie ma bocznych odstępów — bez tego kolumny stykały się,
   gdy tekst był długi. Niska specyficzność: własne odstępy tabel wygrywają. */
.card :where(thead th, tbody td, tfoot td):not(:last-child) { padding-right: 16px; }
/* .table-wrap w .card (np. tabela danych w statystykach): reguły .card mają tę
   samą specyficzność co .table-wrap, ale stoją niżej i zerowały odstępy —
   kolumny kleiły się do ramki, a ostatnia wchodziła pod cień przewijania. */
.card .table-wrap thead th { padding: 11px 16px; }
.card .table-wrap tbody td { padding: 12px 16px; }

.client-name { font-weight: 600; color: var(--text); }
.text-right { text-align: right; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ---------- Badges / chips ---------- */
.participant-tag {
    display: inline-block;
    background: var(--accent-soft-bg);
    color: var(--accent-soft-text);
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    margin: 2px 4px 2px 0;
}
/* Rodzaj usługi: ten sam kształt co uczestnik, ale z obwódką i własnym odcieniem
   na rodzaj (tokeny --tag-*) — żeby "Przegląd roczny" nie wyglądał jak nazwisko,
   a rodzaje dało się rozróżnić na pierwszy rzut oka. Kolor to tylko dodatek:
   nazwa jest zawsze napisana. */
.service-tag {
    --tag: var(--text-dim);
    display: inline-block;
    background: var(--surface-alt);
    background: color-mix(in srgb, var(--tag) 12%, var(--surface));
    color: var(--tag);
    border: 1px solid var(--border-strong);
    border-color: color-mix(in srgb, var(--tag) 38%, var(--surface));
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.service-tag--installation { --tag: var(--tag-installation); }
.service-tag--programming  { --tag: var(--tag-programming); }
.service-tag--training     { --tag: var(--tag-training); }
.service-tag--inspection   { --tag: var(--tag-inspection); }
.service-tag--mechanical   { --tag: var(--tag-mechanical); }
.service-tag--diagnostics  { --tag: var(--tag-diagnostics); }
.participant-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-soft-bg);
    color: var(--accent-soft-text);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    margin: 0 8px 8px 0;
}
.participant-chip .ref { color: var(--amber-text); font-size: 12px; }
.ic-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    background: var(--accent-soft-bg);
    color: var(--accent-soft-text);
}

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px 24px; }
.stats-row { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.stat { flex: 1; min-width: 120px; }
.stat label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.stat .value {
    font-size: 20px;
    font-weight: 600;
    color: var(--accent-soft-text);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.stat .value.negative { color: var(--danger); }
.stat .value.cost { color: var(--amber-text); }
.stat .stat-note { font-size: 12px; font-weight: 400; color: var(--text-muted); }
/* Liczby w tym samym kroju co reszta wiersza — mieszanie mono i sans w jednej
   tabeli rozjeżdżało kolumny. Cyfry o stałej szerokości daje tabular-nums. */
.margin-value { color: var(--accent-soft-text); font-variant-numeric: tabular-nums; }
.margin-value.negative { color: var(--danger); }
.cost-value { color: var(--amber-text); font-variant-numeric: tabular-nums; }
.table-wrap td.text-right,
.card td.text-right { font-variant-numeric: tabular-nums; white-space: nowrap; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 24px; }
.info-item label,
.info-item dt { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.info-item div,
.info-item dd { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.info-item-wide { grid-column: 1 / -1; }
.info-item dd { white-space: pre-line; }

/* Szczegóły raportu: blok na robota. Kolejny robot odcięty kreską i odstępem,
   tytuł "Robot N" przy samej kresce; odczyty i "Brak danych" odsunięte od pól. */
.report-robot > .section-title { margin-top: 0; }
.report-robots > .section-title + .report-robot { margin-top: 24px; }
.report-robot + .report-robot { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.report-robot > .info-grid + * { margin-top: 20px; }
.report-robot > p.muted { margin-bottom: 8px; }
.report-robot > .table-wrap + p.muted { margin-top: 16px; }

/* Przyciski pod treścią karty (Edytuj robota, Zapisz/Anuluj). */
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.card-note { margin-top: 16px; }

/* Druga lista na stronie (np. Roboty → "Tylko w zwykłych raportach"):
   wyraźny odstęp od tabeli wyżej, opis między tytułem a tabelą. */
.list-section { margin-top: 40px; }
.list-section > .section-title { margin-top: 0; }
.section-lead { margin: -4px 0 14px; }
.warn-text { color: var(--amber-text); }
.timeline-details { line-height: 1.45; }
.timeline-details > * + * { margin-top: 4px; }
.timeline-details > .pdf-links { margin-top: 8px; }
/* Roboty: sama wyszukiwarka; pod nią karta robota, ostatni przegląd i wizyty. */
.robot-search { display: flex; gap: var(--space-2); max-width: 560px; margin-bottom: var(--space-5); }
.robot-search input { flex: 1 1 auto; min-width: 0; min-height: var(--tap-target); font-size: 16px; }
.robot-search .btn-primary { flex: 0 0 auto; min-height: var(--tap-target); }
.robot-search-hint { max-width: 560px; }
.robot-info .section-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.robot-yearly-link {
    display: flex; align-items: center; gap: var(--space-3);
    min-height: var(--tap-target); padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    color: var(--text); text-decoration: none;
    transition: border-color var(--transition);
}
a.robot-yearly-link:hover { border-color: var(--accent); }
a.robot-yearly-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.robot-yearly-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--space-3); flex: 1 1 auto; min-width: 0; }
.robot-yearly-title { font-weight: 600; }
.robot-yearly-link .warn-chip { flex: 0 0 auto; white-space: nowrap; }
.robot-yearly-arrow { color: var(--accent-soft-text); }
.robot-visits td.card-title a { font-weight: 600; }

.text-block { font-size: 14px; color: var(--text-dim); white-space: pre-wrap; line-height: 1.6; }

/* ---------- Report create/edit form specifics ---------- */
.participant-you {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--accent-soft-bg);
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 10px;
}
.participant-you .badge { color: var(--accent-soft-text); font-weight: 600; }
.participant-you .muted { color: var(--text-muted); font-size: 12px; }

.participant-row { margin-bottom: 8px; }
.participant-line { display: flex; align-items: center; gap: 8px; }
.participant-line select { flex: 1; min-width: 0; }
.travel-together { margin-bottom: 12px; }
.travel-together .checkbox-field { width: fit-content; }
.travel-together .field-hint { margin: 4px 0 0; }
.participant-trip {
    margin: 8px 0 4px;
    padding: 10px 12px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 0;
}
.participant-trip[hidden] { display: none; }
.participant-trip legend { margin: 0; padding: 0 4px; }
.participant-trip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    gap: 10px 14px;
}
.participant-trip .mini-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.participant-trip .mini-field label { font-size: 12px; color: var(--text-muted); }

.day-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
}
.day-row .mini-field { display: flex; flex-direction: column; gap: 4px; }
.day-row .mini-field label { font-size: 12px; color: var(--text-muted); }
/* Ostrzeżenie (nie błąd) pod polami dnia: zapis przechodzi, serwisant sprawdza datę. */
.field-warning { font-size: 12px; color: var(--warning); }
.field-warning::before { content: '⚠ '; font-size: 11px; }
.day-row .field-warning { grid-column: 1 / -1; }

.absolute-data-buttons { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.absolute-group {
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.absolute-group-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.absolute-group-header .group-label { font-weight: 600; font-size: 14px; color: var(--text); }
.absolute-group-fields-r { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.absolute-group-fields-r .mini-field,
.absolute-group-fields-single .mini-field { display: flex; flex-direction: column; gap: 4px; }
.absolute-group-fields-r .mini-field label,
.absolute-group-fields-single .mini-field label { font-size: 12px; color: var(--text-muted); }
.absolute-group-fields-single { max-width: 220px; }
.absolute-fields-hidden { display: none; }
.absolute-group-note { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.absolute-group-note label { font-size: 12px; color: var(--text-muted); }
/* "+ Dodaj R" wyłączony, gdy robot ma już grupę R (report_form.js). */
.absolute-data-buttons .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.absolute-data-buttons .btn-secondary:disabled:hover { border-color: var(--border-strong); color: var(--text-subtle); }

/* ---------- Zwykły raport: karty "Robot N" w formularzu (_robot_card.html) ----------
   "> .robot-card": .robot-cards to też klasa tabeli na stronie robotów. */
.robot-cards > .robot-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 14px;
}
.robot-cards > .robot-card > .robot-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.robot-cards > .robot-card .robot-card-title { flex: 0 1 auto; }
/* Tytuły sekcji w karcie — mniejszy odstęp niż między sekcjami formularza. */
.robot-cards > .robot-card .section-title { margin-top: 20px; }
.robot-cards > .robot-card .absolute-groups:empty { display: none; }
.robot-cards > .robot-card .absolute-groups .absolute-group:last-child { margin-bottom: 0; }
[data-add-robot] { margin-bottom: 4px; }
.nights-toggle { width: fit-content; margin-bottom: 14px; }

/* ---------- Przegląd roczny: karty robotów i protokół (lista kontrolna) ---------- */
.field-static-label { font-size: 13px; color: var(--text-dim); }
.robot-section { display: grid; gap: var(--space-3); }
.robot-actions { display: flex; gap: 10px; flex-wrap: wrap; }
/* Lista robotów na stronie przeglądu (report_details.html). */
.robots-header {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: var(--space-3); margin-bottom: 14px;
}
.robots-header .section-title { margin: 0; }
.robots-section .table-wrap table { min-width: 0; }
.robots-table td { vertical-align: middle; }
.robots-table .robot-actions { justify-content: flex-end; align-items: center; gap: 8px; }
/* Edytuj / PL / EN / Usuń jednej wysokości (przycisk i link PDF mają różne paddingi).
   Na dotyku min-height 44px z responsive.css i tak wygrywa z height. */
.robots-table .robot-actions .inline-form { display: flex; }
.robots-table .robot-actions .btn-outline,
.robots-table .robot-actions .pdf-link {
    display: inline-flex; align-items: center; justify-content: center;
    box-sizing: border-box; height: 28px; line-height: 1;
}
.robots-table .warn-chip { white-space: nowrap; }
/* Formularz jednego robota (robot_inspection_form.html). */
.robot-context { margin: 0 0 16px; font-size: 14px; color: var(--text-muted); overflow-wrap: anywhere; }
.robot-context strong { color: var(--text); font-weight: 600; }
.robot-form-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.robot-form-header .section-title { margin: 0; overflow-wrap: anywhere; }
.robot-registry { margin-bottom: 16px; max-width: 520px; }
.robot-form h2.section-title { font-size: 12px; }
.robot-notes { margin-top: 20px; }
.choice-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.robot-form .actions { flex-wrap: wrap; }
.btn-danger-outline { color: var(--danger-soft-text); }
.btn-danger-outline:hover { border-color: var(--danger); color: var(--danger-soft-text); background: var(--danger-soft-bg); }
.robot-status:empty { display: none; }
.robot-card { margin-bottom: 12px; }
.robot-card[open] > .robot-card-summary { margin-bottom: 14px; }
.robot-card-summary { justify-content: flex-start; gap: 10px; }
.robot-card-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow-wrap: anywhere;
}
.robot-attention {
    flex-shrink: 0;
    border: 1px solid var(--warning);
    border-radius: var(--radius-pill);
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.robot-subtitle { font-size: 12px; font-weight: 600; color: var(--text-subtle); margin: 18px 0 8px; }
.robot-table-wrap { overflow-x: auto; }
/* table-layout: fixed + <colgroup> — kolumny mają stałe szerokości, więc
   wiersze listy i osi się nie rozjeżdżają, gdy etykiety mają różną długość. */
.robot-table { width: 100%; min-width: 680px; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
/* .card przed klasą: formularz robota stoi w .card, a ".card tbody td"
   (padding: 11px 0) zerował odstępy — przyciski kleiły się do pola obok. */
.card .robot-table th,
.card .robot-table td,
.robot-table th,
.robot-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.card .robot-table tr > :first-child,
.robot-table tr > :first-child { padding-left: 0; }
.card .robot-table tr > :last-child,
.robot-table tr > :last-child { padding-right: 0; }
.card .robot-table tbody tr:last-child th,
.card .robot-table tbody tr:last-child td,
.robot-table tbody tr:last-child th,
.robot-table tbody tr:last-child td { border-bottom: 0; }
/* Pola tekstowe w protokole tej samej wysokości co przyciski Tak/Nie obok. */
.robot-table input:not([type="radio"]):not([type="checkbox"]) { min-height: var(--tap-target); }
.robot-table thead th { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.robot-table thead .optional { font-weight: 400; }
.robot-table input:not([type="radio"]):not([type="checkbox"]) { width: 100%; min-width: 0; }
.checklist-table .col-nr { width: 48px; }
.checklist-table .col-answer { width: 320px; }
.checklist-table .col-note { width: 26%; }
/* Przerwa między przyciskami odpowiedzi a polem Uwagi. */
.card .checklist-table .checklist-note,
.checklist-table .checklist-note { padding-left: 16px; }
.axis-table .col-axis { width: 64px; }
.axis-table .col-grease { width: 36%; }
.axis-table .col-chip { width: 17%; }
.axis-table .col-remove { width: 60px; }
/* Smar | odczyt | przekładnia: wyraźna przerwa między grupami przycisków a polem. */
.card .axis-table .axis-chip,
.axis-table .axis-chip,
.card .axis-table .axis-gearbox,
.axis-table .axis-gearbox { padding-left: 16px; }
.checklist-nr { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.checklist-item { line-height: 1.4; overflow-wrap: anywhere; }
.axis-name { font-weight: 600; color: var(--text); white-space: nowrap; }
.axis-table .axis-name { padding-right: 0; }
.axis-remove { padding-left: 0; }
.axis-remove .remove-row:disabled { opacity: 0.45; cursor: not-allowed; }
.axis-remove .remove-row:disabled:hover { background: var(--surface-alt); border-color: var(--border-strong); color: var(--text-dim); }
.axis-chip .field-errors,
.axis-gearbox .field-errors { margin-top: 4px; }
/* Oś bez wybranego stanu przekładni (wymagany). */
.axis-gearbox.has-error .segment span { border-color: var(--danger); }
.axis-restore { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.axis-restore-label { font-size: 13px; color: var(--text-muted); }
.axis-restore .btn-outline { min-height: var(--tap-target); min-width: var(--tap-target); justify-content: center; }

/* Tak / Nie / Nie dotyczy itd.: przyciski 44px z ✓ na wybranym. Prawdziwe
   radio zostaje (strzałki, czytnik ekranu), tylko jest niewidoczne. */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented-stack { flex-direction: column; align-items: stretch; }
.segment { position: relative; display: flex; flex: 1 1 auto; min-width: 0; cursor: pointer; }
.segment input {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    margin: 0; opacity: 0; cursor: pointer;
}
.segment span {
    display: flex; flex: 1 1 auto; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--tap-target);
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    line-height: 1.25;
    text-align: center;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.segment:hover span { border-color: var(--accent); }
.segment input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft-bg);
    color: var(--accent-soft-text);
    font-weight: 600;
}
/* ✓ narysowany ramką — bez tekstu, który czytnik dokleiłby do nazwy opcji. */
.segment input:checked + span::before {
    content: '';
    flex-shrink: 0;
    width: 5px; height: 10px;
    margin: -3px 2px 0 0;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.segment input[value="no"]:checked + span,
.segment input[name^="gearbox_"][value="replace"]:checked + span {
    border-color: var(--danger); background: var(--danger-soft-bg); color: var(--danger-soft-text);
}
.segment input[name^="gearbox_"][value="check"]:checked + span {
    border-color: var(--warning); background: var(--surface-alt); color: var(--amber-text);
}
.segment input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.segment input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* Pola sterujące formsetu (DELETE) nie są widoczne — ustawia je JS. */
.formset-delete { display: none; }

/* [hidden] musi wygrać z regułami display ustawionymi na konkretnych klasach. */
[hidden] { display: none !important; }

.actions { display: flex; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ---------- Sign status / PDF links (my reports) ---------- */
.sign-status { display: flex; align-items: center; gap: 6px; }
.sign-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); display: inline-block; flex-shrink: 0; }
.sign-dot.signed { background: var(--success); }
.sign-link { margin-left: 6px; color: var(--accent-soft-text); text-decoration: none; font-size: 12px; }
.sign-link:hover { text-decoration: underline; }
.pdf-links { display: flex; gap: 8px; }
.pdf-link {
    color: var(--text-subtle);
    text-decoration: none;
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 600;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 3px 7px;
    transition: border-color var(--transition), color var(--transition);
}
.pdf-link:hover { border-color: var(--accent); color: var(--accent-soft-text); }

/* Reference numbers: monospace + amber — data that looks like data */
.ref {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--amber-text);
}

/* ---------- Signature status cards (sign report) ---------- */
.signature-card {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 16px;
}
.signature-card-thumb {
    width: 64px;
    height: 44px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.signature-card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.signature-card-info { flex: 1; min-width: 0; display: grid; gap: 4px; }
.signer-name-input { margin-top: 6px; padding: 6px 10px; font-size: 13px; max-width: 320px; }

/* Panele pod podpisami: link zdalny i "bez podpisu". */
.sign-panel {
    display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5); margin-bottom: var(--space-4);
}
.sign-panel-body { flex: 1 1 320px; min-width: 0; display: grid; gap: var(--space-2); }
.sign-panel-title { font-size: 14px; font-weight: 600; color: var(--text); }
.sign-panel-text { font-size: 13px; color: var(--text-subtle); max-width: 62ch; }
.sign-panel-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.sign-panel-waived { border-color: var(--amber); background: var(--surface-alt); }
.link-box { display: flex; gap: var(--space-2); }
/* min-width: 0 — input w flexie ma domyślnie szerokość wg atrybutu size
   i na 360px wypychał przycisk "Kopiuj" poza kartę. */
.link-box input { font-family: var(--font-mono); font-size: 12px; min-width: 0; }
.link-mail { font-size: 13px; color: var(--accent-soft-text); }
.waive-form { display: flex; gap: var(--space-2); flex-wrap: wrap; }
/* Mała etykieta nad polem — sam placeholder znika przy pisaniu i ucinał się na telefonie. */
.mini-label { display: block; font-size: 12px; color: var(--text-dim); margin: 8px 0 4px; }
.mini-label .optional { color: var(--text-muted); }
.waive-form .mini-label { flex: 1 1 100%; margin: 4px 0 0; }
.waive-form input { flex: 1 1 220px; padding: 7px 10px; font-size: 13px; }
.waived-chip {
    display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong); color: var(--text-subtle); font-size: 11px; text-decoration: none;
}
.status-chip {
    display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill);
    font-size: 11px; white-space: nowrap; border: 1px solid var(--border-strong); color: var(--text-subtle);
}
.status-chip.is-accepted { border-color: var(--accent); color: var(--accent-soft-text); background: var(--accent-soft-bg); }
.status-chip.is-invoiced { border-color: var(--success-soft-border); color: var(--success-soft-text); background: var(--success-soft-bg); }
.inline-form { display: inline; }
.link-button {
    background: none; border: 0; padding: 0; margin-left: 6px; cursor: pointer;
    font: inherit; font-size: 12px; color: var(--text-muted);
}
.link-button:hover { color: var(--text); text-decoration: underline; }

/* ---------- Zdalny podpis klienta (strona publiczna) ---------- */
.auth-card.auth-card-wide { max-width: 680px; }
.remote-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3) var(--space-4); margin: var(--space-4) 0; }
.remote-summary dt { font-size: 11px; color: var(--text-muted); }
.remote-summary dd { margin: 0; font-size: 14px; color: var(--text); }
.remote-section { margin-top: var(--space-5); }
.remote-section-title { font-size: 12px; font-weight: 600; color: var(--text-subtle); margin-bottom: var(--space-2); }
.remote-days { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.remote-days th { font-size: 11px; color: var(--text-muted); font-weight: 600; text-align: left; padding: 6px 0; border-bottom: 1px solid var(--border); }
.remote-days td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.remote-days .text-center { text-align: center; }
.remote-days .text-right { text-align: right; }
.remote-totals { font-size: 13px; color: var(--text-subtle); margin-top: var(--space-2); }
.remote-pdf { font-size: 13px; color: var(--text-subtle); margin-top: var(--space-5); }
.remote-pdf a { color: var(--accent-soft-text); }
.remote-sign-box {
    margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border);
    display: grid; gap: var(--space-3);
}
/* Przycisk rozciąga się na szerokość siatki — tekst na środek, wysokość
   jak cel dotykowy (klient podpisuje zwykle na telefonie). */
.remote-sign-box .btn-primary { justify-content: center; min-height: var(--tap-target); }
.remote-sign-box .btn-primary[disabled] { opacity: 0.5; cursor: not-allowed; }
.remote-closed-help { font-size: 13px; color: var(--text-subtle); }
.signature-card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.signature-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }

/* ---------- Fullscreen signature pad overlay — courier-style ---------- */
.signature-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg);
    flex-direction: column;
    height: 100dvh;
}
.signature-overlay.open { display: flex; }
body.signature-open { overflow: hidden; }
.signature-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.signature-overlay-header h2 { font-size: 16px; font-weight: 600; }
.signature-overlay-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}
.signature-overlay-close:hover { border-color: var(--danger); color: var(--danger-soft-text); }
.signature-overlay-canvas-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
}
.signature-overlay-canvas {
    flex: 1;
    width: 100%;
    min-height: 0;
    background: #ffffff;
    border-radius: var(--radius-lg);
    touch-action: none;
    display: block;
}
.signature-overlay-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
}
.signature-overlay-actions {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.signature-overlay-actions .btn-secondary,
.signature-overlay-actions .btn-primary {
    flex: 1;
    justify-content: center;
}

/* ---------- Empty hero (dashboard placeholder) ---------- */
.empty-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    color: var(--text-muted);
}
.empty-hero h2 { color: var(--text); font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.empty-hero p { font-size: 14px; margin-bottom: 4px; }
.empty-hero a {
    display: inline-block;
    margin-top: 16px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    transition: background var(--transition);
}
.empty-hero a:hover { background: var(--accent-hover); }

/* ---------- Focus visibility for keyboard users ---------- */
a:focus-visible, button:focus-visible, summary:focus-visible, .table-wrap:focus-visible,
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible {
    outline: 2px solid var(--accent-soft-text);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* ============================================================
   Responsive — mobile-first additions
   ============================================================ */

/* Hamburger toggle (hidden on desktop) */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    width: var(--tap-target);
    height: var(--tap-target);
    padding: 0;
    cursor: pointer;
    color: var(--text-dim);
    flex-shrink: 0;
    border-radius: var(--radius);
    transition: color var(--transition);
}
.menu-toggle:hover { color: var(--text); }
.menu-toggle span {
    display: block;
    width: 18px;
    height: 1.5px;
    background: currentColor;
    border-radius: 1px;
}

/* Backdrop overlay when sidebar is open on mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99;
}


/* ---------- Wyrównanie pól w siatce formularza ---------- */
/* Każde pole zajmuje trzy wiersze siatki rodzica: etykieta / kontrolka /
   komunikaty (.field-errors). Dzięki subgrid pola w jednym rzędzie dzielą te
   wiersze, więc inputy stoją w linii niezależnie od tego, czy sąsiad ma
   zawiniętą etykietę albo komunikat błędu pod spodem. Poprzednie dosuwanie
   do dołu komórki wyrównywało etykiety, ale błąd pod polem podnosił jego input. */
@supports (grid-template-rows: subgrid) {
    .form-grid .field {
        display: grid;
        grid-row: span 3;
        grid-template-rows: subgrid;
        row-gap: 6px;
    }
    .form-grid .field > label { align-self: end; }

    .day-row { grid-template-rows: auto auto auto; align-items: start; }
    .day-row .mini-field { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 4px; }
    .day-row .mini-field > label { align-self: end; }
    /* Sam grid-row nie wystarczy: element z jawnym wierszem układany jest
       przed pozostałymi i zająłby pierwszą kolumnę. */
    .day-row .remove-row { grid-row: 2; grid-column: 3; }
}
/* Bez subgrid przycisk "×" układa się po kolei — ostrzeżenie idzie na koniec,
   inaczej zepchnęłoby "×" do pierwszej kolumny następnego wiersza. */
@supports not (grid-template-rows: subgrid) {
    .day-row .field-warning { order: 1; }
}
.field-errors { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Tabele edytowalne (Klienci, Użytkownicy) ---------- */
.editable-table td { vertical-align: top; }
/* Cała etykieta (komórka) przełącza pole — 16px kwadracik to za mały cel. */
.editable-table .checkbox-field { min-height: 38px; }
.editable-table input[type="text"],
.editable-table input[type="number"] { width: 100%; }
.editable-table .col-narrow { width: 140px; }
/* Do prawej wyrównujemy tylko liczby — symbol jest tekstem. */
.editable-table .col-narrow input[type="number"] { text-align: right; }
/* Etykieta pola w wierszu tabeli: dla czytnika zawsze, wizualnie tylko w
   układzie kart na telefonie (responsive.css) — na desktopie mówi to nagłówek. */
.cell-label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono { font-family: var(--font-mono); }

.warn-chip {
    display: inline-block;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--danger-soft-bg);
    color: var(--danger-soft-text);
    border: 1px solid var(--danger-soft-border);
    font-size: 12px;
}

/* ---------- Przycisk "ghost" ---------- */
/* Trzeci wariant obok primary i secondary: akcja drugorzędna bez ramki. */
.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    border-radius: var(--radius);
    padding: 8px var(--space-3);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

/* ---------- Cele dotykowe ---------- */
/* Powiększamy obszar klikalny bez zmiany wyglądu przycisku: pseudoelement
   rozpycha go do 44px, więc layout zostaje taki sam jak był. */
/* .auth-theme-toggle zostaje fixed — też jest blokiem zawierającym dla ::after. */
/* Nie dla linków w tabelach (Podpisz / Pomiń): pseudoelement wystawał poza
   .table-wrap, dawał jej pionowy pasek przewijania, a przy akcjach
   ułożonych pionowo na telefonie "Pomiń" przykrywał dolną część "Podpisz".
   Te dostają prawdziwą wysokość w responsive.css (pointer: coarse). */
.remove-row, .btn-remove-group,
.theme-toggle:not(.auth-theme-toggle), .signature-overlay-close, .dtp-nav { position: relative; }
.remove-row::after, .btn-remove-group::after,
.theme-toggle::after, .signature-overlay-close::after, .dtp-nav::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    min-width: var(--tap-target);
    min-height: var(--tap-target);
    width: 100%; height: 100%;
}

/* ---------- Pola liczbowe ---------- */
/* Natywne strzałki są wąskie, źle wyglądają w ciemnym motywie i łatwo je
   trafić przypadkiem na stronie kosztów. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Błędy pól ---------- */
/* Sam kolor ramki bywa nieczytelny na telefonie w pełnym słońcu — komunikat
   dostaje własny znacznik, a nie tylko odcień. */
.field-error::before {
    content: '⚠ ';
    font-size: 11px;
}

/* ---------- Zapowiedź przewijania szerokich tabel ---------- */
.table-wrap { position: relative; }
.table-wrap::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--surface));
    opacity: 0;
    transition: opacity var(--transition);
}
.table-wrap.is-scrollable::after { opacity: 1; }

/* ---------- Wybór daty i godziny ---------- */
.dtp-field { position: relative; display: flex; align-items: center; }
.dtp-display { width: 100%; padding-right: 36px !important; }
.dtp-icon {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    background: none;
    border: 0;
    padding: 4px;
    color: var(--text-muted);
    pointer-events: none;
}
.dtp-icon svg { width: 16px; height: 16px; }

/* Okno to <dialog> (showModal) w warstwie top-layer. Szeroki ekran: kalendarz
   w lewej kolumnie na całą wysokość, nagłówek i godzina w prawej. */
.dtp-popover {
    position: fixed;
    inset: auto;
    margin: 0;
    width: fit-content;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    display: grid;
    grid-template-columns: 280px 264px;
    grid-template-rows: auto 1fr;
    column-gap: var(--space-5);
    row-gap: 10px;
    padding: var(--space-3) var(--space-4);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.dtp-popover:not([open]) { display: none; }
.dtp-popover::backdrop { background: transparent; }
.dtp-popover button { touch-action: manipulation; }

.dtp-head { grid-column: 2; grid-row: 1; display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); min-width: 0; }
.dtp-head .btn-primary, .dtp-head .btn-ghost { min-height: 36px; }
.dtp-title { flex: 1; min-width: 0; display: grid; }
.dtp-eyebrow { font-size: 11px; color: var(--text-muted); }
.dtp-title h2 { font-size: 16px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Obok pola nagłówek jest zbędny wizualnie — zostaje dla czytnika (aria-labelledby). */
.dtp-popover:not(.dtp-sheet) .dtp-title {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.dtp-tabs { display: none; }

.dtp-cal { grid-column: 1; grid-row: 1 / span 2; }
.dtp-header { display: grid; grid-template-columns: 32px 1fr 32px auto; align-items: center; gap: var(--space-1); margin-bottom: 6px; }
.dtp-month { font-weight: 600; font-size: 14px; text-align: center; text-transform: capitalize; }
.dtp-nav {
    background: none; border: 1px solid var(--border-strong); color: var(--text-dim);
    border-radius: var(--radius); width: 32px; height: 32px; cursor: pointer; font-size: 16px;
    line-height: 1; font-family: inherit;
}
.dtp-nav:hover { border-color: var(--accent); color: var(--accent-soft-text); }
.dtp-today {
    height: 32px; padding: 0 var(--space-2); background: none; border: 0; border-radius: var(--radius);
    color: var(--accent-soft-text); font: 500 13px var(--font); cursor: pointer;
}
.dtp-today:hover { background: var(--surface-alt); }

.dtp-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dtp-grid th { height: 18px; padding: 0; font-size: 11px; font-weight: 500; color: var(--text-muted); }
.dtp-grid td { padding: 0; height: 36px; }
.dtp-day {
    width: 100%; height: 36px; background: none; border: 1px solid transparent; color: var(--text);
    border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.dtp-day:hover { background: var(--surface-alt); }
.dtp-day.weekend { color: var(--danger-soft-text); }
.dtp-day.dtp-outside { color: var(--text-subtle); }
.dtp-day.today { border-color: var(--border-strong); }
.dtp-day.selected { background: var(--accent); color: #fff; }

.dtp-time { grid-column: 2; grid-row: 2; }
.dtp-time-label { font-size: 11px; color: var(--text-muted); margin-bottom: var(--space-1); }
.dtp-hours { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-1); margin-bottom: 10px; }
.dtp-minutes { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-1); }
.dtp-chip {
    min-height: 36px; background: var(--surface-alt); border: 1px solid var(--border); color: var(--text-dim);
    border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font-mono); font-size: 13px;
}
/* Godziny nocne słabiej, ale z tym samym polem dotyku. */
.dtp-chip.dtp-night { background: transparent; color: var(--text-subtle); }
.dtp-chip:hover { border-color: var(--accent); color: var(--text); }
.dtp-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Tylko data: jedna kolumna, nagłówek nad kalendarzem. */
.dtp-popover.dtp-date-only { grid-template-columns: 280px; }
.dtp-date-only .dtp-head { grid-column: 1; }
.dtp-date-only .dtp-cal { grid-row: 2; }

/* Niski ekran (telefon w poziomie): mniejsze wiersze, żeby okno się mieściło. */
@media (max-height: 420px) {
    .dtp-grid td, .dtp-day { height: 32px; }
    .dtp-chip { min-height: 32px; }
}

/* ---------- Telefon: arkusz od dołu ----------
   Kalendarz i godzina jeden pod drugim miały 657–736px i przewijały się na
   każdym telefonie. Tu są zakładkami w tym samym miejscu siatki, a nieaktywny
   panel jest tylko niewidoczny — arkusz ma wysokość wyższego z nich (~480px). */
.dtp-popover.dtp-sheet {
    inset: auto 0 0 0;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: var(--space-3);
    padding: var(--space-3) var(--space-4) var(--space-4);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
}
.dtp-popover.dtp-sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
@media (prefers-reduced-motion: no-preference) {
    .dtp-popover.dtp-sheet[open] { animation: dtp-rise 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
    @keyframes dtp-rise { from { transform: translateY(24px); opacity: 0.4; } }
}
.dtp-sheet .dtp-head, .dtp-sheet .dtp-cal, .dtp-sheet .dtp-time { grid-column: 1; grid-row: auto; }
.dtp-sheet .dtp-head { min-height: var(--tap-target); }
.dtp-sheet .dtp-head .btn-primary,
.dtp-sheet .dtp-head .btn-ghost { min-height: var(--tap-target); }
.dtp-sheet.dtp-tabbed .dtp-clear-text { display: none; }

.dtp-tabbed .dtp-tabs { display: grid; grid-template-columns: minmax(0, 1fr) var(--tap-target); gap: 6px; }
.dtp-tablist { display: grid; grid-template-columns: 1.35fr 1fr; gap: 6px; min-width: 0; }
.dtp-tab {
    min-height: 48px; min-width: 0; display: flex; align-items: center; justify-content: center; gap: var(--space-2);
    border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface-alt);
    color: var(--text-dim); font: 16px var(--font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.dtp-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.dtp-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtp-tab .dtp-empty { color: var(--text-subtle); }
.dtp-tab[aria-selected="true"] {
    border-color: var(--accent); background: var(--accent-soft-bg); color: var(--text);
    box-shadow: inset 0 -2px 0 var(--accent-soft-text);
}
.dtp-clear-icon {
    border-radius: var(--radius); border: 1px solid var(--border-strong); background: none;
    color: var(--text-subtle); font-size: 16px; cursor: pointer;
}
.dtp-tabbed .dtp-cal, .dtp-tabbed .dtp-time { grid-row: 3; }
.dtp-cal[data-inactive], .dtp-time[data-inactive] { visibility: hidden; }

.dtp-sheet .dtp-header { grid-template-columns: var(--tap-target) 1fr var(--tap-target) auto; height: var(--tap-target); margin-bottom: var(--space-1); }
.dtp-sheet .dtp-nav { width: var(--tap-target); height: var(--tap-target); font-size: 18px; }
.dtp-sheet .dtp-today { height: var(--tap-target); font-size: 14px; }
.dtp-sheet .dtp-month { font-size: 15px; }
.dtp-sheet .dtp-grid th { height: 24px; font-size: 12px; }
.dtp-sheet .dtp-grid td, .dtp-sheet .dtp-day { height: var(--tap-target); }
.dtp-sheet .dtp-day { font-size: 16px; }
.dtp-sheet .dtp-day.dtp-outside { font-size: 14px; }
.dtp-sheet .dtp-time-label { font-size: 12px; margin-bottom: 6px; }
.dtp-sheet .dtp-hours { gap: 6px; margin-bottom: 14px; }
.dtp-sheet .dtp-minutes { gap: 6px; }
.dtp-sheet .dtp-chip { min-height: var(--tap-target); font-size: 16px; }

/* ---------- Ograniczenie animacji ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Warianty wcześniej wpisywane w atrybutach style="" szablonów. */
.back-link-block { display: inline-block; margin-bottom: var(--space-5); }
.actions-tight { margin-top: 0; }

/* Ekran startowy: zestaw skrótów zamiast pustej obietnicy statystyk. */
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    margin-top: var(--space-6);
}
.hero-actions a { margin-top: 0; }

/* ---------- Komunikaty po akcji (django.contrib.messages) ---------- */
.flash-list { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.flash {
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    border: 1px solid var(--border-strong);
    background: var(--surface-alt);
    color: var(--text);
}
.flash-success {
    background: var(--success-soft-bg);
    border-color: var(--success-soft-border);
    color: var(--success-soft-text);
}
.flash-error {
    background: var(--danger-soft-bg);
    border-color: var(--danger-soft-border);
    color: var(--danger-soft-text);
}
.flash-warning { border-color: var(--warning); }
.draft-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-4); }
.draft-actions { display: flex; gap: var(--space-2); }

/* ---------- Podgląd raportu dla klienta ---------- */
.report-preview {
    position: fixed; inset: 0; z-index: 150;
    display: flex; flex-direction: column;
    background: var(--bg); color: var(--text);
}
.report-preview[hidden] { display: none; }
body.preview-open { overflow: hidden; }
.report-preview-header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: max(12px, env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--border);
}
.report-preview-header h2 { margin: 0; font-size: 16px; }
.report-preview-header h2:focus { outline: none; }
.report-preview-body {
    flex: 1; overflow-y: auto; overscroll-behavior: contain;
    padding: 16px; display: grid; gap: var(--space-4); align-content: start;
    max-width: 760px; width: 100%; margin: 0 auto; box-sizing: border-box;
}
.preview-section h3 {
    margin: 0 0 var(--space-2); font-size: 12px; font-weight: 600; color: var(--text-subtle);
    padding-left: 9px; border-left: 2px solid var(--accent);
}
.preview-grid { margin: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 6px 12px; font-size: 14px; }
.preview-grid dt { color: var(--text-muted); }
.preview-grid dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.report-preview-footer {
    border-top: 1px solid var(--border); background: var(--surface);
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    display: grid; gap: var(--space-2);
}
.report-preview-footer .signer-name-input { max-width: none; }
.report-preview-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.preview-signed { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; margin-top: var(--space-4); }
.preview-signed[hidden] { display: none; }

/* ---------- E-mail z raportem (szczegóły raportu) ---------- */
.email-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: 13px; }
.email-status .inline-form { margin-left: auto; }
.email-state { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.email-state .sign-dot { margin-right: 6px; vertical-align: middle; }
/* Przegląd roczny: "Język PDF [lista] [Wyślij]" w jednym wierszu, pole i przycisk tej samej wysokości. */
.email-send-form { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; flex-wrap: wrap; }
.email-send-form label { color: var(--text-muted); font-size: 13px; }
.email-send-form select { width: auto; min-width: 180px; padding: 0 10px; font-size: 13px; }
.email-send-form select,
.email-send-form button { min-height: 36px; justify-content: center; }
.email-send-form :disabled { opacity: 0.5; cursor: not-allowed; }
.email-send-form .btn-primary:disabled:hover { background: var(--accent); }
.email-send-form .btn-outline:disabled:hover { border-color: var(--border-strong); color: var(--text-dim); }
.email-history { margin-top: var(--space-3); font-size: 12px; color: var(--text-muted); }
.email-history summary { cursor: pointer; color: var(--accent-soft-text); }
.email-history ul { margin: var(--space-2) 0 0; padding-left: 18px; display: grid; gap: 2px; overflow-wrap: anywhere; }

/* ---------- Kolejka offline ("Do wysłania") ---------- */
.outbox-chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
    border-radius: var(--radius-pill); border: 1px solid var(--warning);
    color: var(--text); font-size: 12px; text-decoration: none; white-space: nowrap;
}
.outbox-chip[hidden], .nav-badge[hidden] { display: none; }
.outbox-intro { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.outbox-intro p { margin: 0; flex: 1 1 260px; font-size: 13px; }
.outbox-status:not(:empty) { margin-bottom: var(--space-3); font-size: 13px; color: var(--success-soft-text); }
.outbox-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.outbox-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; }
.outbox-item.is-invalid { border-color: var(--danger-soft-border); }
.outbox-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.outbox-meta { font-size: 12px; margin-top: 2px; }
.outbox-state { font-size: 13px; margin-top: var(--space-2); }
.outbox-errors { margin: var(--space-2) 0 0; padding-left: 18px; font-size: 13px; color: var(--danger-soft-text); }
.outbox-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
/* Strona "Brak połączenia": przyciski jeden pod drugim, równej szerokości
   i wysokości, z wyśrodkowanym tekstem — <button> i <a> wyglądają tak samo. */
.offline-actions { display: grid; gap: var(--space-2); margin: var(--space-4) 0; }
.offline-actions > * {
    display: flex; align-items: center; justify-content: center;
    width: 100%; min-height: var(--tap-target); box-sizing: border-box;
    text-align: center; font-size: 14px;
}

/* ---------- Hasło: link na stronie logowania, panel użytkownika, menu ---------- */
.auth-forgot { margin-top: var(--space-3); font-size: 13px; text-align: center; }
/* Formularze w karcie (Moje konto): odstęp między polami i przed przyciskiem. */
.stacked-fields { display: grid; gap: 18px; margin: var(--space-3) 0 var(--space-5); max-width: 520px; }
.card > .field-hint { margin-bottom: var(--space-2); }
/* Lista wymagań hasła (help_text Django to <ul>) — wcięta, w linii z polem. */
.field-hint ul { margin: 2px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.password-link { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.password-link .field-hint { margin-bottom: var(--space-3); }
/* W stopce menu obok "Wyloguj się": ta sama linia, rozmiar i kolor; para przy prawej krawędzi. */
.sidebar-footer .account-link {
    margin-left: auto; display: inline-flex; align-items: center;
    font-size: 13px; line-height: 1.3; color: var(--text-muted); text-decoration: none;
    transition: color var(--transition);
}
.account-link.active, .account-link:hover { color: var(--text); }

/* ---------- Powiadomienia push (dashboard) ---------- */
.push-card {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
    border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
    padding: 10px 14px; margin-bottom: var(--space-4); font-size: 13px;
}
.push-card[hidden] { display: none; }
.push-card > .notice-icon { color: var(--accent-soft-text); flex-shrink: 0; }
.push-card-text { flex: 1 1 220px; min-width: 0; }
.push-card-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.card > .push-card { margin: var(--space-3) 0 0; }

/* ---------- Powiadomienia: dzwonek w nagłówku i lista ---------- */
.bell-link {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--radius);
    border: 1px solid var(--border-strong); background: var(--surface-alt); color: var(--text-dim);
    transition: border-color var(--transition), color var(--transition);
}
.bell-link:hover { border-color: var(--accent); color: var(--accent-soft-text); }
.bell-link.has-unread { color: var(--text); }
.bell-link svg { width: 17px; height: 17px; display: block; }
.bell-count {
    position: absolute; top: -6px; right: -7px;
    display: inline-flex; align-items: center; justify-content: center;
    height: 17px; min-width: 17px; padding: 0 4px; border-radius: var(--radius-pill);
    background: var(--amber); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 1;
    font-variant-numeric: tabular-nums; text-box: trim-both cap alphabetic;
    box-shadow: 0 0 0 2px var(--bg);
}
.bell-count[hidden] { display: none; }
.notification-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.notification-item {
    display: flex; align-items: flex-start; gap: var(--space-3);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 12px 16px; color: var(--text-muted); text-decoration: none;
    transition: border-color var(--transition);
}
.notification-item:hover { border-color: var(--border-strong); }
.notification-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.notification-item.is-unread { border-color: var(--accent); background: var(--accent-soft-bg); color: var(--text-dim); }
.notification-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; flex-shrink: 0; background: transparent; }
.is-unread .notification-dot { background: var(--accent-soft-text); }
.notification-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.notification-title { font-weight: 600; color: var(--text); }
.notification-item:not(.is-unread) .notification-title { font-weight: 500; }
.notification-body { font-size: 13px; overflow-wrap: anywhere; }
.notification-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.notification-footnote { margin-top: var(--space-4); }

/* ---------- Aplikacja instalowana ---------- */
.install-hint {
    display: flex; align-items: flex-start; gap: var(--space-3);
    background: var(--accent-soft-bg); border: 1px solid var(--accent); color: var(--text);
    border-radius: var(--radius); padding: 10px 14px; margin-bottom: var(--space-4); font-size: 13px;
}
.install-hint[hidden] { display: none; }
.install-hint > .notice-icon { color: var(--accent-soft-text); margin-top: 2px; flex-shrink: 0; }
.install-hint-body { flex: 1; min-width: 0; }
.install-share { display: inline-block; padding: 0 3px; border: 1px solid currentColor; border-radius: 4px; font-size: 11px; }
.install-button { margin-top: var(--space-2); }
.install-hint-close {
    flex-shrink: 0; background: none; border: 0; color: var(--text-muted); cursor: pointer;
    font: inherit; font-size: 14px; padding: 2px 6px; border-radius: var(--radius);
}
.install-hint-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.update-banner {
    position: fixed; z-index: 50;
    left: 50%; transform: translateX(-50%);
    bottom: max(16px, env(safe-area-inset-bottom));
    width: min(420px, calc(100% - 32px));
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    padding: 10px 12px 10px 16px; font-size: 13px; color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---------- Historia zmian raportu ---------- */
.revision-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.revision + .revision { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.revision-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-3); margin-bottom: var(--space-2); font-size: 13px; }
.revision-when { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.revision-changes { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; overflow-wrap: anywhere; }
.revision-field { color: var(--text-muted); }
.revision-changes del { color: var(--text-muted); }
.revision-changes ins { text-decoration: none; color: var(--text); font-weight: 500; }
.revision-action { font-weight: 600; color: var(--text); }
.revision-long { display: inline; }
.revision-long > summary { display: inline-flex; align-items: center; cursor: pointer; color: var(--accent-soft-text); text-decoration: underline; text-underline-offset: 2px; }
.revision-long[open] > summary { margin-bottom: 4px; }
.revision-long[open] { display: block; margin-top: 2px; }
@media (pointer: coarse) {
    .revision-long > summary { min-height: var(--tap-target); }
}

/* ---------- Status konta ---------- */
.nav-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 18px;
    min-width: 18px;          /* jedna cyfra = koło */
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--amber);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    /* Przycina pole tekstu do wysokości cyfr, więc flex centruje sam glif,
       a nie pole linii fontu z nierównym zapasem nad i pod cyframi. */
    text-box: trim-both cap alphabetic;
}
.status-cell { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.status-chip {
    display: inline-block;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    color: var(--text-subtle);
    font-size: 12px;
    white-space: nowrap;
}
.status-active { border-color: var(--success-soft-border); color: var(--success-soft-text); }
.status-pending { border-color: var(--amber); color: var(--amber-text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- Przyklejony pasek filtrów ----------
   .content jest kontenerem przewijania (topbar leży poza nim). Ujemny top
   znosi jego padding, więc pasek przykleja się tuż pod topbarem.
   Tło zasłania przewijaną treść. */
.sticky-bar {
    position: sticky;
    top: calc(-1 * var(--content-pad-y, 0px));
    z-index: 20;
    background: var(--bg);
    /* Ujemny margines mieści się w odstępie nad paskiem (padding .content
       albo margines komunikatów), więc przed przewinięciem nic nie zasłania. */
    margin: calc(-1 * var(--space-3)) 0 var(--space-4);
    padding: var(--space-3) 0;
}
.sticky-bar > :last-child { margin-bottom: 0; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.form-grid + .field { margin-top: var(--space-5); }
.label-with-chip { display: flex; align-items: center; gap: var(--space-2); }

/* ---------- Dashboard ---------- */
.dash-section { margin-bottom: var(--space-6, 28px); }
.dash-heading { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: var(--space-3); }
.dash-sub { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: var(--space-2); }

.attention-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: var(--space-4); }
.attention-card {
    background: var(--surface); border: 1px solid var(--border);
    border-left: 3px solid var(--amber); border-radius: var(--radius-lg);
    padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3);
}
.attention-head { display: flex; align-items: baseline; gap: var(--space-3); }
.attention-count { font-size: 24px; font-weight: 600; color: var(--text); line-height: 1; }
.attention-title { font-size: 13px; color: var(--text-dim); }
.attention-list { list-style: none; display: grid; gap: 6px; font-size: 13px; }
.attention-list a { color: var(--text); font-weight: 500; }
.attention-list .muted { margin-left: 6px; font-size: 12px; }
.attention-missing { display: block; font-size: 12px; color: var(--amber-text); }
.attention-more { font-size: 12px; color: var(--accent-soft-text); text-decoration: none; margin-top: auto; }
.attention-more:hover { text-decoration: underline; }
.dash-section > .attention-more { display: inline-block; margin-top: var(--space-2); }

/* Kafelki KPI — wartości w cyfrach proporcjonalnych (duże, samodzielne liczby). */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-3); }
.kpi-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 600; color: var(--text); line-height: 1.2; }
.kpi-delta { font-size: 12px; color: var(--text-subtle); margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kpi-delta-good { color: var(--success-soft-text); }
.kpi-delta-bad { color: var(--danger-soft-text); }
.kpi-delta-none { color: var(--text-muted); }

/* Specyficzność jak ".table-wrap table" (min-width: 640px) — samo
   ".dash-table" przegrywało i tabela zawsze przewijała się w poziomie. */
.table-wrap .dash-table { min-width: 0; }
.recent-list { list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.recent-list li + li { border-top: 1px solid var(--border); }
.recent-link { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--space-3); align-items: baseline;
               padding: 12px 16px; text-decoration: none; color: var(--text); font-size: 13px; }
.recent-link:hover { background: var(--surface-alt); }
.recent-client { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-date { color: var(--text-subtle); font-variant-numeric: tabular-nums; }

/* ---------- Statystyki: poziome wykresy słupkowe ---------- */
.chip-divider { width: 1px; align-self: stretch; background: var(--border-strong); }
.stats-note { margin: 0 0 var(--space-5); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: var(--space-4); }
.chart-card { margin-bottom: 0; padding: var(--space-5); }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: var(--space-4); }
.bar-chart { display: grid; gap: 2px; }
.bar-row {
    display: grid; grid-template-columns: minmax(90px, 34%) minmax(0, 1fr) auto;
    align-items: center; gap: var(--space-3);
    padding: 5px 6px; border-radius: var(--radius-sm); cursor: default; outline: none;
}
.bar-row:hover, .bar-row:focus-visible { background: var(--surface-alt); }
.bar-row:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.bar-name { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Słupek ≤24px, kwadratowy przy linii bazowej, zaokrąglony 4px na końcu. */
.bar-track { display: block; height: 14px; }
.bar { display: block; height: 100%; width: var(--w); min-width: 2px; background: var(--viz-1);
       border-radius: 0 4px 4px 0; transition: filter var(--transition); }
.bar-row:hover .bar, .bar-row:focus-visible .bar { filter: brightness(1.15); }

/* Użycie: komputer / telefon / tablet — jeden pasek podzielony na udziały. */
.usage-card { margin-top: var(--space-5); padding: var(--space-5); }
.usage-split { display: flex; gap: 2px; height: 14px; border-radius: var(--radius-pill); overflow: hidden; margin: var(--space-3) 0; }
.usage-seg { width: var(--w); min-width: 4px; }
.usage-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); list-style: none; padding: 0; margin: 0 0 var(--space-4); font-size: 13px; }
.usage-legend li { display: inline-flex; align-items: center; gap: 6px; }
.usage-dot { width: 10px; height: 10px; border-radius: 50%; }
.usage-desktop { background: var(--viz-1); }
.usage-mobile { background: var(--amber); }
.usage-tablet { background: var(--text-muted); }
.usage-card .field-hint { margin-top: var(--space-3); }
.bar-value { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 56px; text-align: right; }

.bar-tooltip {
    position: fixed; z-index: 400; pointer-events: none;
    display: grid; gap: 2px; padding: 8px 10px; max-width: 260px;
    background: var(--surface-alt); border: 1px solid var(--border-strong);
    border-radius: var(--radius); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.bar-tooltip[hidden] { display: none; }
.bar-tooltip-value { font-size: 14px; color: var(--text); }
.bar-tooltip-name { font-size: 12px; color: var(--text-dim); }
.bar-tooltip-share { font-size: 11px; color: var(--text-muted); }

.stats-table-card { margin-top: var(--space-5); }
.stats-table-card summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.stats-table-card[open] summary { margin-bottom: var(--space-4); }

/* ---------- Historia wyliczeń kosztów ---------- */
.history-scroll { overflow-x: auto; }
.history-table { min-width: 860px; }
.history-table td { vertical-align: top; font-variant-numeric: tabular-nums; }
.card .history-table th, .card .history-table td { padding-right: var(--space-3); }
.nowrap { white-space: nowrap; }
.delta-up { color: var(--success-soft-text); white-space: nowrap; }
.delta-down { color: var(--danger); white-space: nowrap; }
.history-rates { margin-top: 4px; font-size: 12px; }
.history-rates summary { cursor: pointer; color: var(--accent-soft-text); }
/* Użyte stawki: każda stawka to blok — nazwa, pod nią kwoty po trzy w wierszu.
   Także na desktopie: tabela 8 kolumn w komórce "Powód" rozpychała historię. */
.history-rates table { margin-top: var(--space-2); min-width: 240px; }
.history-rates table,
.history-rates tbody { display: block; }
.history-rates thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
}
.history-rates tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 8px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}
.card .history-rates td { padding: 0; border: 0; font-size: 12px; text-align: left; }
.history-rates td.rate-role,
.history-rates td.rate-name { grid-column: span 3; }
.card .history-rates td.rate-role { font-size: 11px; }
.card .history-rates td.rate-name { font-weight: 600; margin-top: -4px; }
.history-rates td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    color: var(--text-muted);
}
/* Wysokość pola tekstowego w tym samym wierszu — checkbox na jego osi. */
.editable-table .checkbox-field { min-height: 38px; }
.label-with-chip .contract-chip[hidden] { display: none; }
.sticky-bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.sticky-bar-row .chip-filter { margin-bottom: 0; }
.sticky-bar > * + .content-header { margin-top: var(--space-3); }
.sticky-bar .filter-card { margin-bottom: 0; }
.content-header-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.search-field { flex: 0 1 280px; }
.search-field input { padding: 6px 12px; }
/* Lokalizacje klienta: lista w raporcie, kolumna i panel w Klientach. */
[data-location-choice]:not([hidden]) + input { margin-top: var(--space-2); }
.editable-table .col-locations { width: 36%; }
/* Przycisk wygląda jak kontrolka tej samej wysokości co pola w wierszu — inaczej
   ginie między polami. Rozwija panel lokalizacji pod wierszem. */
.client-locations .locations-link {
    display: flex; align-items: center; gap: var(--space-2);
    width: 100%; min-height: 38px; padding: 4px 10px 4px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font: inherit; font-size: 14px; text-align: left; cursor: pointer;
    transition: border-color var(--transition);
}
.client-locations .locations-link:hover,
.client-locations .locations-link[aria-expanded="true"] { border-color: var(--accent); }
.client-locations .locations-link.is-empty { color: var(--accent-soft-text); border-style: dashed; }
.locations-default { min-width: 0; overflow-wrap: anywhere; }
.locations-nip { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.locations-chev { width: 16px; height: 16px; flex-shrink: 0; margin-left: auto; color: var(--text-muted); transition: transform var(--transition); }
.locations-link[aria-expanded="true"] .locations-chev { transform: rotate(180deg); }
.locations-more {
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft-bg);
    color: var(--accent-soft-text);
    font-size: 12px;
}
.editable-table td.client-locations { vertical-align: middle; }

/* Panel pod wierszem klienta. [hidden] musi wygrać z układem kart (tr: flex). */
.clients-table tr[hidden] { display: none; }
.clients-table .client-group.is-open .client-row td { border-bottom-color: transparent; }
.table-wrap .clients-table .locations-panel-row > td { padding: 4px 16px 16px; background: var(--surface-alt); }
.locations-panel { max-width: 1080px; }
.location-head,
.location-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 170px minmax(0, 1fr) 120px 44px;
    gap: 6px 12px;
    align-items: start;
}
.location-head { padding: 8px 0 4px; font-size: 12px; color: var(--text-muted); }
.location-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.location-nip input { font-variant-numeric: tabular-nums; }
.location-default { min-height: 38px; font-size: 13px; }
.location-remove .btn-outline { min-width: 38px; min-height: 38px; justify-content: center; padding: 0 10px; }
.location-row.is-deleted .location-name input,
.location-row.is-deleted .location-nip input,
.location-row.is-deleted .location-contact input { text-decoration: line-through; color: var(--text-muted); background: var(--surface-alt); }
.location-row.is-deleted .location-default { opacity: 0.5; }
.location-deleted-note { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--danger-soft-text); }
.location-empty { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }
.locations-panel-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.contract-chip {
    display: inline-block;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    border: 1px solid var(--accent);
    color: var(--accent-soft-text);
    background: var(--accent-soft-bg);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    vertical-align: middle;
}

/* ---------- Użytkownicy: lista + panel ---------- */
.users-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.users-layout.has-panel { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); }

.chip-filter { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    font-size: 13px;
    text-decoration: none;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.filter-chip:hover { border-color: var(--accent); color: var(--text); }
.filter-chip.is-active { background: var(--accent-soft-bg); border-color: var(--accent); color: var(--accent-soft-text); }
.filter-chip-count { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.filter-chip.is-active .filter-chip-count { color: inherit; }
.filter-chip.has-pending .filter-chip-count { color: var(--amber-text); font-weight: 600; }

.user-group { margin-bottom: var(--space-4); }
.user-group table { min-width: 0; }
.table-wrap thead th.user-group-title { font-size: 12px; color: var(--text-subtle); }
.user-group-count { color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.user-link { color: var(--text); font-weight: 500; text-decoration: none; }
.user-login { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.user-symbol { width: 90px; }
.user-status { width: 110px; text-align: right; }
.table-wrap tbody tr.is-selected { background: var(--accent-soft-bg); box-shadow: inset 2px 0 0 var(--accent-soft-text); }
.table-wrap tbody tr.is-selected:hover { background: var(--accent-soft-bg); }

.user-panel { position: sticky; top: var(--space-4); margin-bottom: 0; }
.user-panel-back { display: none; margin-bottom: var(--space-4); }
.user-panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.user-panel-header h2 { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.user-panel-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: var(--radius); color: var(--text-muted); text-decoration: none;
}
.user-panel-close:hover { background: var(--surface-alt); color: var(--text); }

.user-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4);
    margin: var(--space-5) 0; padding: var(--space-4) 0;
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.user-meta dt { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.user-meta dd { font-size: 13px; color: var(--text); }

.user-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
.field-hint { font-size: 12px; color: var(--text-muted); }
.field-label { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.user-panel .actions { margin-top: var(--space-5); }
.user-panel-note { margin-top: var(--space-4); font-size: 12px; color: var(--text-muted); }

/* Przełącznik — prawdziwy checkbox pod spodem (formularz, klawiatura, czytniki). */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; min-height: var(--tap-target); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
    position: relative; flex-shrink: 0;
    width: 40px; height: 22px; border-radius: var(--radius-pill);
    background: var(--border-strong); transition: background var(--transition);
}
.switch-track::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; border-radius: 50%; background: #fff;
    transition: transform var(--transition);
}
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(0, 96, 160, 0.35); }
.switch input:disabled + .switch-track { opacity: 0.5; }
.switch:has(input:disabled) { cursor: not-allowed; }
.switch-text { font-size: 13px; color: var(--text-dim); }
.switch-on { display: none; }
.switch input:checked ~ .switch-text .switch-on { display: inline; }
.switch input:checked ~ .switch-text .switch-off { display: none; }

/* ---------- Układ kolumn list (panel "Kolumny") ----------
   Same tokeny — ten sam panel w ciemnym i jasnym motywie. */
.layout-pill {
    display: inline-block; margin-left: 6px; padding: 1px 8px;
    border-radius: var(--radius-pill); background: var(--accent-soft-bg); color: var(--accent-soft-text);
    font-size: 11px; font-weight: 500; line-height: 1.5; vertical-align: 1px;
}
.columns-panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 14px; margin-bottom: var(--space-4);
}
.columns-panel[hidden] { display: none; }
.columns-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.columns-heading { font-size: 12px; font-weight: 600; color: var(--text-dim); margin: 0 0 var(--space-2); }
/* Zamknięcie bez zapisu jest potrzebne tylko w pełnoekranowym arkuszu na telefonie. */
.columns-close { display: none; }
.columns-presets { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.preset-btn {
    display: inline-flex; align-items: center; padding: 4px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
    background: transparent; color: var(--text-dim); font: inherit; font-size: 12px; cursor: pointer;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
button.preset-btn:hover { border-color: var(--accent); color: var(--accent-soft-text); }
.preset-btn[aria-pressed="true"],
.preset-custom.is-pressed { background: var(--accent-soft-bg); border-color: var(--accent); color: var(--accent-soft-text); }
/* "Własny" to stan, nie przycisk — przerywana ramka, gdy nieaktywny. */
.preset-custom { cursor: default; border-style: dashed; color: var(--text-muted); }
.preset-custom.is-pressed { border-style: solid; }
.columns-list {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px;
}
.columns-item {
    display: flex; align-items: center; gap: var(--space-2); min-width: 0;
    padding: 4px 6px 4px 8px; font-size: 13px;
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius);
}
.columns-item.is-off { border-style: dashed; }
.columns-item.is-off .columns-label { color: var(--text-muted); }
.columns-item.is-dragging { opacity: 0.45; }
.columns-item.is-drag-over { outline: 2px solid var(--accent); outline-offset: -1px; }
.drag-handle { color: var(--text-muted); cursor: grab; user-select: none; line-height: 1; }
.columns-item.is-locked .drag-handle { visibility: hidden; }
.columns-check { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; cursor: pointer; }
.columns-item.is-locked .columns-check { cursor: default; }
/* Ogólne input { width: 100% } rozpychało checkbox na cały wiersz. */
.columns-check input { width: 16px; height: 16px; flex-shrink: 0; margin: 0; padding: 0; accent-color: var(--accent); }
.columns-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.columns-move { display: flex; gap: 2px; flex-shrink: 0; }
.columns-move-btn,
.columns-close {
    align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-dim); font: inherit; line-height: 1; cursor: pointer;
}
.columns-move-btn { display: inline-flex; }
.columns-move-btn:hover:not([aria-disabled="true"]),
.columns-close:hover { border-color: var(--accent); color: var(--accent-soft-text); }
.columns-move-btn[aria-disabled="true"] { opacity: 0.35; cursor: default; }
.columns-footer {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
    margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border);
}
.columns-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-left: auto; }
.columns-error { flex-basis: 100%; margin: 0; }
.columns-error[hidden] { display: none; }
.columns-actions [aria-busy="true"] { cursor: progress; opacity: 0.7; }
/* Układy udostępniane i zmienione wbudowane: nazwa, obok przyciski administratora.
   Otwarty formularz (is-editing) zajmuje cały wiersz pod przyciskiem układu. */
.preset-shared { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.preset-shared.is-editing { flex-basis: 100%; }
.preset-manage-btn {
    padding: 2px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted); font: inherit; font-size: 11px; cursor: pointer;
}
.preset-manage-btn:hover,
.preset-manage-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent-soft-text); }
.preset-manage-btn.is-danger:hover,
.preset-manage-btn.is-danger[aria-expanded="true"] { border-color: var(--danger); color: var(--danger-soft-text); }
.preset-share { margin: calc(-1 * var(--space-2)) 0 var(--space-4); }
.preset-share-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.preset-share > .preset-inline-error { margin-top: var(--space-2); }
.preset-inline {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
    flex-basis: 100%; padding: var(--space-2) var(--space-3);
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 13px;
}
.preset-inline[hidden] { display: none; }
.preset-inline-label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.preset-inline input[name="name"] { flex: 1 1 200px; width: auto; max-width: 320px; }
.preset-inline-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.preset-inline-text { flex: 1 1 260px; margin: 0; color: var(--text); }
.preset-inline-error { flex-basis: 100%; margin: 0; }
.preset-inline-error[hidden] { display: none; }
.preset-inline [aria-busy="true"] { cursor: progress; opacity: 0.7; }
/* Ostrzeżenie o kolumnach z przychodem — znacznik i kolor, nie sam odcień. */
.preset-share-done { border-color: var(--warning); }
.preset-warning { color: var(--amber-text); }
.preset-warning::before { content: '⚠ '; }
/* Przeciąganie nagłówków: tylko mysz (table_layout.js ustawia draggable). */
@media (pointer: fine) {
    .table-cards th[draggable="true"] { cursor: grab; }
}
.table-cards th.is-dragging { opacity: 0.45; }
.table-cards th.is-drop-target { box-shadow: inset 0 -2px 0 var(--accent); background: var(--accent-soft-bg); color: var(--accent-soft-text); }
