:root {
  --bg: #f4f7fa;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #65727f;
  --border: #d9e1e8;
  --primary: #1f5f8b;
  --primary-dark: #164766;
  --danger: #a62b2b;
  --danger-bg: #fff0f0;
  --new-bg: #d9eaf7;
  --new-text: #1f4e78;
  --deposit-bg: #fce4d6;
  --deposit-text: #a9480d;
  --done-bg: #e2f0d9;
  --done-text: #44712c;
  --z-content: 1;
  --z-dropdown: 40;
  --z-tooltip: 120;
  --z-header: 200;
  --z-mobile-backdrop: 700;
  --z-mobile-nav: 710;
  --z-modal: 900;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
.container { width: min(1220px, calc(100% - 32px)); margin: 0 auto; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: var(--z-header); }
.nav-wrap { min-height: 68px; display: flex; align-items: center; justify-content: flex-start; gap: 24px; }
.brand { font-size: 20px; font-weight: 800; color: var(--text); }
nav { display: flex; align-items: center; gap: 18px; }
.nav-left { justify-content: flex-start; }
.nav-create { margin-left: auto; white-space: nowrap; }
main { padding: 32px 0 12px; }
.footer { padding: 28px 0 38px; color: var(--muted); font-size: 13px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.03em; }
.page-heading p { margin: 6px 0 0; color: var(--muted); }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.eyebrow { text-transform: uppercase; letter-spacing: .15em; font-size: 12px; font-weight: 800; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 5px 18px rgba(31, 52, 70, .05); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.button:hover { border-color: #aab8c4; }
.button-primary { background: var(--primary); border-color: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button-quiet { color: var(--muted); }
.filters { padding: 14px; display: grid; grid-template-columns: minmax(220px, 1fr) 210px auto auto auto; gap: 10px; margin-bottom: 16px; }
input, textarea, select { width: 100%; border: 1px solid #bec9d3; border-radius: 8px; padding: 10px 11px; background: white; color: var(--text); font: inherit; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(31, 95, 139, .16); border-color: var(--primary); }
input:disabled { background: #edf1f4; color: #8a949d; }
.table-wrap { overflow: visible; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 15px; border-bottom: 1px solid #e7edf2; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; background: #fbfcfd; }
tbody tr:hover { background: #f8fbfd; }
tbody tr:last-child td { border-bottom: 0; }
@media (min-width: 1101px) {
  /* Border-collapse: collapse nie renderuje radiusów komórek niezawodnie.
     Osobny model borderów pozwala zaokrąglić nagłówek bez klipowania dropdownów. */
  .table-wrap.card > .contracts-table { border-collapse: separate; border-spacing: 0; }
  .table-wrap.card > .contracts-table thead tr:first-child > th:first-child { border-top-left-radius: 13px; }
  .table-wrap.card > .contracts-table thead tr:first-child > th:last-child { border-top-right-radius: 13px; }
  .table-wrap.card:not(:has(> .pagination-bar)) > .contracts-table tbody tr:last-child > td:first-child { border-bottom-left-radius: 13px; }
  .table-wrap.card:not(:has(> .pagination-bar)) > .contracts-table tbody tr:last-child > td:last-child { border-bottom-right-radius: 13px; }
  .table-wrap.card > .contracts-table tbody tr:hover { background: transparent; }
  .table-wrap.card > .contracts-table tbody tr:hover > td { background: #f8fbfd; }
  .table-wrap.card > .pagination-bar:last-child { border-radius: 0 0 13px 13px; }
  .table-wrap.card > .rounded-card-table { border-collapse: separate; border-spacing: 0; }
  .table-wrap.card > .rounded-card-table thead tr:first-child > th:first-child { border-top-left-radius: 13px; }
  .table-wrap.card > .rounded-card-table thead tr:first-child > th:last-child { border-top-right-radius: 13px; }
}
.number-link { font-weight: 800; white-space: nowrap; }
.amount { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 36px; }
.status { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.status-new { background-color: var(--new-bg); color: var(--new-text); }
.status-deposit { background-color: var(--deposit-bg); color: var(--deposit-text); }
.status-done { background-color: var(--done-bg); color: var(--done-text); }
.status-large { padding: 9px 15px; font-size: 16px; }
.inline-status-form { margin: 0; min-width: 158px; }
.status-select { appearance: auto; border: 0; border-radius: 5px; padding: 6px 28px 6px 11px; font-size: 13px; font-weight: 800; cursor: pointer; outline-offset: 2px; }
.status-select.status-new { background-color: var(--new-bg); color: var(--new-text); }
.status-select.status-deposit { background-color: var(--deposit-bg); color: var(--deposit-text); }
.status-select.status-done { background-color: var(--done-bg); color: var(--done-text); }
.actions-cell { width: 52px; text-align: right; position: relative; }
.action-menu { position: relative; display: inline-block; }
.action-menu summary { list-style: none; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-size: 24px; line-height: 1; color: var(--muted); }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary:hover, .action-menu[open] summary { background: #eef3f7; border-color: var(--border); color: var(--text); }
.action-menu-panel { position: absolute; z-index: 30; right: 0; top: 42px; min-width: 190px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 11px; box-shadow: 0 14px 36px rgba(31, 52, 70, .18); text-align: left; }
.action-menu-panel a, .action-menu-panel button { width: 100%; display: block; padding: 10px 11px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.action-menu-panel a:hover, .action-menu-panel button:hover { background: #eef3f7; }
.action-menu-panel form { margin: 0; }
.action-menu-panel .menu-danger { color: var(--danger); }
.action-menu-panel .menu-danger:hover { background: var(--danger-bg); }
.form-grid { padding: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid label, .status-panel label, .stats-filters label { display: grid; gap: 7px; font-weight: 700; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; padding-top: 6px; }
.locked-fields { margin-bottom: 16px; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.locked-fields > div { background: #eef3f7; border-radius: 10px; padding: 12px 14px; display: grid; gap: 3px; }
.locked-fields span { color: var(--muted); font-size: 12px; }
.form-status-note { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 12px 14px; border: 1px solid var(--border); background: #fbfcfd; border-radius: 10px; }
.form-status-note > span { font-weight: 700; }
.form-status-note small { color: var(--muted); flex-basis: 100%; }
.completion-field { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(240px, 1fr); gap: 16px; align-items: end; }
.realization-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, .55fr); gap: 16px; align-items: end; }
.checkbox-label { min-height: 43px; display: flex !important; grid-template-columns: auto 1fr !important; flex-direction: row; align-items: center; justify-content: flex-start; gap: 9px !important; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: #fbfcfd; cursor: pointer; }
.checkbox-label input { width: 18px; height: 18px; margin: 0; }
.errors, .notice { border-radius: 10px; padding: 13px 16px; margin-bottom: 16px; }
.errors { background: #fff0f0; border: 1px solid #efb4b4; color: #8e2424; }
.errors ul { margin: 7px 0 0 20px; }
.notice { background: #edf7ed; border: 1px solid #b8dbb8; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .75fr); gap: 18px; align-items: start; }
.detail-grid .card { padding: 22px; }
h2 { margin-top: 0; }
dl { display: grid; grid-template-columns: 180px 1fr; margin: 0; }
dt, dd { padding: 11px 0; border-bottom: 1px solid #e8edf1; }
dt { color: var(--muted); font-weight: 700; }
dd { margin: 0; }
.status-panel { position: sticky; top: 88px; }
.status-panel form { display: grid; gap: 12px; margin-top: 22px; }
.status-panel hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
code { overflow-wrap: anywhere; }

.stats-filters { padding: 16px; display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)) auto; gap: 12px; align-items: end; }
.stats-period { margin: 18px 0 10px; display: flex; align-items: baseline; gap: 9px; color: var(--muted); }
.stats-period strong { color: var(--text); font-size: 20px; text-transform: capitalize; }
.stats-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { padding: 20px; display: grid; gap: 10px; }
.stat-card span { color: var(--muted); font-weight: 700; }
.stat-card strong { font-size: clamp(25px, 3vw, 34px); letter-spacing: -.03em; }
.stats-section { margin-bottom: 18px; overflow: visible; }
.section-heading { min-height: 62px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading span { color: var(--muted); }
.bar-cell { width: 22%; min-width: 130px; }
.bar-cell span { display: block; height: 8px; border-radius: 999px; background: var(--primary); opacity: .75; }

@media (max-width: 980px) {
  .stats-filters { grid-template-columns: repeat(3, 1fr); }
  .stats-filters .button { align-self: stretch; }
}
@media (max-width: 820px) {
  .table-wrap { overflow-x: auto; }
  nav { gap: 10px; }
  nav > a:first-child { display: none; }
  .page-heading { flex-direction: column; }
  .heading-actions { justify-content: flex-start; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .completion-field { grid-template-columns: 1fr; }
  .locked-fields, .detail-grid { grid-template-columns: 1fr; }
  .status-panel { position: static; }
  dl { grid-template-columns: 1fr; }
  dt { padding-bottom: 2px; border-bottom: 0; }
  dd { padding-top: 2px; }
  .stats-cards { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .container { width: min(100% - 20px, 1220px); }
  .nav-wrap { min-height: 60px; }
  .brand { font-size: 17px; }
  nav a:not(.button) { display: none; }
  main { padding-top: 22px; }
  .filters, .stats-filters { grid-template-columns: 1fr; }
  .filters input { grid-column: auto; }
  .form-grid { padding: 16px; }
  th, td { padding: 12px 11px; }
}

/* Wersja 3: płatności, załączniki, notyfikacje i ostrzeżenie przed utratą zmian. */
:root {
  --paid-bg: #e8e0f6;
  --paid-text: #5d3f8c;
}
.status-paid { background-color: var(--paid-bg); color: var(--paid-text); }
.status-select.status-paid { background-color: var(--paid-bg); color: var(--paid-text); }
.payment-field { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(340px, 1fr); gap: 16px; align-items: end; }
.attachment-upload small { color: var(--muted); font-weight: 400; line-height: 1.45; }
.attachment-upload input[type="file"] { padding: 9px; }
.existing-attachments { border: 1px solid var(--border); background: #fbfcfd; border-radius: 10px; padding: 14px 16px; }
.existing-attachments ul, .attachment-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.existing-attachments li, .attachment-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border: 1px solid #e4eaf0; border-radius: 9px; background: #fff; }
.existing-attachments li span, .attachment-list li span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.detail-main { display: grid; gap: 18px; min-width: 0; }
.attachments-card { padding: 0 !important; overflow: hidden; }
.attachment-list { padding: 4px 18px 18px; margin: 0; }
.empty-attachments { margin: 0; padding: 20px; color: var(--muted); }
.attachment-preview { padding: 14px; min-height: 70vh; }
.attachment-object { width: 100%; height: 75vh; border: 0; border-radius: 8px; background: #eef2f5; }
.attachment-object-small { min-height: 55vh; }
.attachment-image { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto; object-fit: contain; }
.attachment-text { min-height: 65vh; margin: 0; padding: 18px; overflow: auto; white-space: pre-wrap; border-radius: 8px; background: #f7f9fb; font: 14px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
.attachment-generic { padding: 18px; text-align: center; }
.notice { transition: opacity .3s ease, transform .3s ease; }
.notice-hide { opacity: 0; transform: translateY(-6px); }
.modal-backdrop[hidden] { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: 20px; background: rgba(17, 29, 39, .55); }
.modal-card { width: min(480px, 100%); padding: 24px; border-radius: 14px; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .3); }
.modal-card h2 { margin: 0 0 10px; }
.modal-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.action-confirm-card { width: min(480px, 100%); }
.action-confirm-card .modal-actions .button { min-width: 98px; }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-danger:hover { background: #812020; border-color: #812020; }

@media (max-width: 820px) {
  .payment-field { grid-template-columns: 1fr; }
  .existing-attachments li, .attachment-list li { align-items: flex-start; flex-direction: column; gap: 4px; }
}
.inline-status-form { min-width: 195px; }

/* Wersja 4: kompaktowa tabela, kumulowanie załączników i akcje podglądu. */
.contracts-table { table-layout: auto; }
.contracts-table .col-number,
.contracts-table .col-date,
.contracts-table .col-amount,
.contracts-table .col-status,
.contracts-table .col-actions { width: 1%; }
.contracts-table .col-subject { width: 100%; }
.contracts-table .cell-number,
.contracts-table .cell-date,
.contracts-table .cell-amount,
.contracts-table .cell-status,
.contracts-table .actions-cell { white-space: nowrap; }
.contracts-table .cell-client { min-width: 170px; max-width: 220px; overflow-wrap: anywhere; }
.contracts-table .cell-subject { min-width: 280px; overflow-wrap: anywhere; }
.inline-status-form { min-width: 0; width: max-content; }
.status-select { width: auto; }
.status-back-button { width: 100%; margin-top: 12px; }

/* Pośredni desktop: klasyczna tabela ma się zmieścić bez poziomego scrolla.
   Kolumny z treścią użytkownika mogą się zawijać, a kontrolka statusu nie ustala
   już minimalnej szerokości całej tabeli. */
@media (min-width: 1101px) and (max-width: 1280px) {
  .contracts-table:not(.lite-contracts-table) {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
  }
  .contracts-table:not(.lite-contracts-table) th,
  .contracts-table:not(.lite-contracts-table) td {
    min-width: 0;
    padding-left: 10px;
    padding-right: 10px;
  }
  .contracts-table:not(.lite-contracts-table) .col-business { width: 8%; }
  .contracts-table:not(.lite-contracts-table) .col-number { width: 14%; }
  .contracts-table:not(.lite-contracts-table) .col-date { width: 10%; }
  .contracts-table:not(.lite-contracts-table) .col-client { width: 15%; }
  .contracts-table:not(.lite-contracts-table) .col-subject { width: 20%; }
  .contracts-table:not(.lite-contracts-table) .col-amount { width: 13%; }
  .contracts-table:not(.lite-contracts-table) .col-status { width: 15%; }
  .contracts-table:not(.lite-contracts-table) .col-actions { width: 5%; }
  .contracts-table:not(.lite-contracts-table) .cell-client,
  .contracts-table:not(.lite-contracts-table) .cell-subject {
    min-width: 0;
    max-width: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .contracts-table:not(.lite-contracts-table) .cell-status .inline-status-form,
  .contracts-table:not(.lite-contracts-table) .cell-status .status-select {
    width: 100%;
    max-width: 100%;
  }
  .contracts-table:not(.lite-contracts-table) .cell-status .status-select {
    padding-left: 9px;
    padding-right: 24px;
  }

  .contracts-table-no-status .col-business { width: 8%; }
  .contracts-table-no-status .col-number { width: 14%; }
  .contracts-table-no-status .col-date { width: 10%; }
  .contracts-table-no-status .col-client { width: 17%; }
  .contracts-table-no-status .col-subject { width: 32%; }
  .contracts-table-no-status .col-amount { width: 14%; }
  .contracts-table-no-status .col-actions { width: 5%; }
}
.pending-attachments { border: 1px dashed var(--border); background: #fbfcfd; border-radius: 10px; padding: 14px 16px; }
.pending-file-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.pending-file-list[hidden] { display: none; }
.pending-file-list li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid #e4eaf0; border-radius: 9px; background: #fff; }
.pending-file-list li > div { min-width: 0; display: grid; gap: 2px; }
.pending-file-list strong { overflow-wrap: anywhere; }
.pending-file-list span { color: var(--muted); font-size: 13px; }
.pending-file-remove { border: 0; background: transparent; color: var(--danger); font: inherit; font-weight: 700; cursor: pointer; padding: 6px 8px; border-radius: 7px; }
.pending-file-remove:hover { background: var(--danger-bg); }

@media (max-width: 820px) {
  .contracts-table { min-width: 980px; }
}

/* Wersja 5: wybór firmy i dwa niezależne szablony umowy. */
.contracts-table .col-business { width: 1%; }
.contracts-table .cell-business { white-space: nowrap; text-align: center; }
.business-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  white-space: nowrap;
}
.business-zs { background: #dcecf8; color: #174f78; }
.business-gw { background: #eee3f7; color: #613d86; }
.business-unassigned { background: #edf0f2; color: #7b8791; }
.business-selector {
  padding: 15px 16px;
  border: 1px solid #b7c9d8;
  border-radius: 11px;
  background: #f4f9fc;
}
.business-selector select { font-weight: 800; }
.business-selector small { color: var(--muted); font-weight: 400; }
.business-detail-label { margin-left: 8px; }

@media (max-width: 820px) {
  .contracts-table { min-width: 1040px; }
}

/* Wersja 6: zakładki firmowe na liście i filtr firmy w statystykach. */
.business-tabs {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
  margin: 0 0 12px;
  overflow-x: auto;
  max-width: 100%;
  box-shadow: none;
}
.business-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 8px 15px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}
.business-tab:hover { background: #eef3f7; color: var(--text); }
.business-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 8px rgba(31, 95, 139, .2);
}
.stats-filters { grid-template-columns: repeat(6, minmax(120px, 1fr)) auto; }
.stats-business-context { color: var(--muted); font-weight: 700; }

@media (max-width: 620px) {
  .business-tabs { display: flex; width: 100%; }
  .business-tab { flex: 1 0 auto; }
}


/* Wersja 7: sortowanie, paginacja, lokalizacje ZS/FG/FGW i przebudowany nagłówek. */
.business-fg { background: #e4effa; color: #24567f; }
.business-fgw { background: #e2f1e8; color: #286744; }
.business-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.business-tabs-row .business-tabs { margin: 0; }
.business-tabs-row .backup { flex: 0 0 auto; }
.filters { grid-template-columns: minmax(260px, 1fr) 220px auto auto; }
.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  white-space: nowrap;
}
.sort-link:hover { color: var(--primary); }
.sort-link span { min-width: 10px; font-size: 13px; }
.sort-link.active { color: var(--primary); }
.pagination-bar {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
}
.pagination-summary { color: var(--muted); font-size: 13px; }
.pagination-controls { display: flex; align-items: center; justify-content: center; gap: 8px; }
.page-links { display: flex; align-items: center; gap: 4px; }
.page-link, .page-button {
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.page-link:hover, .page-button:hover { border-color: #aab8c4; background: #f3f7fa; }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-button.disabled { color: #a0aab3; background: #f0f3f5; cursor: default; }
.page-ellipsis { padding: 0 3px; color: var(--muted); }
.page-size-form { justify-self: end; }
.page-size-form label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.page-size-form select { width: auto; min-width: 78px; padding: 7px 28px 7px 9px; }

@media (max-width: 980px) {
  .nav-wrap { gap: 14px; }
  .brand { font-size: 18px; }
  .nav-left { gap: 12px; }
  .pagination-bar { grid-template-columns: 1fr; justify-items: center; }
  .pagination-summary, .page-size-form { justify-self: center; }
}
@media (max-width: 820px) {
  .nav-left { display: none; }
  .business-tabs-row { align-items: stretch; flex-direction: column; }
  .business-tabs-row .backup { align-self: flex-end; }
}
@media (max-width: 620px) {
  .brand { font-size: 15px; }
  .nav-create { padding-inline: 10px; }
  .pagination-controls { flex-wrap: wrap; }
  .page-button { font-size: 0; min-width: 36px; }
  .page-button::first-letter { font-size: 13px; }
}

/* Wersja 8: kolory oddziałów, ikony akcji i pełna responsywność tablet/mobile. */
.business-zs {
  background: #fde6e6;
  color: #9f1d1d;
  border: 1px solid #f2bcbc;
}
.business-fg {
  background: #eee7fa;
  color: #653a91;
  border: 1px solid #d7c4ed;
}
.business-fgw {
  background: #f1e6dc;
  color: #754626;
  border: 1px solid #ddc2aa;
}

.business-tab-all { color: var(--primary); }
.business-tab-all:hover { background: #e8f1f7; color: var(--primary-dark); }
.business-tab-all.active { background: var(--primary); color: #fff; box-shadow: 0 3px 8px rgba(31, 95, 139, .2); }
.business-tab-zs { background: #fff5f5; color: #9f1d1d; }
.business-tab-zs:hover { background: #fde6e6; color: #861717; }
.business-tab-zs.active { background: #b42323; color: #fff; box-shadow: 0 3px 8px rgba(180, 35, 35, .22); }
.business-tab-fg { background: #f8f4fd; color: #653a91; }
.business-tab-fg:hover { background: #eee7fa; color: #542c7c; }
.business-tab-fg.active { background: #7040a0; color: #fff; box-shadow: 0 3px 8px rgba(112, 64, 160, .22); }
.business-tab-fgw { background: #fbf6f1; color: #754626; }
.business-tab-fgw:hover { background: #f1e6dc; color: #61391f; }
.business-tab-fgw.active { background: #815134; color: #fff; box-shadow: 0 3px 8px rgba(129, 81, 52, .22); }

.action-menu-panel a,
.action-menu-panel button {
  display: flex;
  align-items: center;
  gap: 10px;
}
.menu-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
}
.menu-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 1100px) {
  /* Nagłówek i główne grupy sterujące */
  .container { width: min(100% - 24px, 1220px); }
  .nav-wrap {
    min-height: auto;
    padding: 10px 0;
    flex-wrap: wrap;
    column-gap: 14px;
    row-gap: 9px;
  }
  .brand { flex: 1 1 auto; min-width: 0; }
  .nav-create { margin-left: 0; }
  .nav-left {
    order: 3;
    display: flex !important;
    width: 100%;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .nav-left a:not(.button) {
    display: inline-flex !important;
    min-height: 40px;
    align-items: center;
    padding: 7px 10px;
    border-radius: 8px;
  }
  .nav-left a:hover { background: #eef3f7; }

  .page-heading { flex-wrap: wrap; }
  .heading-actions { max-width: 100%; }
  .business-tabs-row {
    align-items: stretch;
    flex-direction: column;
  }
  .business-tabs {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    overflow: visible;
  }
  .business-tab { flex: 1 1 auto; }
  .business-tabs-row .backup { align-self: flex-end; }

  .filters { grid-template-columns: minmax(0, 1fr) minmax(190px, .55fr); }
  .filters input[type="search"] { grid-column: 1 / -1; }
  .filters .button { min-width: 0; }
  .stats-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-filters .button { width: 100%; }
  .stats-period { flex-wrap: wrap; }

  .payment-field,
  .completion-field { grid-template-columns: 1fr; }
  input, textarea, select, button { min-width: 0; }
  .form-actions, .heading-actions, .modal-actions { flex-wrap: wrap; }

  /* Tabela główna jako karty na tabletach i telefonach. */
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .contracts-table,
  .contracts-table tbody {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }
  .contracts-table colgroup,
  .contracts-table thead { display: none; }
  .contracts-table tbody {
    display: grid;
    gap: 12px;
  }
  .contracts-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--card);
    box-shadow: 0 4px 14px rgba(31, 52, 70, .05);
  }
  .contracts-table tbody tr:hover { background: var(--card); }
  .contracts-table td {
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
    display: grid;
    grid-template-columns: minmax(86px, .42fr) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 11px 13px;
    border-bottom: 1px solid #e7edf2;
    white-space: normal !important;
    text-align: left;
  }
  .contracts-table td::before,
  .mobile-card-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
  }
  .contracts-table .cell-client,
  .contracts-table .cell-subject { grid-column: 1 / -1; }
  .contracts-table .cell-subject { overflow-wrap: anywhere; }
  .contracts-table .cell-status,
  .contracts-table .actions-cell { border-bottom: 0; }
  .contracts-table .inline-status-form,
  .contracts-table .status-select { width: 100%; }
  .contracts-table .actions-cell .action-menu { justify-self: end; }
  .contracts-table .empty {
    grid-column: 1 / -1;
    display: block;
    text-align: center;
    border: 0;
  }
  .contracts-table .empty::before { display: none; }
  .action-menu-panel { min-width: 205px; }

  .pagination-bar {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--card);
  }

  /* Tabele statystyk również przechodzą w układ kart. */
  .mobile-card-table,
  .mobile-card-table tbody {
    display: block;
    width: 100%;
  }
  .mobile-card-table thead { display: none; }
  .mobile-card-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }
  .mobile-card-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fff;
  }
  .mobile-card-table td {
    display: grid;
    grid-template-columns: minmax(86px, .45fr) minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    min-width: 0;
    padding: 10px 12px;
    border-bottom: 1px solid #e7edf2;
    white-space: normal;
  }
  .mobile-card-table .amount { white-space: normal; }
  .mobile-card-table .bar-cell { width: auto; min-width: 0; }
  .mobile-card-table .empty {
    grid-column: 1 / -1;
    display: block;
    border: 0;
  }
  .mobile-card-table .empty::before { display: none; }
  .stats-contracts-table td:nth-last-child(-n+1),
  .stats-breakdown-table td:nth-last-child(-n+1) { border-bottom: 0; }

  .detail-grid { grid-template-columns: 1fr; }
  .status-panel { position: static; }
  .attachment-object { height: 65vh; }
}

@media (max-width: 760px) {
  main { padding-top: 22px; }
  .page-heading { flex-direction: column; align-items: stretch; }
  .page-heading > .button,
  .page-heading .heading-actions { width: 100%; }
  .page-heading .heading-actions .button { flex: 1 1 180px; }

  .filters,
  .stats-filters,
  .form-grid,
  .locked-fields { grid-template-columns: 1fr; }
  .filters input[type="search"] { grid-column: auto; }
  .span-2 { grid-column: auto; }
  .form-grid { padding: 17px; gap: 15px; }
  .form-actions .button { flex: 1 1 180px; }
  .checkbox-label { align-items: flex-start; }

  .stats-cards { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  dl { grid-template-columns: 1fr; }
  dt { padding-bottom: 2px; border-bottom: 0; }
  dd { padding-top: 2px; }

  .existing-attachments li,
  .attachment-list li,
  .pending-file-list li {
    align-items: flex-start;
    flex-direction: column;
  }
  .attachment-list li a,
  .existing-attachments li a { overflow-wrap: anywhere; }
  .attachment-preview { padding: 8px; min-height: 55vh; }
  .attachment-object { height: 58vh; }

  .pagination-controls { width: 100%; flex-wrap: wrap; }
  .page-links { max-width: 100%; flex-wrap: wrap; justify-content: center; }
  .page-button { font-size: 13px; }
  .page-button::first-letter { font-size: inherit; }
}

@media (max-width: 560px) {
  .container { width: min(100% - 18px, 1220px); }
  .nav-wrap { padding: 9px 0; }
  .brand { flex: 1 0 100%; font-size: 16px; }
  .nav-create { order: 2; width: 100%; }
  .nav-left { justify-content: stretch; }
  .nav-left a { flex: 1 1 0; justify-content: center; text-align: center; }

  .business-tabs-row .backup { width: 100%; align-self: stretch; }
  .business-tab { flex: 1 1 calc(50% - 5px); padding-inline: 9px; }
  .business-tab-all { flex-basis: 100%; }

  .filters .button,
  .stats-filters .button,
  .form-actions .button,
  .modal-actions .button { width: 100%; flex-basis: 100%; }

  .contracts-table tr,
  .mobile-card-table tr { grid-template-columns: 1fr; }
  .contracts-table .cell-client,
  .contracts-table .cell-subject { grid-column: auto; }
  .contracts-table td,
  .mobile-card-table td {
    grid-template-columns: minmax(82px, .4fr) minmax(0, 1fr);
  }
  .contracts-table .cell-status { border-bottom: 1px solid #e7edf2; }
  .contracts-table .actions-cell { border-bottom: 0; }
  .contracts-table .actions-cell .action-menu { justify-self: end; }

  .pagination-bar { padding: 12px; }
  .pagination-summary { text-align: center; }
  .page-size-form,
  .page-size-form label { width: 100%; justify-content: center; }

  .modal-card { padding: 19px; }
}

/* Nadpisanie starszych reguł ukrywających pierwszy link nawigacji na małych ekranach. */
@media (max-width: 1100px) {
  .business-tabs > a,
  .business-tabs > a:first-child,
  .business-tabs a:not(.button) { display: inline-flex !important; }
}

/* Wersja 9: poprawki tabletowe, mobilne kafelki oddziałów i spokojniejsze zakładki. */

/* Wszystkie nieaktywne zakładki mają jeden neutralny wygląd. */
.business-tab,
.business-tab-all,
.business-tab-zs,
.business-tab-fg,
.business-tab-fgw {
  background: #ffffff;
  color: var(--muted);
  border: 1px solid transparent;
  box-shadow: none;
}
.business-tab:hover,
.business-tab-all:hover,
.business-tab-zs:hover,
.business-tab-fg:hover,
.business-tab-fgw:hover {
  background: #eef3f7;
  color: var(--text);
}

/* Aktywny kafelek dopiero otrzymuje kolor oddziału — rozjaśniony o ok. 25%. */
.business-tab-all.active {
  background: #1f5f8b;
  color: #fff;
  border-color: #1f5f8b;
  box-shadow: 0 3px 8px rgba(31, 95, 139, .18);
}
.business-tab-zs.active {
  background: #c75a5a;
  color: #fff;
  border-color: #c75a5a;
  box-shadow: 0 3px 8px rgba(180, 35, 35, .18);
}
.business-tab-fg.active {
  background: #9470b8;
  color: #fff;
  border-color: #9470b8;
  box-shadow: 0 3px 8px rgba(112, 64, 160, .18);
}
.business-tab-fgw.active {
  background: #a17d67;
  color: #fff;
  border-color: #a17d67;
  box-shadow: 0 3px 8px rgba(129, 81, 52, .18);
}

/* Tablet: uporządkowany, semantyczny układ karty zamiast przypadkowego przepływu komórek. */
@media (min-width: 561px) and (max-width: 1100px) {
  .filters {
    grid-template-columns: minmax(0, 1fr) minmax(120px, .42fr) minmax(120px, .42fr);
  }
  .filters input[type="search"] { grid-column: 1 / -1; }

  .contracts-table tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "business number"
      "date amount"
      "client client"
      "subject subject"
      "status actions";
  }
  .contracts-table .cell-business { grid-area: business; }
  .contracts-table .cell-number { grid-area: number; }
  .contracts-table .cell-date { grid-area: date; }
  .contracts-table .cell-client { grid-area: client; grid-column: auto; }
  .contracts-table .cell-subject { grid-area: subject; grid-column: auto; }
  .contracts-table .cell-amount { grid-area: amount; }
  .contracts-table .cell-status { grid-area: status; border-bottom: 0; }
  .contracts-table .actions-cell { grid-area: actions; border-bottom: 0; }
  .contracts-table .actions-cell .action-menu { justify-self: end; }
}

/* Telefon: zakładki oddziałów zawsze jedna pod drugą, po 100% szerokości. */
@media (max-width: 560px) {
  .nav-create { display: none; }

  .business-tabs {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }
  .business-tab,
  .business-tab-all {
    width: 100%;
    flex: 0 0 auto;
  }

  .contracts-table tr {
    grid-template-columns: 1fr;
    grid-template-areas:
      "business"
      "number"
      "date"
      "client"
      "subject"
      "amount"
      "status"
      "actions";
  }
  .contracts-table .cell-business { grid-area: business; }
  .contracts-table .cell-number { grid-area: number; }
  .contracts-table .cell-date { grid-area: date; }
  .contracts-table .cell-client { grid-area: client; }
  .contracts-table .cell-subject { grid-area: subject; }
  .contracts-table .cell-amount { grid-area: amount; }
  .contracts-table .cell-status { grid-area: status; }
  .contracts-table .actions-cell { grid-area: actions; }
}

@media (min-width: 561px) and (max-width: 700px) {
  .business-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .business-tab { width: 100%; }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .business-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .business-tab { width: 100%; }
}

/* Wersja 10: dopracowanie kart tabletowych i mobilnego nagłówka. */

/* Kopia bazy jest operacją administracyjną — pozostaje widoczna tylko na desktopie. */
@media (max-width: 1100px) {
  .business-tabs-row .backup {
    display: none !important;
  }
}

/* Tablet: pola Klient i Przedmiot zawsze zajmują pełną szerokość karty. */
@media (min-width: 561px) and (max-width: 1100px) {
  .contracts-table .cell-business {
    grid-column: 1;
    grid-row: 1;
  }
  .contracts-table .cell-number {
    grid-column: 2;
    grid-row: 1;
  }
  .contracts-table .cell-date {
    grid-column: 1;
    grid-row: 2;
  }
  .contracts-table .cell-amount {
    grid-column: 2;
    grid-row: 2;
  }
  .contracts-table .cell-client {
    grid-column: 1 / -1 !important;
    grid-row: 3;
    width: 100% !important;
    justify-self: stretch;
    grid-template-columns: minmax(86px, 100px) minmax(0, 1fr);
  }
  .contracts-table .cell-subject {
    grid-column: 1 / -1 !important;
    grid-row: 4;
    width: 100% !important;
    justify-self: stretch;
    grid-template-columns: minmax(86px, 100px) minmax(0, 1fr);
  }
  .contracts-table .cell-status {
    grid-column: 1;
    grid-row: 5;
  }
  .contracts-table .actions-cell {
    grid-column: 2;
    grid-row: 5;
  }
}

/* Telefon: tytuł jest wyśrodkowany względem całej szerokości nagłówka. */
@media (max-width: 560px) {
  .nav-wrap {
    position: relative;
    justify-content: center;
  }
  .brand {
    flex: 0 0 100%;
    width: 100%;
    margin: 0;
    text-align: center;
  }
}

/* Wersja 11: stabilne karty mobilne, jednorzędowe zakładki i dynamiczne tooltipy desktopowe. */

.tab-label-short { display: none; }

/* Własne tooltipy zastępują natywne atrybuty title w tabeli. */
.tooltip-host {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  cursor: help;
}
.tooltip-host:focus-visible {
  outline: 2px solid rgba(31, 95, 139, .45);
  outline-offset: 3px;
  border-radius: 6px;
}
.tooltip-subject,
.tooltip-subject .subject-value { width: 100%; }
.dynamic-tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  left: -10000px;
  top: -10000px;
  width: max-content;
  max-width: min(390px, calc(100vw - 24px));
  display: grid;
  gap: 6px;
  padding: 11px 13px;
  border: 1px solid #cfd9e2;
  border-radius: 10px;
  background: #17222c;
  color: #fff;
  box-shadow: 0 14px 34px rgba(17, 29, 39, .28);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
  pointer-events: none;
}
.dynamic-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dynamic-tooltip strong {
  color: #fff;
  font-size: 13px;
}
.dynamic-tooltip > span { color: #dbe6ee; }
.dynamic-tooltip .tooltip-description {
  max-height: 240px;
  overflow: auto;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  /* Wszystkie zakładki pozostają w jednym rzędzie; na mniejszych ekranach używają skrótów. */
  .business-tabs {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    flex-direction: initial !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 5px;
    width: 100%;
    overflow: visible;
  }
  .business-tab,
  .business-tab-all {
    width: auto !important;
    min-width: 0;
    min-height: 39px;
    flex: none !important;
    padding-inline: 6px;
  }
  .tab-label-full { display: none; }
  .tab-label-short {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Natywne separatory ostatniego/jedynego rekordu nie są już zerowane przez regułę desktopową. */
  .contracts-table tbody tr:last-child td {
    border-bottom: 1px solid #e7edf2;
  }
  .contracts-table tbody tr:last-child .cell-status,
  .contracts-table tbody tr:last-child .actions-cell {
    border-bottom: 0;
  }

  /* Tooltipy są przeznaczone tylko dla precyzyjnego wskaźnika myszy na desktopie. */
  .tooltip-host { cursor: inherit; }
  .tooltip-host:focus-visible { outline: 0; }
  .dynamic-tooltip { display: none !important; }
}

@media (max-width: 560px) {
  /* Na telefonie status nadal oddziela się od ostatniego wiersza akcji. */
  .contracts-table tbody tr:last-child .cell-status {
    border-bottom: 1px solid #e7edf2;
  }
  .contracts-table tbody tr:last-child .actions-cell {
    border-bottom: 0;
  }
}

@media (max-width: 560px) {
  .business-tabs {
    grid-template-columns: minmax(92px, 1.25fr) repeat(3, minmax(0, 1fr)) !important;
  }
  .business-tab { font-size: 13px; }
}


/* Wersja 12: dynamiczny typ klienta, notatki techniczne i stabilniejsze tooltipy. */
.client-type-selector {
  padding: 15px 16px;
  border: 1px solid #c8cfe5;
  border-radius: 11px;
  background: #f8f7fc;
}
.client-type-selector select { font-weight: 800; }
.client-type-selector small { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }
.form-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 4px;
  padding: 18px 0 4px;
  border-top: 1px solid var(--border);
}
.form-section-heading span {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.form-section-heading h2 { margin: 0; font-size: 20px; }
.form-section-heading p { max-width: 520px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; text-align: right; }
.technical-notes-field textarea { background: #fffdf7; border-color: #d8cda9; }
.technical-notes-card { padding: 0 !important; overflow: hidden; }
.technical-notes-content { padding: 18px; background: #fffdf7; line-height: 1.65; overflow-wrap: anywhere; }
.contact-details-card { padding: 0 !important; overflow: hidden; }
.contact-details-list { padding: 0 18px 12px; }
.contact-details-list dd { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.contact-link { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 820px) {
  .form-section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .form-section-heading p { max-width: none; text-align: left; }
  .realization-field { grid-template-columns: 1fr; }
}

/* Wersja 13: wyszukiwanie danych firmy w oficjalnym API CEIDG. */
.ceidg-lookup-field {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px 12px;
  align-items: end;
  padding: 15px 16px;
  border: 1px solid #c7d8e5;
  border-radius: 11px;
  background: #f7fbfe;
}
.ceidg-lookup-field > label { min-width: 0; }
.ceidg-lookup-button { min-width: 205px; white-space: nowrap; }
.ceidg-lookup-button:disabled { cursor: wait; opacity: .72; }
.ceidg-lookup-status {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}
.ceidg-lookup-status.is-loading { background: #eef5fa; color: #315d7b; }
.ceidg-lookup-status.is-success { background: #edf7ed; color: #356b35; }
.ceidg-lookup-status.is-error { background: #fff0f0; color: #8e2424; }

@media (max-width: 820px) {
  .ceidg-lookup-field { grid-template-columns: 1fr; }
  .ceidg-lookup-button { width: 100%; min-width: 0; }
  .ceidg-lookup-status { grid-column: 1; }
}

/* Wersja 14: szerszy desktop i dopracowanie etykiety oddziału na telefonach. */
@media (min-width: 1601px) {
  .container {
    width: min(1440px, calc(100% - 64px));
  }
  .contracts-table .cell-client {
    max-width: none;
    white-space: nowrap;
    overflow-wrap: normal;
  }
}

@media (max-width: 560px) {
  .contracts-table .cell-business,
  .contracts-table .cell-business::before {
    text-align: left;
  }
  .contracts-table .cell-business .business-badge {
    justify-self: start;
  }
}

/* Wersja 15: spójne etykiety tabletowe, większy desktop i ikony przycisków. */
.button { gap: 8px; }
.button-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
}
.button-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Tablet: wszystkie etykiety kart mają identyczną szerokość i wyrównanie do lewej. */
@media (min-width: 561px) and (max-width: 1100px) {
  .contracts-table td {
    grid-template-columns: 100px minmax(0, 1fr);
  }
  .contracts-table td::before {
    width: 100px;
    justify-self: start;
    text-align: left;
  }
  .contracts-table .cell-business,
  .contracts-table .cell-business::before {
    text-align: left;
  }
  .contracts-table .cell-business .tooltip-host,
  .contracts-table .cell-business .business-badge {
    justify-self: start;
  }
}

/* Przycisk w nagłówku jest sterowany przez widok; na telefonie nie jest globalnie ukrywany. */
@media (max-width: 560px) {
  .nav-create {
    display: inline-flex;
  }
}

/* Wersja 16: tekstowy logotyp SOKOŁOWSKI w nagłówku. */
.brand-logo {
  width: min(330px, 31vw);
  min-width: 270px;
  display: inline-grid;
  grid-template-rows: auto auto;
  gap: 2px;
  color: #111;
  line-height: 1;
  text-decoration: none;
}
.brand-logo:hover { color: #111; }
.brand-wordmark {
  display: block;
  padding-left: .19em;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 27px;
  font-weight: 400;
  line-height: .98;
  letter-spacing: .19em;
  text-align: center;
  white-space: nowrap;
}
.brand-tagline {
  display: grid;
  grid-template-columns: minmax(28px, 1fr) auto minmax(28px, 1fr);
  align-items: center;
  gap: 11px;
  width: 100%;
}
.brand-tagline-text {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .28em;
  text-align: center;
  white-space: nowrap;
}
.brand-line {
  display: block;
  height: 1px;
  background: currentColor;
}

@media (max-width: 1100px) {
  .brand-logo {
    width: min(315px, 48vw);
    min-width: 250px;
  }
  .brand-wordmark { font-size: 24px; }
  .brand-tagline-text { font-size: 8px; letter-spacing: .24em; }
  .brand-tagline { gap: 9px; }
}

@media (max-width: 560px) {
  .brand-logo {
    width: min(300px, 88vw);
    min-width: 0;
    justify-self: center;
  }
  .brand-wordmark {
    padding-left: .16em;
    font-size: clamp(20px, 7.1vw, 25px);
    letter-spacing: .16em;
  }
  .brand-tagline {
    grid-template-columns: minmax(24px, 1fr) auto minmax(24px, 1fr);
    gap: 8px;
  }
  .brand-tagline-text {
    font-size: clamp(6.5px, 2.25vw, 8px);
    letter-spacing: .2em;
  }
}



/* Wersja 17: uproszczony logotyp i główna nawigacja. */
.brand-logo {
  width: auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  grid-template-rows: none;
  gap: 0;
  margin-right: 48px;
  color: #111;
  line-height: 1;
}
.brand-wordmark {
  padding: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 28px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 2px;
  text-align: left;
  white-space: nowrap;
}

@media (min-width: 1101px) {
  .nav-left {
    gap: 4px;
  }
  .nav-left a:not(.button) {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 7px 10px;
    border: 0;
    border-radius: 8px;
  }
}

@media (max-width: 1100px) {
  .brand-logo {
    width: auto;
    min-width: 0;
    margin-right: 0;
    justify-self: auto;
  }
  .brand-wordmark {
    padding: 0;
    font-size: 24px;
    letter-spacing: 2px;
  }
  .nav-left {
    gap: 4px;
  }
  .nav-left a:not(.button) {
    border: 0;
    border-radius: 8px;
  }
}

.main-nav-link {
  gap: 7px;
  color: #405361;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.main-nav-link:hover {
  background: #eef4f8;
  color: var(--primary-dark);
}
.main-nav-link.is-active {
  background: #e7f0f6;
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px #d3e2ec;
  font-weight: 800;
}
.main-nav-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  flex: 0 0 16px;
  opacity: .82;
}
.main-nav-icon svg { width: 16px; height: 16px; }
.main-nav-link.is-active .main-nav-icon { opacity: 1; }

@media (max-width: 560px) {
  .brand-logo {
    width: auto;
    min-width: 0;
    margin: 0 auto;
    justify-content: center;
  }
  .brand-wordmark {
    padding: 0;
    font-size: clamp(20px, 6.5vw, 24px);
    letter-spacing: 2px;
    text-align: center;
  }
}

/* Wersja 18: dopracowany szeryfowy logotyp nagłówka. */
.brand-logo {
  margin-right: 20px;
  color: #555b61;
}
.brand-logo:hover {
  color: #353a3f;
}
.brand-wordmark {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 2.5px;
  color: inherit;
}

/* Poza desktopem logotyp jest wyśrodkowany względem całej szerokości nagłówka. */
@media (max-width: 1100px) {
  .brand-logo {
    order: 1;
    flex: 1 0 100%;
    width: 100%;
    margin: 0;
    justify-content: center;
    text-align: center;
  }
  .brand-wordmark {
    width: 100%;
    max-width: 100%;
    font-size: clamp(19px, 3.2vw, 24px);
    letter-spacing: clamp(2px, .35vw, 2.5px);
    text-align: center;
  }
  .nav-create { order: 2; }
  .nav-left { order: 3; }
}

@media (max-width: 560px) {
  .brand-wordmark {
    font-size: clamp(18px, 6vw, 22px);
    letter-spacing: 2px;
  }
}

/* Wersja 19: dopracowany układ nagłówka na tabletach i telefonach. */
@media (min-width: 561px) and (max-width: 1100px) {
  .nav-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 16px;
    row-gap: 9px;
  }

  .brand-logo {
    grid-column: 1;
    grid-row: 1;
    order: initial;
    flex: none;
    width: auto;
    min-width: 0;
    margin: 0;
    justify-self: start;
    justify-content: flex-start;
    text-align: left;
  }

  .brand-wordmark {
    width: auto;
    text-align: left;
  }

  .nav-create {
    grid-column: 2;
    grid-row: 1;
    order: initial;
    width: auto;
    margin: 0;
    justify-self: end;
  }

  .nav-left {
    grid-column: 1 / -1;
    grid-row: 2;
    order: initial;
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .nav-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .brand-logo {
    order: 1;
    flex: 1 0 100%;
    width: 100%;
    margin: 0;
    justify-content: center;
    text-align: center;
  }

  .brand-wordmark {
    width: 100%;
    text-align: center;
  }

  .nav-left {
    order: 2;
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .nav-create {
    display: none !important;
  }
}

/* Produkcyjna wersja Django: logowanie, konta i dodatkowe zabezpieczenia UI */
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.account-chip { display: flex; flex-direction: column; line-height: 1.15; color: #4f5862; font-size: .82rem; text-align: right; }
.account-chip small { color: #818891; font-size: .72rem; }
.logout-form { margin: 0; }
.header-link-button { border: 0; border-left: 1px solid #c9cdd2; background: transparent; color: #4f5862; padding: 4px 0 4px 14px; cursor: pointer; font: inherit; }
.header-link-button:hover { color: #111827; }
.auth-body { min-height: 100vh; background: #eef1f4; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(430px, 100%); padding: 34px; }
.auth-brand { font-family: Georgia, 'Times New Roman', serif; font-size: 24px; font-weight: 700; letter-spacing: 2.5px; color: #5e6267; margin-bottom: 24px; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-form label { display: grid; gap: 7px; font-weight: 600; }
.auth-form .errorlist, .errorlist { color: #a72b2b; margin: 5px 0 0; padding-left: 18px; font-size: .9rem; }
.compact-form { max-width: 720px; }
.role-badge { display: inline-flex; padding: 5px 9px; border-radius: 6px; background: #e8ebef; font-size: .82rem; font-weight: 700; }
.role-super_admin { background: #f7d8d8; color: #842222; }
.role-manager { background: #e8dcf5; color: #563179; }
.role-branch_user { background: #dce9f6; color: #274e75; }
.role-lite_viewer { background: #e8ebef; color: #4e5863; }
.users-table { table-layout: auto; font-size: .9rem; }
.users-table th,
.users-table td { padding: 10px 11px; }
.users-table th { font-size: 11px; line-height: 1.2; }
.users-table td { line-height: 1.28; }
.users-table .user-login-cell strong,
.users-table .user-login-cell small { display: block; overflow-wrap: anywhere; }
.users-table .user-login-cell small { margin-top: 2px; color: var(--muted); font-size: .76rem; line-height: 1.25; }
.users-table .user-name-cell { overflow-wrap: anywhere; }
.users-table .role-badge { padding: 4px 7px; font-size: .76rem; line-height: 1.15; }
.users-table .branch-badge { min-width: 34px; min-height: 24px; padding: 4px 7px; font-size: 11px; }
.users-table .user-branches { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; width: max-content; max-width: 100%; min-width: 0; }
.users-table .user-branches .branch-badge + .branch-badge { margin-left: 0; }
.users-table .status { padding: 4px 8px; font-size: 12px; }
.users-table .user-last-login { white-space: nowrap; font-variant-numeric: tabular-nums; }
.users-table .user-actions-cell { width: 1%; }
.user-actions { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; }
.user-actions form { margin: 0; }
.users-table .user-actions .button { min-height: 30px; padding: 4px 7px; gap: 5px; font-size: .77rem; line-height: 1.1; }
.users-table .user-actions .button-icon,
.users-table .user-actions .ui-icon { width: 14px; height: 14px; flex-basis: 14px; }
.button-small { padding: 6px 9px; min-height: auto; font-size: .82rem; }
.existing-attachments li { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.existing-attachments li > span { display: flex; flex-direction: column; gap: 2px; }
.compact-file-list { display: grid; gap: 4px; }
.compact-file-list a { font-size: .86rem; }
.lite-contracts-table td { vertical-align: top; }
.lite-description { min-width: 260px; max-width: 480px; }
.detail-grid-lite { grid-template-columns: minmax(0, 1fr); }
.notice-error { background: #fbe3e3; color: #7b2222; border-color: #efb6b6; }
.notice-success { background: #e1f4e8; color: #245c36; border-color: #b7dfc4; }

@media (max-width: 1100px) {
  .nav-wrap { grid-template-columns: 1fr auto; }
  .nav-left { grid-column: 1 / -1; justify-content: center; }
  .nav-right { grid-column: 2; grid-row: 1; }
  .account-chip, .logout-form { display: none; }
  .users-table .user-login-cell { column-gap: 9px; row-gap: 2px; }
  .users-table .user-login-cell small { grid-column: 2; }
  .users-table .user-branches-cell { align-items: start; }
  .users-table .user-branches { grid-column: 2; align-self: center; }
  .users-table .role-badge,
  .users-table .status { justify-self: start; width: auto; }
  .users-table .user-last-login {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 4px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .users-table .user-last-login::before { white-space: normal; }
  .users-table .user-actions-cell { width: auto; }
  .users-table .user-actions { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .nav-right { display: none; }
  .auth-card { padding: 24px; }
  .users-table .user-actions { justify-content: flex-start; }
}
.error-page { max-width: 720px; margin: 48px auto; padding: 32px; text-align: center; }
.backup-form { margin: 0; }


/* Produkcyjna tabela User lite: czytelne karty bez dziedziczenia układu pełnej tabeli. */
@media (max-width: 1100px) {
  .lite-contracts-table,
  .lite-contracts-table tbody,
  .lite-contracts-table tr,
  .lite-contracts-table td { display: block; width: 100%; }
  .lite-contracts-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .lite-contracts-table tbody { display: grid; gap: 14px; padding: 14px; }
  .lite-contracts-table tr { border: 1px solid #d9dee4; border-radius: 10px; overflow: hidden; background: #fff; }
  .lite-contracts-table td {
    min-width: 0;
    max-width: none;
    padding: 11px 14px 11px 122px;
    border: 0;
    border-bottom: 1px solid #e7eaee;
    position: relative;
    white-space: normal;
  }
  .lite-contracts-table td:last-child { border-bottom: 0; }
  .lite-contracts-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 14px;
    top: 11px;
    width: 96px;
    color: #69727c;
    font-weight: 700;
    text-align: left;
  }
  .lite-contracts-table .lite-description { min-width: 0; max-width: none; }
}
@media (max-width: 560px) {
  .lite-contracts-table td { padding-left: 14px; padding-top: 34px; }
  .lite-contracts-table td::before { width: auto; right: 14px; }
}

/* 1.0.1 — korekty zgodności z interfejsem lokalnym. */

/* Spójne, wektorowe ikony we wszystkich przyciskach i menu. */
.ui-icon {
  width: 18px;
  height: 18px;
  display: block;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.button-icon,
.menu-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.button-small .button-icon,
.button-small .ui-icon {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}
.header-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

/* Etykiety oddziałów — używane na liście, w szczegółach, statystykach,
   archiwum i panelu użytkowników. */
.branch-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .06em;
  white-space: nowrap;
  vertical-align: middle;
}
.branch-zs {
  background: #fde6e6;
  color: #9f1d1d;
  border-color: #f2bcbc;
}
.branch-fg {
  background: #eee7fa;
  color: #653a91;
  border-color: #d7c4ed;
}
.branch-fgw {
  background: #f1e6dc;
  color: #754626;
  border-color: #ddc2aa;
}
.branch-badge + .branch-badge { margin-left: 4px; }

/* Element tooltipa nie może zmieniać komórki <td> w inline-flex. */
@media (min-width: 1101px) {
  .contracts-table tbody td {
    vertical-align: middle;
  }
  .contracts-table tbody tr {
    min-height: 62px;
  }
  .contracts-table .cell-date > .tooltip-host,
  .contracts-table .cell-subject > .tooltip-host {
    min-height: 34px;
    align-items: center;
  }
  .contracts-table .cell-subject > .tooltip-host,
  .contracts-table .cell-subject .subject-value {
    max-width: 100%;
  }
  .contracts-table .cell-status .inline-status-form,
  .contracts-table .actions-cell .action-menu {
    vertical-align: middle;
  }
  .mobile-card-table td,
  .users-table td {
    vertical-align: middle;
  }
}

/* Nawigacja przewija się wewnątrz nagłówka, zamiast poszerzać całą stronę. */
html, body { max-width: 100%; }
@media (max-width: 1100px) {
  .nav-wrap,
  .nav-left {
    min-width: 0;
    max-width: 100%;
  }
  .nav-left {
    flex-wrap: nowrap;
    justify-content: safe center;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: #c6ced6 transparent;
    -webkit-overflow-scrolling: touch;
  }
  .nav-left::-webkit-scrollbar { height: 5px; }
  .nav-left::-webkit-scrollbar-thumb { background: #c6ced6; border-radius: 999px; }
  .nav-left a:not(.button) { flex: 0 0 auto; white-space: nowrap; }
  .nav-right { min-width: 0; }
}

/* Listy formularzy Django i pola wyboru zachowują spójny rytm. */
select:required:invalid { color: var(--muted); }
.form-grid small { color: var(--muted); font-weight: 400; line-height: 1.45; }

/* Drobne korekty innych podstron. */
.user-actions .button { white-space: nowrap; }
.mobile-card-table .branch-badge { justify-self: start; }
.existing-attachments li > span { min-width: 0; }
.existing-attachments li a { overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  /* Karty tabel zachowują separatory również dla jedynego i ostatniego rekordu. */
  .mobile-card-table tbody tr:last-child td:not(:last-child),
  .contracts-table tbody tr:last-child td:not(:last-child) {
    border-bottom: 1px solid #e7edf2;
  }
  .mobile-card-table tbody tr:last-child td:last-child,
  .contracts-table tbody tr:last-child td:last-child {
    border-bottom: 0;
  }
}
@media (max-width: 1100px) {
  .contracts-table .cell-business .branch-badge { justify-self: start; }
}

/* Panel użytkowników: czytelny wybór oddziału w formularzu konta. */
#id_branches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#id_branches > div > label,
#id_branches label {
  min-height: 40px;
  display: inline-flex;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  cursor: pointer;
}
#id_branches input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
}

/* 1.0.2 — spójny edytor użytkownika. */
.user-editor-form { padding: 22px; }
.user-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.user-field { min-width: 0; display: grid; gap: 7px; }
.user-field > label,
.user-branches-field > legend { font-weight: 700; }
.user-field small,
.user-field-hint,
.user-toggle-copy small,
.password-help { color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.45; }
.user-field-hint { margin: -1px 0 3px; }
.user-branches-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.user-branches-field > legend { padding: 0; margin-bottom: 7px; }
.user-branches-field[aria-disabled="true"] { opacity: .58; }
#id_branches { display: flex; flex-wrap: wrap; gap: 8px; }
#id_branches > div { display: contents; }
#id_branches > div > label,
#id_branches label {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfd;
  font-weight: 700;
  cursor: pointer;
}
#id_branches label:hover { border-color: #b6c3ce; background: #f6f9fb; }
#id_branches input[type="checkbox"] {
  appearance: auto;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}
.user-toggle-card {
  min-height: 92px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 18px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fbfcfd;
}
.user-toggle-copy { min-width: 0; display: grid; gap: 5px; }
.user-toggle-copy label { font-weight: 700; cursor: pointer; }
.user-toggle-control { display: grid; place-items: center; }
.user-toggle-control input[type="checkbox"] {
  appearance: auto;
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.user-toggle-card > .errorlist { grid-column: 1 / -1; }
.password-help ul { margin: 7px 0 0 18px; padding: 0; }
.user-editor-actions { display: flex; gap: 10px; margin-top: 20px; }
.button-danger { color: var(--danger); border-color: #e4b7b7; background: #fff; }
.button-danger:hover { color: #861f1f; border-color: #d99a9a; background: var(--danger-bg); }

@media (max-width: 820px) {
  .user-editor-form { padding: 17px; }
  .user-editor-grid { grid-template-columns: 1fr; gap: 15px; }
  .user-editor-grid .span-2 { grid-column: auto; }
}
@media (max-width: 560px) {
  .user-toggle-card { min-height: 0; padding: 13px; }
  #id_branches { display: grid; grid-template-columns: 1fr; }
  #id_branches label { width: 100%; }
  .user-editor-actions .button { width: 100%; }
}

/* 1.0.2 — metadane twórcy umowy w nagłówku szczegółów. */
.contract-heading-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}
.contract-heading-separator {
  width: 1px;
  height: 18px;
  background: #c9d1d8;
  flex: 0 0 1px;
}
.contract-created-by { color: var(--muted); }
.contract-created-by strong { color: #4e5963; font-weight: 700; }
@media (max-width: 560px) {
  .contract-heading-meta { align-items: flex-start; }
}
.audit-contract-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.audit-contract-link:hover { text-decoration: underline; }
.audit-object-id { display: block; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }

/* 1.1.0 — elastyczne uprawnienia użytkowników i filtr autora. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.muted-text { color: var(--muted); }

.filter-checkbox {
  min-height: 40px;
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  color: #4f5963;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.filter-checkbox input[type="checkbox"] {
  appearance: auto;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

.role-preset-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
  gap: 8px 12px;
}
.role-preset-row > small { grid-column: 1 / -1; }
.role-preset-select { display: grid; gap: 7px; }
.role-preset-select > label { font-weight: 700; }

.permission-section-heading { margin-top: 4px; }
.permissions-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.permission-card {
  min-height: 94px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fbfcfd;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.permission-card:hover {
  border-color: #b7c4cf;
  background: #f7fafc;
}
.permission-card:has(input:checked) {
  border-color: #aac7db;
  background: #f2f8fc;
  box-shadow: inset 0 0 0 1px rgba(31, 95, 139, .05);
}
.permission-card-sensitive:has(input:checked) {
  border-color: #deb7b7;
  background: #fff7f7;
}
.permission-card input[type="checkbox"] {
  appearance: auto;
  width: 19px;
  height: 19px;
  min-width: 19px;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--primary);
}
.permission-copy { min-width: 0; display: grid; gap: 5px; }
.permission-copy strong { color: var(--text); font-size: .93rem; line-height: 1.3; }
.permission-copy small { color: var(--muted); font-size: .79rem; line-height: 1.42; font-weight: 400; }
.permission-errors .errorlist { margin: 0 0 12px; padding: 11px 14px 11px 32px; border: 1px solid #efb6b6; border-radius: 9px; background: #fff3f3; }
.user-branches-field[aria-disabled="true"]::after {
  content: "Dla Super admina ograniczenie oddziałowe jest pomijane — konto zawsze widzi wszystkie oddziały.";
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1100px) {
  .filters .filter-checkbox { width: 100%; }
}
@media (max-width: 820px) {
  .permission-grid { grid-template-columns: 1fr; }
  .role-preset-row { grid-template-columns: 1fr; }
  .role-preset-row > small { grid-column: auto; }
  .role-preset-row .button { width: 100%; }
}


/* 1.1.0 — elastyczne uprawnienia: pełny widok może działać bez kolumny statusu. */
@media (min-width: 561px) and (max-width: 1100px) {
  .contracts-table-no-status tr {
    grid-template-areas:
      "business number"
      "date amount"
      "client client"
      "subject subject"
      "actions actions";
  }
  .contracts-table-no-status .actions-cell {
    grid-column: 1 / -1;
    grid-row: 5;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .contracts-table-no-status tr {
    grid-template-areas:
      "business"
      "number"
      "date"
      "client"
      "subject"
      "amount"
      "actions";
  }
}

@media (min-width: 1101px) {
  .filters { grid-template-columns: minmax(260px, 1fr) 220px auto auto auto; }
}


/* 1.1.1 — drobne korekty filtrów tabletowych i pól hasła. */
.filters > * { min-width: 0; }
.filter-checkbox { box-sizing: border-box; max-width: 100%; }
.filter-checkbox > span { min-width: 0; }

.password-field {
  align-self: start;
  align-content: start;
}
.password-field input[type="password"] {
  min-height: 43px;
  height: 43px;
}

@media (min-width: 761px) and (max-width: 1100px) {
  .filters {
    grid-template-columns: minmax(0, 1fr) minmax(215px, .52fr) minmax(140px, .35fr);
  }
  .filters input[type="search"] { grid-column: 1 / -1; }
  .filters .filter-checkbox {
    width: 100%;
    min-width: 0;
  }
}


/* 1.1.2 — spójne pola formularza użytkownika i tabletowa siatka filtrów. */
.user-editor-grid > .user-field {
  align-self: start;
  align-content: start;
}
.user-editor-grid > .user-field input:not([type="checkbox"]):not([type="radio"]),
.user-editor-grid > .user-field select {
  min-height: 43px;
  height: 43px;
}

@media (min-width: 761px) and (max-width: 1100px) {
  .contract-list-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
  .contract-list-filters .filter-search {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .contract-list-filters .filter-status {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
  }
  .contract-list-filters .filter-mine {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
  }
  .contract-list-filters .filter-submit {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
  }
  .contract-list-filters .filter-clear {
    grid-column: 2;
    grid-row: 3;
    width: 100%;
  }
  .contract-list-filters.filters-no-status .filter-mine {
    grid-column: 1 / -1;
  }
}

/* 1.1.3 — filtry od 561 px, czytelny dziennik oraz menu konta w nagłówku. */
@media (min-width: 561px) and (max-width: 1100px) {
  .contract-list-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
  .contract-list-filters .filter-search {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .contract-list-filters .filter-status {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
  }
  .contract-list-filters .filter-mine {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }
  .contract-list-filters .filter-submit {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
  }
  .contract-list-filters .filter-clear {
    grid-column: 2;
    grid-row: 3;
    width: 100%;
  }
  .contract-list-filters.filters-no-status .filter-mine {
    grid-column: 1 / -1;
  }
}

/* Menu użytkownika: pozycje administracyjne nie zajmują miejsca w głównej nawigacji. */
.account-menu {
  position: relative;
  order: 1;
}
.account-menu > summary {
  list-style: none;
}
.account-menu > summary::-webkit-details-marker {
  display: none;
}
.account-menu-trigger {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #4f5862;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.account-menu-trigger:hover,
.account-menu[open] .account-menu-trigger {
  background: #f3f6f8;
  border-color: var(--border);
  color: var(--text);
}
.account-menu-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: right;
}
.account-menu-copy strong {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .84rem;
}
.account-menu-copy small {
  margin-top: 2px;
  color: #818891;
  font-size: .72rem;
  white-space: nowrap;
}
.account-menu-chevron {
  width: 16px;
  height: 16px;
  display: inline-flex;
  flex: 0 0 16px;
  transition: transform .18s ease;
}
.account-menu-chevron svg,
.account-menu-panel .menu-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.account-menu[open] .account-menu-chevron {
  transform: rotate(180deg);
}
.account-menu-panel {
  position: absolute;
  z-index: var(--z-dropdown);
  right: 0;
  top: calc(100% + 8px);
  min-width: 230px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(31, 52, 70, .18);
}
.account-menu-panel a,
.account-menu-panel button {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.account-menu-panel a:hover,
.account-menu-panel button:hover {
  background: #eef3f7;
}
.account-menu-panel form { margin: 0; }
.account-menu-panel .menu-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: 0 0 18px;
  color: var(--muted);
}
.account-menu-separator {
  height: 1px;
  margin: 6px 5px;
  background: #e2e7ec;
}
.nav-right .nav-create { order: 2; }

@media (min-width: 561px) and (max-width: 1100px) {
  .nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }
  .account-menu-copy strong { max-width: 150px; }
}

@media (max-width: 560px) {
  .nav-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    row-gap: 7px;
  }
  .brand-logo {
    grid-column: 1;
    grid-row: 1;
  }
  .nav-left {
    grid-column: 1;
    grid-row: 2;
  }
  .nav-right {
    grid-column: 1;
    grid-row: 3;
    display: flex;
    width: 100%;
    margin: 0;
    justify-content: center;
  }
  .nav-create { display: none !important; }
  .account-menu-trigger { justify-content: center; }
  .account-menu-copy { text-align: center; }
  .account-menu-panel {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    width: min(280px, calc(100vw - 32px));
  }
}

/* Dziennik operacji: JSON jest prezentowany jako kod, a publiczne IP prowadzi do ipinfo.io. */
.audit-table-wrap { overflow: visible; }
.audit-user-cell { min-width: 150px; }
.audit-user-stack { display: grid; gap: 3px; min-width: 0; }
.audit-user-name { display: block; font-weight: 700; }
.audit-user-ip { display: block; line-height: 1.25; }
.audit-ip-link {
  display: inline-flex;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .84rem;
  font-weight: 700;
}
.audit-ip-link:hover { text-decoration: underline; }
.audit-ip-local {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .84rem;
}
.audit-details-cell {
  min-width: 300px;
  width: 42%;
}
.audit-json {
  width: 100%;
  max-width: 100%;
  max-height: 280px;
  margin: 0;
  padding: 11px 12px;
  overflow: auto;
  border: 1px solid #dfe5ea;
  border-radius: 8px;
  background: #f7f9fb;
  color: #26323c;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.audit-json code {
  font: inherit;
  color: inherit;
}
.audit-table td[data-label="Akcja"] code { white-space: nowrap; }
.audit-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.35fr) minmax(190px, .85fr) minmax(145px, .65fr) minmax(145px, .65fr) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.audit-filters label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.audit-filters input,
.audit-filters select { width: 100%; min-width: 0; }
.audit-filter-actions { display: flex; gap: 8px; }
.audit-filter-actions .button { min-height: 42px; }

@media (max-width: 1100px) {
  .audit-table-wrap { overflow: visible; }
  .audit-details-cell { width: auto; min-width: 0; }
  .audit-json { max-height: 340px; }
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-filter-query { grid-column: 1 / -1; }
  .audit-filter-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 560px) {
  .audit-filters { grid-template-columns: 1fr; }
  .audit-filter-query, .audit-filter-actions { grid-column: auto; }
  .audit-filter-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-filter-actions .button { width: 100%; }
}

/* Wersja 1.2.0: katalog materiałów. */
.material-page-heading { align-items: center; }
.category-create-menu { position: relative; }
.category-create-menu > summary { list-style: none; }
.category-create-menu > summary::-webkit-details-marker { display: none; }
.category-create-panel {
  position: absolute;
  z-index: 3;
  right: 0;
  top: calc(100% + 8px);
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  box-shadow: 0 16px 40px rgba(31, 52, 70, .18);
}
.category-create-panel label { display: grid; gap: 6px; font-weight: 700; }
.category-create-panel .button { align-self: end; }

.material-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.material-tab {
  flex: 0 0 auto;
  min-width: 130px;
  padding: 10px 18px;
  border-radius: 9px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
  white-space: nowrap;
}
.material-tab:hover { background: #eef3f7; color: var(--text); }
.material-tab.active { background: var(--primary); color: #fff; }

.material-filters {
  display: grid;
  grid-template-columns: minmax(280px, 1.6fr) repeat(3, minmax(145px, .65fr)) auto auto;
  gap: 10px;
  padding: 14px;
  margin-bottom: 16px;
  align-items: center;
}
.material-search-field { position: relative; min-width: 0; }
.material-suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(31, 52, 70, .18);
}
.material-suggestion {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 7px;
  text-align: left;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.material-suggestion:hover,
.material-suggestion.is-active { background: #eef3f7; }

.material-catalog-card { overflow: hidden; }
.material-catalog-heading {
  padding: 18px 20px 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}
.material-catalog-heading h2 { margin: 2px 0 0; }
.material-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.material-table-wrap { overflow-x: auto; }
.material-table { min-width: 920px; }
.material-table th,
.material-table td { vertical-align: middle; }
.material-table th:first-child,
.material-table td:first-child { width: 1%; white-space: nowrap; }
.material-table th:nth-child(4),
.material-table td:nth-child(4),
.material-table th:nth-child(6),
.material-table td:nth-child(6),
.material-actions-col,
.material-row-actions { width: 1%; white-space: nowrap; }
.material-id { font-weight: 800; color: var(--primary-dark); }
.material-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 600; }
.thickness-pill { display: inline-flex; min-width: 52px; justify-content: center; padding: 5px 8px; border-radius: 999px; background: #eef3f7; font-size: 12px; font-weight: 800; }
.material-row-actions { text-align: right; }
.material-row-actions form { margin: 0; }
.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}
.icon-button svg { width: 16px; height: 16px; }
.icon-button:hover { border-color: #aab8c4; color: var(--text); background: #f7fafc; }
.icon-button-danger:hover { color: var(--danger); background: var(--danger-bg); border-color: #efb4b4; }
.icon-button-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.icon-button-primary:hover { color: #fff; background: var(--primary-dark); border-color: var(--primary-dark); }
.material-new-row td { background: #f8fbfd; border-top: 2px solid #cad7e1; }
.material-new-row input,
.material-new-row select { min-width: 110px; padding: 8px 9px; }
.material-new-row td:nth-child(2) input { min-width: 180px; }
.material-new-row td:nth-child(3) input { min-width: 150px; }
.material-auto-id { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.material-inline-hint { margin: 0; padding: 11px 18px 14px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }
.material-empty { padding: 30px; }
.material-empty h2 { margin-bottom: 7px; }
.material-empty p { margin: 0; }

@media (max-width: 1100px) {
  .material-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .material-search-field { grid-column: 1 / -1; }
  .material-filters .button { width: 100%; }
  .material-table { min-width: 860px; }
}

@media (max-width: 560px) {
  .material-page-heading { align-items: stretch; }
  .category-create-menu { width: 100%; }
  .category-create-menu > summary { width: 100%; }
  .category-create-panel { position: fixed; top: 74px; left: 16px; right: 16px; width: auto; grid-template-columns: 1fr; }
  .material-tab { min-width: 112px; padding-inline: 13px; }
  .material-filters { grid-template-columns: 1fr; }
  .material-search-field { grid-column: auto; }
  .material-catalog-heading { align-items: flex-start; }
  .material-table-wrap { overflow: visible; }
  .material-table,
  .material-table tbody { display: block; min-width: 0; }
  .material-table thead { display: none; }
  .material-table tbody { padding: 10px; }
  .material-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
  }
  .material-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: auto !important;
    white-space: normal !important;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid #e7edf2;
  }
  .material-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  .material-table td:nth-child(2),
  .material-table td:nth-child(3),
  .material-table .empty,
  .material-table .material-row-actions { grid-column: 1 / -1; }
  .material-table tr > td:last-child { border-bottom: 0; }
  .material-table .empty { display: block; text-align: center; }
  .material-table .empty::before { display: none; }
  .material-row-actions { text-align: left; }
  .material-new-row td { background: #f8fbfd; }
  .material-new-row input,
  .material-new-row select { min-width: 0 !important; }
}

/* Wersja 1.2.1: rozbudowany katalog materiałów. */
.material-filters {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: stretch;
}
.material-search-field { grid-column: span 6; }
.material-filters > select { grid-column: span 2; }
.material-price-range {
  grid-column: span 8;
  display: grid;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfd;
}
.material-price-range-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.material-price-range-head strong { color: var(--text); }
.material-price-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.material-price-sliders label { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.material-price-sliders input[type="range"] { width: 100%; min-width: 0; accent-color: var(--primary); }
.material-filter-actions { grid-column: span 4; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: stretch; }
.material-filter-actions .button { width: 100%; }

.material-heading-tools { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap; }
.material-price-switch { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; user-select: none; }
.material-price-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 38px; height: 21px; padding: 2px; border-radius: 999px; background: #cbd6de; transition: background .18s ease; }
.switch-track > span { display: block; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(20, 40, 55, .28); transition: transform .18s ease; }
.material-price-switch input:checked + .switch-track { background: var(--primary); }
.material-price-switch input:checked + .switch-track > span { transform: translateX(17px); }

.material-table { min-width: 1260px; }
.material-table-all { min-width: 1360px; }
.material-table th,
.material-table td { vertical-align: middle; }
.material-table th a { color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.material-table th.sortable a:hover { color: var(--primary); }
.material-table th:first-child,
.material-table td:first-child { width: auto; }
.material-table .material-id,
.material-table .material-price-cell,
.material-table .material-row-actions { white-space: nowrap; }
.material-table .material-actions-col,
.material-table .material-row-actions { width: 1%; text-align: center; }
.material-category-badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; background: #eef3f7; font-size: 12px; font-weight: 800; white-space: nowrap; }
.material-size-tooltip { justify-content: center; }
.material-size-trigger { width: 32px; height: 32px; display: inline-grid; place-items: center; color: var(--primary-dark); border: 1px solid var(--border); border-radius: 8px; background: #f8fbfd; }
.material-size-trigger svg { width: 17px; height: 17px; }
.material-size-tooltip:focus-visible .material-size-trigger { outline: 2px solid rgba(31, 95, 139, .25); outline-offset: 2px; }
.material-view-actions,
.material-edit-actions { display: inline-flex; justify-content: flex-end; gap: 6px; }
.material-edit-actions { display: none; }
.material-edit-field { display: none; width: 100%; min-width: 90px; padding: 8px 9px; }
.material-product-row.is-editing [data-material-display] { display: none !important; }
.material-product-row.is-editing .material-edit-field { display: block; }
.material-product-row.is-editing .material-view-actions { display: none; }
.material-product-row.is-editing .material-edit-actions { display: inline-flex; }
.material-product-row.is-editing td { background: #fbfdff; }
.material-size-input { min-width: 150px; }
.material-price-cell .price-gross,
.material-price-head .price-heading-gross,
.material-group-price .price-gross { display: none; }
.material-catalog-card.is-gross .material-price-cell .price-net,
.material-catalog-card.is-gross .material-price-head .price-heading-net,
.material-catalog-card.is-gross .material-group-price .price-net { display: none; }
.material-catalog-card.is-gross .material-price-cell .price-gross,
.material-catalog-card.is-gross .material-price-head .price-heading-gross,
.material-catalog-card.is-gross .material-group-price .price-gross { display: inline; }
.material-new-row td { background: #f8fbfd; }
.material-new-row-top td { border-top: 0; border-bottom: 2px solid #cad7e1; }
.material-new-row-bottom td { border-top: 2px solid #cad7e1; }
.material-new-row input,
.material-new-row select { width: 100%; min-width: 100px; padding: 8px 9px; }
.material-new-row td:nth-child(2) input,
.material-new-row td:nth-child(3) input { min-width: 120px; }
.material-inline-hint { border-top: 1px solid var(--border); }
.material-catalog-card + .pagination-bar { margin-top: 14px; }
.material-count-grouped-mobile { display: none; }
.material-grouped-mobile-view { display: none; }

@media (min-width: 1101px) {
  .material-group-row > td {
    padding: 4px 8px;
    background: #fff;
    border-bottom-color: #dde1e4;
  }
  .material-group-summary {
    display: block;
    min-width: 0;
    padding: 6px;
    border-radius: 10px;
    background: #fff;
    transition: background .15s ease;
  }
  .material-group-row:hover { background: transparent; }
  .material-group-row:hover > td { background: #f8fbfd; }
  .material-group-row:hover .material-group-summary { background: #f8fbfd; }
  .material-group-toggle {
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: 22px minmax(0, 345px) 104px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
  }
  .material-group-toggle:hover { background: transparent; }
  .material-group-toggle:focus-visible { outline: 2px solid rgba(31, 95, 139, .28); outline-offset: 1px; }
  .material-group-chevron {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    color: var(--primary-dark);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform .16s ease;
  }
  .material-group-toggle[aria-expanded="true"] .material-group-chevron { transform: rotate(90deg); }
  .material-group-primary,
  .material-group-meta { min-width: 0; }
  .material-group-primary {
    display: grid;
    gap: 2px;
  }
  .material-group-primary strong {
    color: #25333c;
    font-size: 16px;
    overflow-wrap: anywhere;
  }
  .material-group-primary > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    overflow-wrap: anywhere;
  }
  .material-group-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .material-group-count {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef3f7;
    color: #4b5963;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
  }
  .material-group-price {
    color: var(--text);
    font-size: 14px;
    font-weight: 400;
    text-align: right;
    white-space: nowrap;
  }
  .material-group-price .price-net,
  .material-group-price .price-gross { margin-right: 6px; }
  .material-group-actions-cell { text-align: center; }
  .material-group-add-variant {
    width: 132px;
    min-height: 34px;
    padding: 6px 9px;
    white-space: nowrap;
    background: #fff;
  }
  .material-group-variant-row.is-group-collapsed { display: none; }
  .material-group-variant-row > td { background: #f4f9fc; }
  .material-group-variant-row > td:first-child { box-shadow: inset 3px 0 0 #cbdde8; }
  .material-group-variant-row:hover > td { background: #f8fbfd; }
}

@media (min-width: 1101px) and (max-width: 1280px) {
  .material-group-add-variant { font-size: 12px; }
}

@media (max-width: 1100px) {
  .material-grouped-desktop-view { display: none !important; }
  .material-grouped-mobile-view { display: block; }
  .material-group-row { display: none !important; }
  .material-count-grouped-desktop { display: none; }
  .material-count-grouped-mobile { display: inline; }
  .material-search-field { grid-column: 1 / -1; }
  .material-filters > select { grid-column: span 4; }
  .material-price-range { grid-column: 1 / -1; }
  .material-filter-actions { grid-column: 1 / -1; }
  .material-tabs { overflow-x: auto; }

  .material-table-wrap { overflow: visible; }
  .material-table,
  .material-table tbody { display: block; min-width: 0; }
  .material-table thead { display: none; }
  .material-table tbody { padding: 10px; }
  .material-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
  }
  .material-table td {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    width: auto !important;
    min-width: 0 !important;
    white-space: normal !important;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid #e7edf2;
    text-align: left !important;
  }
  .material-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  /* Desktop ma kolejność Nazwa | Producent | Typ; karty mobilne zachowują
     dotychczasową kolejność Typ | Producent | Nazwa. */
  .material-product-row > td:nth-child(3) { order: 1; }
  .material-product-row > td:nth-child(2) { order: 2; }
  .material-product-row > td:nth-child(1) { order: 3; }
  .material-product-row > td:nth-child(4) { order: 4; }
  .material-product-row > td:nth-child(5) { order: 5; }
  .material-product-row > td:nth-child(6) { order: 6; }
  .material-product-row > td:nth-child(7) { order: 7; }
  .material-product-row > td:nth-child(8) { order: 8; }
  .material-table .material-row-actions { grid-column: 1 / -1; }
  .material-table tr > td:last-child { border-bottom: 0; }
  .material-table .empty { grid-column: 1 / -1; display: block; text-align: center !important; }
  .material-table .empty::before { display: none; }
  .material-size-tooltip { justify-content: flex-start; }
  .material-view-actions,
  .material-edit-actions { justify-content: flex-start; }
  .material-edit-field { min-width: 0 !important; }
  .tooltip-host[data-tooltip-all] { cursor: help; }
  .tooltip-host[data-tooltip-all] .dynamic-tooltip { display: grid !important; }
}

@media (max-width: 760px) {
  .material-filters > select { grid-column: span 6; }
  .material-price-sliders { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .material-filters { grid-template-columns: 1fr; }
  .material-search-field,
  .material-filters > select,
  .material-price-range,
  .material-filter-actions { grid-column: auto; }
  .material-filter-actions { grid-template-columns: 1fr; }
  .material-price-range-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .material-heading-tools { width: 100%; justify-content: space-between; }
  .material-table tr { grid-template-columns: 1fr; }
  .material-table td,
  .material-table .material-row-actions { grid-column: auto; }
  .material-table td { grid-template-columns: 96px minmax(0, 1fr); }
  .material-table .empty { grid-column: auto; }
}

/* Wersja 1.2.2: dopracowanie katalogu materiałów. */
.material-filters {
  align-items: start;
}
.material-filter-actions {
  align-self: center;
  align-items: center;
}
.material-filter-actions .button {
  min-height: 44px;
  height: 44px;
  padding-block: 8px;
}

/* Jeden suwak zakresu z dwoma uchwytami. */
.material-price-range {
  gap: 7px;
  padding: 10px 13px;
}
.material-dual-range {
  position: relative;
  height: 28px;
  margin: 0 4px;
}
.material-dual-range-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  height: 4px;
  border-radius: 999px;
  background: #d9e1e7;
  overflow: hidden;
}
.material-dual-range-track > span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: inherit;
  background: var(--primary);
}
.material-dual-range input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  pointer-events: none;
  outline: none;
}
.material-dual-range input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.material-dual-range input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(22, 57, 80, .25);
  appearance: none;
  -webkit-appearance: none;
  pointer-events: auto;
  cursor: grab;
}
.material-dual-range input[type="range"]::-moz-range-track { height: 4px; background: transparent; border: 0; }
.material-dual-range input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(22, 57, 80, .25);
  pointer-events: auto;
  cursor: grab;
}
.material-price-range-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

/* Szybkie dodawanie poza tabelą. */
.material-quick-add {
  margin-bottom: 16px;
  padding: 16px;
  transition: box-shadow .18s ease, border-color .18s ease;
}
.material-quick-add.is-variant-prefill-target {
  border-color: #9fc2d8;
  box-shadow: 0 0 0 3px rgba(31, 95, 139, .12), 0 8px 24px rgba(31, 52, 70, .08);
}
.material-quick-add-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}
.material-quick-add-heading h2 { margin: 2px 0 0; font-size: 19px; }
.material-quick-add-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px 12px;
  align-items: end;
}
.material-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.material-field > span {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}
.material-field input,
.material-field select { width: 100%; min-width: 0; }
.material-field-name { grid-column: span 2; }
.material-quick-add-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.material-quick-add-action .button { width: 100%; min-height: 42px; }
.material-quick-add-clear { min-width: 108px; }
.material-quick-add-clear[hidden] { display: none; }

/* Tabela: bez kolumny kategorii. */
.material-table,
.material-table-all { min-width: 1180px; }
.material-table th:first-child,
.material-table td:first-child { width: 1%; white-space: nowrap; }
.material-table th:nth-child(2),
.material-table td:nth-child(2) { width: 1%; white-space: nowrap; }
.material-table th:nth-child(4),
.material-table td:nth-child(4),
.material-table th:nth-child(7),
.material-table td:nth-child(7),
.material-table th:nth-child(8),
.material-table td:nth-child(8) { width: 1%; white-space: nowrap; }
.material-inline-category {
  display: block;
  width: 132px !important;
  min-width: 0 !important;
  margin-top: 6px;
}
.material-action-label { display: none; }

/* Paginacja katalogu zawsze jest osobnym, domkniętym kontenerem. */
.material-pagination-wrap { margin-top: 14px; }
.material-pagination-wrap .pagination-bar {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--card);
  overflow: hidden;
}

@media (max-width: 1100px) {
  .material-search-field { grid-column: 1 / -1; }
  .material-filters > select { grid-column: span 4; }
  .material-price-range,
  .material-filter-actions { grid-column: 1 / -1; }
  .material-filter-actions { grid-template-columns: 1fr 1fr; }

  .material-quick-add-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .material-field-name { grid-column: span 1; }
  .material-quick-add-action { grid-column: 1 / -1; }

  .material-table .material-price-cell,
  .material-table .material-new-price-cell { grid-column: 1 / -1; }
  .material-table .material-row-actions { grid-column: 1 / -1; }
  .material-view-actions,
  .material-edit-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }
  .material-edit-actions { display: none; }
  .material-product-row.is-editing .material-edit-actions { display: grid; }
  .material-view-actions form { width: 100%; }
  .material-action-button,
  .material-add-row-button {
    width: 100%;
    min-width: 0;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 8px;
  }
  .material-action-label { display: inline; font-size: 12px; font-weight: 800; white-space: nowrap; }
  .material-action-icon { display: inline-flex; flex: 0 0 auto; }
  .material-action-icon svg { width: 15px; height: 15px; }
  .material-new-row .material-row-actions { display: block; }
  .material-new-row .material-add-row-button { min-height: 40px; }
}

@media (max-width: 760px) {
  .material-filters > select { grid-column: span 4; }
  .material-quick-add-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
}

@media (max-width: 560px) {
  .material-filters { grid-template-columns: 1fr; }
  .material-search-field,
  .material-filters > select,
  .material-price-range,
  .material-filter-actions { grid-column: auto; }
  .material-filter-actions { grid-template-columns: 1fr 1fr; }
  .material-price-range-head { flex-direction: row; align-items: center; }
  .material-quick-add-form { grid-template-columns: 1fr; }
  .material-field-name,
  .material-quick-add-action { grid-column: auto; }
  .material-quick-add { padding: 13px; }
  .material-table .material-price-cell,
  .material-table .material-new-price-cell,
  .material-table .material-row-actions { grid-column: auto; }
  .material-view-actions,
  .material-edit-actions { grid-template-columns: 1fr 1fr; }
  .material-table td { grid-template-columns: 94px minmax(0, 1fr); }
}


/* Wersja 1.2.3: poprawki slidera cen i kart materiałów. */
.material-price-range {
  gap: 8px;
  padding: 10px 12px;
}
.material-price-range-head {
  align-items: center;
}
.material-dual-range {
  position: relative;
  height: 24px;
  margin: 0;
  padding: 0 10px;
}
.material-dual-range-track {
  left: 10px;
  right: 10px;
  top: 10px;
  height: 4px;
  border: 0;
  box-shadow: none;
}
.material-dual-range input[type="range"] {
  inset: 0;
  width: 100%;
  height: 24px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.material-dual-range input[type="range"]:focus,
.material-dual-range input[type="range"]:focus-visible {
  outline: none;
  box-shadow: none;
}
.material-dual-range input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border: 0;
  background: transparent;
}
.material-dual-range input[type="range"]::-moz-range-track {
  height: 4px;
  border: 0;
  background: transparent;
}
.material-price-range-labels {
  padding: 0 10px;
  gap: 16px;
}
.material-filter-actions {
  align-self: end;
}
.material-filter-actions .button {
  min-height: 40px;
  height: 40px;
}
.material-table td[data-label="Grubość"] .thickness-pill {
  justify-self: start;
  min-width: 64px;
  padding: 4px 10px;
}
.material-table td[data-label="Cena"] strong {
  justify-self: start;
}
.material-row-actions form {
  width: 100%;
}
.material-view-actions,
.material-edit-actions {
  width: 100%;
}
.material-view-actions > button,
.material-view-actions > form,
.material-edit-actions > button {
  width: 100%;
}
.material-view-actions form .material-action-button {
  width: 100%;
}
.material-action-button {
  min-height: 40px;
  border-radius: 10px;
}
@media (max-width: 1100px) {
  .material-price-range {
    padding: 10px 10px 8px;
  }
  .material-dual-range {
    padding: 0 2px;
  }
  .material-dual-range-track {
    left: 2px;
    right: 2px;
  }
  .material-price-range-labels {
    padding: 0 2px;
  }
  .material-table td[data-label="Grubość"] {
    grid-template-columns: 104px max-content;
  }
  .material-table td.material-price-cell {
    grid-template-columns: 104px minmax(0, 1fr);
  }
  .material-action-button,
  .material-add-row-button {
    min-height: 42px;
    height: 42px;
    padding: 9px 12px;
    border-radius: 10px;
  }
}
@media (max-width: 560px) {
  .material-price-range {
    padding: 10px 10px 8px;
  }
  .material-price-range-labels {
    padding: 0 2px;
  }
  .material-table td[data-label="Grubość"] {
    grid-template-columns: 94px max-content;
  }
  .material-table td.material-price-cell {
    grid-template-columns: 94px minmax(0, 1fr);
  }
}


/* Wersja 1.2.4: usunięcie dolnego szybkiego dodawania i dopracowanie stylu kart materiałów. */
.material-inline-hint {
  padding: 12px 18px 15px;
  line-height: 1.45;
}
.material-row-actions {
  min-width: 0;
}
.material-view-actions,
.material-edit-actions {
  align-items: stretch;
}
.material-action-button {
  justify-content: center;
  text-align: center;
}
.material-action-label {
  white-space: normal;
  line-height: 1.15;
}
@media (max-width: 1100px) {
  .material-table .material-row-actions {
    padding-top: 12px;
  }
  .material-view-actions,
  .material-edit-actions {
    gap: 10px;
  }
  .material-action-button,
  .material-add-row-button {
    align-items: center;
  }
  .material-action-label {
    display: inline-block;
    white-space: normal;
    text-align: center;
  }
}
@media (max-width: 560px) {
  .material-table .material-row-actions {
    padding-top: 10px;
  }
  .material-view-actions,
  .material-edit-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}


/* Wersja 1.2.5: responsywność i układ katalogu materiałów. */
.material-quick-add,
.material-catalog-card,
.material-pagination-wrap {
  overflow: hidden;
}
.material-page-heading,
.material-filters { overflow: visible; }
.material-filters,
.material-quick-add-form,
.material-catalog-heading,
.material-heading-tools,
.material-table-wrap,
.material-table,
.material-table tbody,
.material-table tr,
.material-table td,
.material-view-actions,
.material-edit-actions,
.material-view-actions > form {
  min-width: 0;
}
.material-search-field input { min-width: 0; }
.material-table-wrap { overflow-x: hidden !important; }
.material-table,
.material-table-all {
  width: 100%;
  min-width: 0 !important;
  table-layout: fixed;
}
.material-table th, .material-table td { overflow-wrap: anywhere; }
.material-table th:nth-child(1), .material-table td:nth-child(1) { width: 14%; }
.material-table th:nth-child(2), .material-table td:nth-child(2) { width: 22%; }
.material-table th:nth-child(3), .material-table td:nth-child(3) { width: 16%; }
.material-table th:nth-child(4), .material-table td:nth-child(4) { width: 12%; }
.material-table th:nth-child(5), .material-table td:nth-child(5) { width: 14%; }
.material-table th:nth-child(6), .material-table td:nth-child(6) { width: 10%; }
.material-table th:nth-child(7), .material-table td:nth-child(7) { width: 8%; }
.material-actions-col, .material-row-actions { width: 14%; }
.material-inline-hint code, .material-auto-id { display: none; }
.material-input-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.material-input-suffix input { border: 0 !important; box-shadow: none !important; }
.material-input-suffix-text {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  border-left: 1px solid var(--border);
  background: #f7fafc;
}
.material-size-trigger { margin-left: auto; }
.material-row-actions { text-align: right; }
.material-view-actions,
.material-edit-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
}
.material-view-actions > button,
.material-view-actions > form,
.material-edit-actions > button {
  flex: 1 1 0;
  min-width: 0;
}
.material-view-actions form .material-action-button { width: 100% !important; }
.material-action-button {
  width: 100% !important;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
}
.material-action-icon { flex: 0 0 16px; display: inline-flex; align-items: center; justify-content: center; }
.material-action-label { display: inline-block; white-space: normal; text-align: center; line-height: 1.2; }
@media (max-width: 1100px) {
  .material-filter-actions { grid-template-columns: 1fr 1fr; }
  .material-table-wrap { overflow: visible !important; }
  .material-table, .material-table tbody { display: block; width: 100%; }
  .material-table thead { display: none; }
  .material-table tbody { padding: 10px; }
  .material-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .material-table td {
    grid-template-columns: 108px minmax(0, 1fr);
    width: 100% !important;
    box-sizing: border-box;
  }
  .material-table td:nth-child(2),
  .material-table td:nth-child(3),
  .material-table td:nth-child(5),
  .material-table .material-row-actions {
    grid-column: 1 / -1;
  }
  .material-table td.material-price-cell { grid-column: 1 / 2; }
  .material-table td.material-size-cell { grid-column: 2 / 3; }
  .material-table td[data-label="Grubość"] { grid-column: 1 / -1; }
  .material-size-trigger { margin-left: 0; }
  .material-row-actions { padding-top: 12px; }
  .material-view-actions, .material-edit-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 10px;
  }
}
@media (max-width: 560px) {
  .material-filter-actions { grid-template-columns: 1fr 1fr; }
  .material-table tr { grid-template-columns: 1fr; }
  .material-table td,
  .material-table .material-row-actions,
  .material-table td.material-price-cell,
  .material-table td.material-size-cell,
  .material-table td[data-label="Grubość"] {
    grid-column: auto;
  }
  .material-table td { grid-template-columns: 96px minmax(0, 1fr); }
  .material-view-actions, .material-edit-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}


/* Wersja 1.2.6: desktopowe akcje tylko jako ikony + bezpiecznie ukryty switch cen. */
.material-price-switch {
  position: relative;
}
.material-price-switch input[type="checkbox"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Desktop: kompaktowe przyciski akcji wyłącznie z ikonami. */
.material-actions-col,
.material-row-actions {
  width: 92px !important;
  white-space: nowrap;
}
.material-view-actions,
.material-edit-actions {
  display: inline-flex;
  width: auto;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
.material-edit-actions { display: none; }
.material-product-row.is-editing .material-edit-actions { display: inline-flex; }
.material-view-actions > button,
.material-view-actions > form,
.material-edit-actions > button {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
}
.material-view-actions > form { width: auto; }
.material-action-button,
.material-view-actions form .material-action-button {
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  display: inline-grid !important;
  place-items: center;
  gap: 0;
  border-radius: 8px;
}
.material-action-label {
  display: none !important;
}
.material-action-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.material-action-icon svg {
  width: 16px;
  height: 16px;
}

/* Desktopowa tabela ma zamknięte proporcje bez wypychania ostatniej kolumny. */
.material-table th:nth-child(1), .material-table td:nth-child(1) { width: 13%; }
.material-table th:nth-child(2), .material-table td:nth-child(2) { width: 22%; }
.material-table th:nth-child(3), .material-table td:nth-child(3) { width: 15%; }
.material-table th:nth-child(4), .material-table td:nth-child(4) { width: 12%; }
.material-table th:nth-child(5), .material-table td:nth-child(5) { width: 14%; }
.material-table th:nth-child(6), .material-table td:nth-child(6) { width: 9%; }
.material-table th:nth-child(7), .material-table td:nth-child(7) { width: 7%; }
.material-table th.material-actions-col,
.material-table td.material-row-actions { width: 8% !important; }
.material-actions-col { overflow-wrap: normal !important; }

@media (max-width: 1100px) {
  /* Tablet/mobile: pełne przyciski 50/50 z tekstem. */
  .material-table .material-row-actions { width: 100% !important; }
  .material-view-actions,
  .material-edit-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 10px;
    align-items: stretch;
  }
  .material-edit-actions { display: none; }
  .material-product-row.is-editing .material-edit-actions { display: grid; }
  .material-view-actions > button,
  .material-view-actions > form,
  .material-edit-actions > button,
  .material-view-actions > form .material-action-button {
    width: 100% !important;
    min-width: 0 !important;
  }
  .material-action-button,
  .material-view-actions form .material-action-button {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 42px !important;
    padding: 9px 12px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
  }
  .material-action-label {
    display: inline-block !important;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }
}

@media (max-width: 560px) {
  .material-view-actions,
  .material-edit-actions {
    gap: 8px;
  }
}


/* Wersja 1.2.7: poprawiony grid kart tablet/mobile i tekstowy format. */
.material-format-responsive {
  display: none;
}

@media (max-width: 1100px) {
  /* Pola bez logicznego partnera zajmują pełny wiersz, więc separator domyka kartę. */
  .material-table td[data-label="Producent"],
  .material-table td[data-label="Nazwa"],
  .material-table td[data-label="Typ"],
  .material-table td[data-label="Wykończenie"],
  .material-table td[data-label="Grubość"] {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }

  /* Cena i format pozostają obok siebie na tablecie. */
  .material-table td.material-price-cell {
    grid-column: 1 / 2 !important;
  }
  .material-table td.material-size-cell {
    grid-column: 2 / 3 !important;
  }

  /* Na tablet/mobile format pokazuje rzeczywistą wartość zamiast ikony. */
  .material-format-desktop {
    display: none !important;
  }
  .material-format-responsive {
    display: inline !important;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Akcje są samodzielnym, pełnoszerokim blokiem — bez etykiety „Akcje”. */
  .material-table td.material-row-actions {
    grid-column: 1 / -1 !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 12px !important;
    box-sizing: border-box;
    text-align: left !important;
  }
  .material-table td.material-row-actions::before {
    display: none !important;
    content: none !important;
  }
  .material-view-actions,
  .material-edit-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    width: 100% !important;
    min-width: 0 !important;
    gap: 10px !important;
  }
  .material-edit-actions {
    display: none !important;
  }
  .material-product-row.is-editing .material-edit-actions {
    display: grid !important;
  }
  .material-view-actions > button,
  .material-view-actions > form,
  .material-edit-actions > button,
  .material-view-actions > form .material-action-button,
  .material-edit-actions .material-action-button {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box;
  }
  .material-row-actions form {
    min-width: 0 !important;
    max-width: none !important;
  }
}

@media (max-width: 560px) {
  /* Telefon: wszystkie pola jeden pod drugim, format nadal tekstowo. */
  .material-table td.material-price-cell,
  .material-table td.material-size-cell,
  .material-table td[data-label="Producent"],
  .material-table td[data-label="Nazwa"],
  .material-table td[data-label="Typ"],
  .material-table td[data-label="Wykończenie"],
  .material-table td[data-label="Grubość"] {
    grid-column: auto !important;
  }
  .material-table td.material-row-actions {
    grid-column: auto !important;
  }
  .material-view-actions,
  .material-edit-actions {
    gap: 8px !important;
  }
}


/* Wersja 1.2.8: jednorzędowe karty tablet/mobile i nagłówek katalogu na telefonie. */
@media (max-width: 1100px) {
  /* Każda wartość materiału jest osobnym pełnoszerokim rzędem. */
  .material-table tr.material-product-row {
    grid-template-columns: 1fr !important;
  }
  .material-table tr.material-product-row > td,
  .material-table tr.material-product-row > td.material-price-cell,
  .material-table tr.material-product-row > td.material-size-cell,
  .material-table tr.material-product-row > td[data-label="Producent"],
  .material-table tr.material-product-row > td[data-label="Nazwa"],
  .material-table tr.material-product-row > td[data-label="Typ"],
  .material-table tr.material-product-row > td[data-label="Wykończenie"],
  .material-table tr.material-product-row > td[data-label="Grubość"] {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Separatory zawsze obejmują pełną szerokość karty, także pierwszy/ostatni rekord. */
  .material-table tr.material-product-row > td:not(.material-row-actions) {
    border-bottom: 1px solid #e7edf2 !important;
  }
  .material-table tr.material-product-row > td.material-row-actions {
    border-bottom: 0 !important;
  }

  /* Format jest zwykłym tekstem; nie pozostaje układ dwóch kolumn Cena/Format. */
  .material-table td.material-size-cell {
    text-align: left !important;
  }
  .material-format-responsive {
    display: inline-block !important;
    justify-self: start;
  }

  /* Akcje pozostają pełnoszerokim blokiem bez etykiety. */
  .material-table td.material-row-actions {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px !important;
    border-top: 0 !important;
  }
  .material-table td.material-row-actions::before {
    display: none !important;
    content: none !important;
  }
  .material-view-actions,
  .material-edit-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
  }
  .material-product-row.is-editing .material-view-actions + .material-edit-actions {
    margin-top: 8px;
  }
}

@media (max-width: 560px) {
  /* Na telefonie narzędzia nagłówka są pod tytułem, a nie obok niego. */
  .material-catalog-heading {
    display: grid !important;
    grid-template-columns: 1fr !important;
    align-items: start !important;
    gap: 12px !important;
  }
  .material-heading-tools {
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 14px !important;
    flex-wrap: nowrap !important;
  }
  .material-price-switch,
  .material-count {
    flex: 0 0 auto;
  }
}


/* Wersja 1.2.9: poprawiony stacking popupu tworzenia kategorii. */
.material-page-heading {
  position: relative;
  z-index: 40;
  overflow: visible !important;
}
.category-create-menu {
  position: relative;
  z-index: 1;
  overflow: visible;
}
.category-create-menu[open] {
  z-index: 2;
}
.category-create-panel {
  z-index: 3 !important;
}
.material-tabs,
.material-quick-add,
.material-catalog-card,
.material-pagination-wrap {
  position: relative;
  z-index: var(--z-content);
}
.material-filters {
  position: relative;
  z-index: 2;
  overflow: visible !important;
}
.material-filters:focus-within { z-index: 30; }
.material-suggestions { z-index: 20; }


/* Kompaktowa tabela katalogu: tożsamość produktu jest jedną, szeroką kolumną.
   Nazwa (+ producent i typ) | Grubość | Wykończenie | Format | Cena | Akcje */
.material-product-identity {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.material-product-identity strong {
  color: #25333c;
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.material-product-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.material-identity-edit-fields {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.material-format-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (min-width: 1101px) {
  .material-table {
    --material-col-thickness: 150px;
    --material-col-finish: 170px;
    --material-col-format: 170px;
    --material-col-price: 180px;
    --material-col-actions: 148px;
    table-layout: fixed;
  }
  .material-table th,
  .material-table td { padding: 10px 14px; }
  .material-table .material-group-row > td { padding: 4px 8px; }
  .material-table th:nth-child(1),
  .material-table td.material-identity-cell { width: auto; white-space: normal; }
  .material-table th:nth-child(2),
  .material-table td.material-thickness-cell { width: var(--material-col-thickness); }
  .material-table th:nth-child(3),
  .material-table td.material-finish-cell { width: var(--material-col-finish); }
  .material-table th:nth-child(4),
  .material-table td.material-size-cell { width: var(--material-col-format); }
  .material-table th:nth-child(5),
  .material-table td.material-price-cell,
  .material-table td.material-group-price { width: var(--material-col-price); }
  .material-table th:nth-child(6),
  .material-table td.material-row-actions,
  .material-table td.material-group-actions-cell { width: var(--material-col-actions); }
  .material-table .material-size-cell,
  .material-table .material-size-head { text-align: left; white-space: normal; }
  .material-table th:nth-child(2),
  .material-table .material-thickness-cell { text-align: center; }
  .material-table .material-price-head,
  .material-table .material-price-cell { text-align: right; white-space: nowrap; }
  .material-table th.material-actions-col,
  .material-table td.material-row-actions { width: var(--material-col-actions) !important; }
  .material-table th.material-actions-col { text-align: center; }
  .material-table td.material-row-actions {
    box-sizing: border-box;
    padding-left: 14px !important;
    padding-right: 14px !important;
    text-align: right;
  }
  .material-table td.material-row-actions .material-view-actions,
  .material-table td.material-row-actions .material-edit-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .material-product-row:hover .thickness-pill,
  .material-group-variant-row:hover .thickness-pill {
    background: #dce8f0;
    color: #29495f;
  }
}

@media (max-width: 1100px) {
  /* Po scaleniu producenta i typu w komórce nazwy mobilna karta zachowuje
     logiczną kolejność wszystkich pozostałych pól. */
  .material-product-row > td.material-identity-cell {
    order: 1 !important;
    row-gap: 0 !important;
  }
  .material-product-row > td.material-identity-cell .material-identity-edit-fields {
    display: none;
  }
  .material-product-row.is-editing > td.material-identity-cell .material-identity-edit-fields {
    display: grid;
    grid-column: 2;
  }
  .material-product-row > td.material-thickness-cell { order: 2 !important; }
  .material-product-row > td.material-finish-cell { order: 3 !important; }
  .material-product-row > td.material-size-cell { order: 4 !important; }
  .material-product-row > td.material-price-cell { order: 5 !important; }
  .material-product-row > td.material-row-actions { order: 6 !important; }
  .material-product-row > .material-identity-cell,
  .material-product-row > .material-thickness-cell,
  .material-product-row > .material-finish-cell,
  .material-product-row > .material-size-cell,
  .material-product-row > .material-price-cell,
  .material-product-row > .material-row-actions {
    grid-column: 1 / -1 !important;
  }
  .material-table td.material-size-cell { text-align: left !important; }
}


/* Wersja 1.3.3: stacking nagłówka, taby katalogu na mobile i producent z kategorii. */
/* Sticky header zawsze pozostaje nad zawartością strony. */
.topbar {
  z-index: var(--z-header);
}

/* Starsze globalne reguły `nav` ukrywały pierwszy link <=820px i wszystkie linki <=620px.
   Katalog materiałów ma własną nawigację i musi pozostać widoczny na każdej szerokości. */
.material-tabs {
  display: flex !important;
  width: 100%;
  max-width: 100%;
  justify-content: flex-start !important;
  overflow-x: auto !important;
  overflow-y: hidden;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.material-tabs > .material-tab,
.material-tabs > a.material-tab,
.material-tabs > a.material-tab:first-child {
  display: block !important;
  flex: 0 0 auto;
}

.material-fixed-manufacturer {
  align-content: center;
  min-height: 66px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7fafc;
}
.material-fixed-manufacturer > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.material-fixed-manufacturer strong {
  font-size: 15px;
}
.material-fixed-manufacturer small {
  color: var(--muted);
  line-height: 1.2;
}

@media (max-width: 820px) {
  .material-tabs > a:first-child {
    display: block !important;
  }
}
@media (max-width: 620px) {
  .material-tabs a:not(.button),
  .material-tabs > .material-tab {
    display: block !important;
  }
}
@media (max-width: 560px) {
  .material-tabs {
    gap: 6px;
    padding: 5px;
  }
  .material-tab {
    min-width: max-content;
    padding-inline: 14px;
  }
}

/* Wersja 1.4.0: moduł Notatki. */
.notes-page-heading { margin-bottom: 16px; }
.note-create-card,
.note-edit-card { padding: 20px; margin-bottom: 28px; }
.note-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.note-section-heading h2 { margin: 3px 0 0; font-size: 22px; }
.note-limit,
.note-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.note-form-grid { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 2fr) minmax(180px, .8fr) minmax(180px, .8fr); gap: 14px; align-items: end; }
.note-form-grid label { display: grid; gap: 7px; min-width: 0; font-weight: 700; }
.note-content-field { grid-row: span 2; align-self: stretch; }
.note-content-field textarea { min-height: 132px; height: 100%; resize: vertical; line-height: 1.5; }
.note-pin-checkbox { display: flex !important; align-items: center; gap: 9px !important; min-height: 42px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fbfcfd; }
.note-pin-checkbox input { width: 18px; height: 18px; margin: 0; flex: 0 0 18px; }
.note-form-action { display: flex; align-items: end; }
.note-form-action .button { width: 100%; }
.field-error { color: var(--danger); font-weight: 600; }
.notes-section { margin-bottom: 32px; }
.notes-list-heading { margin-bottom: 14px; padding: 0 2px; }
.notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.sticky-note { position: relative; min-height: 230px; padding: 16px; display: flex; flex-direction: column; gap: 14px; background: #fff8c9; border: 1px solid #e6d887; border-radius: 6px 14px 14px 14px; box-shadow: 0 7px 18px rgba(74, 67, 30, .08); overflow: hidden; }
.sticky-note::before { content: ""; position: absolute; inset: 0 auto auto 0; width: 18px; height: 18px; background: rgba(255,255,255,.55); clip-path: polygon(0 0, 100% 0, 0 100%); }
.sticky-note-private { background: #eef6fb; border-color: #bfd6e5; }
.sticky-note-pinned { border-color: #c79921; box-shadow: 0 9px 24px rgba(128, 92, 13, .14); }
.sticky-note-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-height: 32px; }
.sticky-note-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.note-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.66); border: 1px solid rgba(100,90,40,.15); font-size: 11px; font-weight: 800; }
.note-badge-pin { background: #fff1a9; color: #6f5200; }
.note-badge-public { background: #e9f6e5; color: #356b2b; }
.sticky-note-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.sticky-note-actions form { margin: 0; }
.note-icon-button { width: 31px; height: 31px; padding: 0; display: inline-grid; place-items: center; border: 1px solid rgba(92,90,70,.18); border-radius: 8px; background: rgba(255,255,255,.68); color: var(--text); cursor: pointer; }
a.note-icon-button { display: inline-grid; }
.note-icon-button svg { width: 15px; height: 15px; }
.note-icon-button:hover { background: #fff; border-color: #abb6bf; }
.note-icon-danger { color: var(--danger); }
.sticky-note-content { flex: 1 1 auto; white-space: normal; overflow-wrap: anywhere; font-size: 16px; line-height: 1.55; }
.sticky-note-footer { margin-top: auto; padding-top: 11px; border-top: 1px solid rgba(70,70,40,.14); display: grid; gap: 3px; color: #697079; font-size: 11px; }
.notes-empty { padding: 34px; text-align: center; color: var(--muted); }
@media (max-width: 1100px) {
  .notes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-form-grid { grid-template-columns: 1fr 1fr; }
  .note-content-field { grid-column: 1 / -1; grid-row: auto; }
}
@media (max-width: 620px) {
  .note-create-card, .note-edit-card { padding: 15px; }
  .note-form-grid { grid-template-columns: 1fr; }
  .note-content-field { grid-column: auto; }
  .notes-grid { grid-template-columns: 1fr; }
  .note-section-heading { align-items: center; }
  .sticky-note { min-height: 205px; }
}


/* Wersja 1.4.1: przebudowany moduł Notatki. */
.note-create-card,
.note-edit-card {
  padding: 20px;
  margin-bottom: 28px;
}
.note-form-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: stretch;
}
.note-form-grid label {
  min-width: 0;
  font-weight: 700;
}
.note-switch-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 14px;
  align-items: stretch;
}
.note-switch-control {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfd;
}
.note-switch-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 800;
}
.note-info-host {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  outline: none;
}
.note-info-icon {
  width: 19px;
  height: 19px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #aebbc5;
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}
.note-info-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: 30;
  width: min(280px, 75vw);
  padding: 9px 11px;
  border-radius: 8px;
  background: #172736;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(20, 36, 48, .18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}
.note-info-host:hover .note-info-tooltip,
.note-info-host:focus .note-info-tooltip,
.note-info-host:focus-within .note-info-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.note-switch {
  position: relative;
  display: inline-flex !important;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  cursor: pointer;
}
.note-switch input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.note-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd6df;
  transition: background .16s ease;
}
.note-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(30, 50, 65, .22);
  transition: transform .16s ease;
}
.note-switch input:checked + .note-switch-track {
  background: var(--primary);
}
.note-switch input:checked + .note-switch-track .note-switch-knob {
  transform: translateX(20px);
}
.note-switch input:focus-visible + .note-switch-track {
  outline: 2px solid rgba(32, 102, 143, .35);
  outline-offset: 2px;
}
.note-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.note-title-field,
.note-lifetime-group > label,
.note-content-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}
.note-title-field {
  width: 100%;
}
.note-lifetime-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.note-lifetime-group:has(.note-custom-expiry[hidden]) {
  grid-template-columns: 1fr;
}
.note-custom-expiry[hidden] {
  display: none !important;
}
.note-content-field {
  position: relative;
  grid-column: 1 / -1;
  grid-row: auto !important;
  align-self: auto;
}
.note-content-field textarea {
  width: 100%;
  min-height: 150px;
  height: auto;
  resize: vertical;
  padding-bottom: 30px;
  line-height: 1.5;
}
.note-char-counter {
  position: absolute;
  right: 11px;
  bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}
.note-char-counter.is-near-limit {
  color: #a26700;
}
.note-char-counter.is-at-limit {
  color: var(--danger);
}
.note-form-action {
  display: flex;
  justify-content: flex-end;
}
.note-form-action .button {
  width: auto;
  min-width: 170px;
}
.notes-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 12px;
}
.sticky-note {
  position: relative;
  width: 100%;
  min-height: 0;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 3px 12px rgba(31, 50, 63, .045);
  overflow: visible;
}
.sticky-note::before {
  display: none;
}
.sticky-note-private {
  background: #fff;
  border-color: var(--border);
}
.sticky-note-pinned {
  background: #fff9dc;
  border-color: #e4d28a;
  box-shadow: 0 5px 16px rgba(117, 91, 18, .08);
}
.sticky-note-topline {
  min-height: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.sticky-note-author {
  display: block;
  margin-top: 1px;
  margin-bottom: -4px;
  color: #7b8e9b;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 550;
}
.sticky-note-author strong {
  color: #5f7686;
  font-weight: 750;
}
.sticky-note-title {
  margin: 0;
  color: var(--text);
  font-size: 19px;
  line-height: 1.28;
  font-weight: 850;
  overflow-wrap: anywhere;
}
.sticky-note-content {
  flex: 1 1 auto;
  color: var(--text);
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.55;
}
.sticky-note-footer {
  margin-top: 3px;
  padding-top: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(88, 105, 117, .15);
  color: #697079;
  font-size: 11px;
}
.sticky-note-footer > span:last-child {
  text-align: right;
}
.sticky-note-footer-separator {
  width: 1px;
  height: 16px;
  background: rgba(88, 105, 117, .28);
}
@media (max-width: 820px) {
  .note-switch-row {
    grid-template-columns: 1fr 1fr;
  }
  .note-meta-row {
    grid-template-columns: 1fr;
  }
  .note-lifetime-group {
    grid-template-columns: 1fr 1fr;
  }
  .note-lifetime-group:has(.note-custom-expiry[hidden]) {
    grid-template-columns: 1fr;
  }
  .note-form-action .button {
    width: 100%;
  }
}
@media (max-width: 560px) {
  .note-create-card,
  .note-edit-card {
    padding: 15px;
  }
  .note-switch-row {
    grid-template-columns: 1fr;
  }
  .note-lifetime-group {
    grid-template-columns: 1fr;
  }
  .sticky-note {
    padding: 14px;
  }
  .sticky-note-topline {
    gap: 8px;
  }
  .sticky-note-title {
    font-size: 18px;
  }
  .sticky-note-footer {
    gap: 8px;
    font-size: 10px;
  }
}


/* Wersja 1.4.2: notatki + mobilne menu offcanvas. */
.note-switch-row {
  grid-template-columns: repeat(2, 275px);
}
.note-info-icon {
  padding: 0;
}
.note-info-icon svg {
  width: 13px;
  height: 13px;
}
.sticky-note-pinned {
  background: #fffdf0;
  border-color: #eadfa8;
  box-shadow: 0 4px 14px rgba(117, 91, 18, .055);
}
.note-badge-icon {
  width: 13px;
  height: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.note-badge-icon svg { width: 13px; height: 13px; }
.sticky-note-actions {
  gap: 7px;
}
.sticky-note-actions form {
  display: inline-flex;
}
.note-action-button {
  min-height: 34px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(92, 105, 115, .22);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.note-action-button:hover {
  background: #f5f8fa;
  border-color: #a9b6bf;
}
.note-action-danger { color: var(--danger); }
.note-action-danger:hover { background: var(--danger-bg); border-color: #efb4b4; }
.note-action-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  flex: 0 0 16px;
}
.note-action-icon svg { width: 16px; height: 16px; }

/* Mobilny/tabletowy header: jeden przycisk Menu przy logo i offcanvas z pełną nawigacją. */
.mobile-menu-trigger,
.mobile-nav-backdrop,
.mobile-offcanvas {
  display: none;
}
@media (max-width: 1100px) {
  body.mobile-nav-open { overflow: hidden; }
  .topbar { z-index: var(--z-header); }
  .topbar .nav-wrap {
    min-height: 64px;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding-block: 7px;
  }
  .topbar .brand {
    order: 1;
    margin: 0 !important;
    flex: 0 1 auto;
  }
  .topbar .nav-left,
  .topbar .nav-right {
    display: none !important;
  }
  .mobile-menu-trigger {
    order: 2;
    min-height: 38px;
    padding: 7px 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
  }
  .mobile-menu-trigger:hover { background: #f5f8fa; border-color: #aab8c4; }
  .mobile-menu-trigger-icon { width: 18px; height: 18px; display: inline-flex; }
  .mobile-menu-trigger-icon svg { width: 18px; height: 18px; }
  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-mobile-backdrop);
    display: block;
    background: rgba(18, 31, 42, .38);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
  }
  .mobile-nav-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .mobile-offcanvas {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-mobile-nav);
    width: min(360px, 88vw);
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid var(--border);
    box-shadow: 18px 0 42px rgba(21, 37, 49, .18);
    transform: translateX(-105%);
    transition: transform .22s ease;
    visibility: hidden;
  }
  .mobile-offcanvas.is-open {
    transform: translateX(0);
    visibility: visible;
  }
  .mobile-offcanvas-header {
    min-height: 70px;
    padding: 13px 14px 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
  }
  .mobile-offcanvas-user { display: grid; gap: 2px; min-width: 0; }
  .mobile-offcanvas-user strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-offcanvas-user small { color: var(--muted); font-size: 11px; font-weight: 700; }
  .mobile-offcanvas-close {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
  }
  .mobile-offcanvas-close svg { width: 18px; height: 18px; }
  .mobile-offcanvas-links {
    padding: 12px;
    display: grid !important;
    gap: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .mobile-offcanvas-links a,
  .mobile-offcanvas-links button {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
  }
  .mobile-offcanvas-links a:hover,
  .mobile-offcanvas-links button:hover {
    background: #f3f7fa;
    border-color: #e1e8ed;
  }
  .mobile-offcanvas-links a.is-active {
    background: #e7f0f6;
    border-color: #d3e2ec;
    color: var(--primary-dark);
    font-weight: 800;
  }
  .mobile-offcanvas-links form { margin: 0; }
  .mobile-nav-icon { width: 19px; height: 19px; display: inline-flex; flex: 0 0 19px; }
  .mobile-nav-icon svg { width: 19px; height: 19px; }
  .mobile-nav-primary {
    margin-top: 3px;
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
  }
  .mobile-nav-primary:hover { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; }
  .mobile-nav-separator { height: 1px; margin: 7px 3px; background: var(--border); }

  .sticky-note-actions { gap: 6px; }
  .note-action-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
  }
  .note-action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}
@media (max-width: 820px) {
  .note-switch-row {
    grid-template-columns: repeat(2, minmax(0, 275px));
  }
}
@media (max-width: 620px) {
  .topbar .nav-wrap { gap: 9px; }
  .mobile-menu-trigger { padding-inline: 9px; }
}
@media (max-width: 560px) {
  .note-switch-row { grid-template-columns: 1fr; }
  .mobile-offcanvas { width: min(340px, 92vw); }
}

/* Wersja 1.4.3: dopracowanie headera i listy Notatek. */
@media (max-width: 1100px) {
  .topbar .nav-wrap {
    flex-wrap: nowrap;
    justify-content: space-between;
  }
  .topbar .brand {
    flex: 0 1 auto;
    min-width: 0;
  }
  .mobile-menu-trigger {
    flex: 0 0 auto;
    margin-left: auto;
  }
}

.notes-list-heading-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.notes-list-heading-separator {
  width: 1px;
  height: 34px;
  flex: 0 0 1px;
  background: var(--border);
}
.notes-mine-filter { margin: 0; }
.notes-mine-filter-label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}
.notes-mine-filter-label:hover { background: #f7f9fb; border-color: #b9c5ce; }
.notes-mine-filter-label input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  flex: 0 0 16px;
}
@media (max-width: 620px) {
  .notes-list-heading {
    align-items: flex-end;
    gap: 10px;
  }
  .notes-list-heading-main {
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .notes-list-heading-separator { height: 30px; }
  .notes-mine-filter-label { min-height: 34px; padding: 6px 9px; }
}


/* Wersja 1.4.5: WYSIWYG Notatek, stopka i dopracowanie mobile. */
.note-field-label {
  display: block;
  font-weight: 700;
}
.note-rich-editor {
  overflow: hidden;
  border: 1px solid #bec9d3;
  border-radius: 10px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.note-rich-editor:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 95, 139, .16);
}
.note-editor-toolbar {
  min-height: 44px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid #e3e9ee;
  background: #f8fafb;
}
.note-editor-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.note-editor-divider {
  width: 1px;
  height: 24px;
  background: #d8e0e6;
}
.note-editor-tool {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #41515d;
  cursor: pointer;
}
.note-editor-tool:hover,
.note-editor-tool:focus-visible {
  background: #fff;
  border-color: #cbd6de;
  color: var(--primary);
  outline: none;
}
.note-editor-tool.is-active {
  background: #e8f1f7;
  border-color: #b9d0df;
  color: var(--primary);
}
.note-editor-tool svg {
  width: 17px;
  height: 17px;
}
.note-editor-surface {
  min-height: 170px;
  padding: 13px 14px;
  color: var(--text);
  line-height: 1.55;
  overflow-wrap: anywhere;
  outline: none;
}
.note-editor-surface:empty::before {
  content: attr(data-placeholder);
  color: #89959f;
  pointer-events: none;
}
.note-editor-surface p,
.sticky-note-content p {
  margin: 0 0 .65em;
}
.note-editor-surface p:last-child,
.sticky-note-content p:last-child { margin-bottom: 0; }
.note-editor-surface ul,
.note-editor-surface ol,
.sticky-note-content ul,
.sticky-note-content ol {
  margin: .45em 0 .65em 1.4em;
  padding: 0;
}
.note-editor-surface blockquote,
.sticky-note-content blockquote {
  margin: .55em 0;
  padding: .25em 0 .25em 12px;
  border-left: 3px solid #c5d4df;
  color: #536571;
}
.note-editor-bottomline {
  min-height: 34px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #edf1f4;
  background: #fbfcfd;
}
.note-editor-hint {
  color: var(--muted);
  font-size: 11px;
}
.note-rich-editor .note-char-counter {
  position: static;
  margin-left: auto;
  flex: 0 0 auto;
  pointer-events: none;
}
.sticky-note-content strong { font-weight: 800; }
.sticky-note-content u { text-underline-offset: 2px; }
.sticky-note-content s { color: #65727f; }
.app-footer {
  padding: 18px 0 24px;
  color: #84909a;
  font-size: 11px;
}
.app-footer-inner {
  display: flex;
  justify-content: center;
  text-align: center;
}
@media (max-width: 620px) {
  .topbar .nav-wrap {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: 16px;
    padding-right: 16px;
  }
  .topbar .brand {
    margin-left: 0 !important;
    padding-left: 0;
  }
  .note-editor-toolbar { gap: 4px; padding: 5px; }
  .note-editor-tool { width: 30px; height: 30px; }
  .note-editor-divider { height: 22px; }
  .note-editor-hint { display: none; }
  .note-editor-surface { min-height: 155px; padding: 12px; }
}
.auth-body {
  display: flex;
  flex-direction: column;
}
.auth-body .auth-shell {
  min-height: 0;
  flex: 1 0 auto;
}
.auth-footer { flex: 0 0 auto; }
@media (max-width: 620px) {
  .topbar .brand-logo {
    width: auto;
    justify-content: flex-start;
    text-align: left;
  }
  .topbar .brand-wordmark {
    width: auto;
    text-align: left;
  }
}
