/* Vend Magazyn — wspolny responsywny interfejs */
:root {
    font-family:
        system-ui,
        -apple-system,
        'Segoe UI',
        sans-serif;
    color: #182333;
    background: #f5f7fb;
    font-size: 15px;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background: #f5f7fb;
    color: #182333;
    font:
        15px system-ui,
        -apple-system,
        'Segoe UI',
        sans-serif;
}
header {
    background: #172b4d;
    color: #fff;
    padding: 16px max(16px, 4%);
    position: relative;
    z-index: 3;
}
header h1 {
    font-size: clamp(19px, 3vw, 25px);
    margin: 0 0 3px;
}
header a {
    color: #fff;
}
main {
    max-width: 1320px;
    margin: auto;
    padding: 16px 16px 95px;
}
nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0 0 14px;
    padding: 6px;
    background: #fff;
    border: 1px solid #dce2e9;
    border-radius: 12px;
}
nav a {
    display: inline-flex;
    padding: 10px 12px;
    color: #174a84;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
}
nav a:hover,
nav a:focus-visible {
    background: #eaf2fc;
}
section,
.panel {
    background: #fff;
    border: 1px solid #dce2e9;
    border-radius: 12px;
    padding: 18px;
    margin: 14px 0;
    min-width: 0;
}
h2 {
    font-size: 19px;
    margin: 0 0 12px;
}
h3 {
    font-size: 16px;
}
a {
    color: #175ba7;
}
input,
select,
button {
    font: inherit;
    padding: 10px 11px;
    margin: 3px;
    border: 1px solid #b9c7d7;
    border-radius: 9px;
    max-width: 100%;
    min-height: 42px;
}
input,
select {
    background: #fff;
    color: #182333;
}
button {
    background: #1959a5;
    color: #fff;
    border-color: #1959a5;
    font-weight: 650;
    cursor: pointer;
}
button:hover {
    background: #124781;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid #78b8f3;
    outline-offset: 2px;
}
button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
label {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    margin: 4px;
    color: #52647a;
    font-size: 13px;
}
label input,
label select {
    color: #182333;
    font-size: 15px;
}
.fields,
.toolbar,
.actions {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    align-items: end;
}
.fields > * {
    flex: 1;
    min-width: 170px;
}
.fields button {
    flex: 0 0 auto;
}
.scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px;
}
th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: middle;
}
th {
    background: #eef3fa;
    font-weight: 700;
}
tr[hidden] {
    display: none !important;
}
.sortable th {
    cursor: pointer;
    user-select: none;
}
.sortable th:hover {
    background: #dceaf9;
}
.table-filter {
    min-width: min(100%, 260px);
}
.error {
    color: #9c1d20;
    background: #fff0f0;
    padding: 10px;
    border-radius: 9px;
}
.ok,
.notice {
    color: #116331;
    background: #eaf7ee;
    padding: 10px;
    border-radius: 9px;
}
.hint,
.muted {
    color: #596c80;
    font-size: 13px;
}
.nowrap {
    white-space: nowrap;
}
.inline-map,
.mapform {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.mapform select {
    min-width: 160px;
    max-width: 350px;
}
.qty-field:not(:placeholder-shown) {
    background: #fffbe5;
}
.topline,
.slot-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.slot-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 12px;
}
.slot {
    border: 1px solid #d6e0e9;
    background: #fff;
    border-radius: 12px;
    padding: 14px;
}
.slot.changed {
    border: 2px solid #0b75cf;
    background: #f1f8ff;
}
.slot-title {
    font-size: 15px;
    font-weight: 750;
}
.slot-sub {
    font-size: 12px;
    color: #566b80;
    margin: 7px 0;
}
.slot-row strong {
    font-size: 22px;
}
.controls {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: 12px;
}
.controls button {
    min-width: 44px;
    font-size: 20px;
}
.controls input {
    width: 66px;
    min-width: 0;
    text-align: center;
    font-size: 20px;
    font-weight: 750;
    flex: 1;
}
.controls .fill {
    font-size: 13px;
    min-width: 78px;
}
.sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 -5px 24px #20334a25;
    padding: 12px max(12px, env(safe-area-inset-right));
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 8;
}
.sticky button {
    flex: 1;
}
.sticky small {
    font-size: 12px;
    max-width: 150px;
}
.warning {
    color: #a45a00;
}
.tiny {
    font-size: 12px;
}
.actions button {
    font-size: 13px;
}
.login {
    max-width: 450px;
    margin: 8vh auto;
    padding: 20px;
}
.login input,
.login button {
    width: 100%;
}
@media (max-width: 700px) {
    main {
        padding: 10px 10px 100px;
    }
    header {
        padding: 14px 12px;
    }
    section,
    .panel {
        padding: 13px;
        margin: 10px 0;
    }
    nav {
        gap: 4px;
    }
    nav a {
        font-size: 13px;
        padding: 10px 9px;
    }
    input,
    select,
    button {
        min-height: 44px;
    }
    label {
        width: 100%;
        margin: 3px 0;
    }
    .fields > * {
        min-width: 100%;
    }
    .fields button {
        width: 100%;
    }
    .toolbar input,
    .toolbar select,
    .toolbar button {
        width: 100%;
    }
    .slot-list {
        grid-template-columns: 1fr;
    }
    .scroll table:not(#bulk-table):not(#tx) {
        min-width: 680px;
    }
    #bulk-table th,
    #bulk-table td {
        padding: 8px 5px;
    }
    #bulk-table .qty-field {
        width: 84px !important;
    }
    #tx {
        min-width: 0 !important;
    }
    #tx thead {
        display: none;
    }
    #tx tbody,
    #tx tr,
    #tx td {
        display: block;
        width: 100%;
    }
    #tx tr {
        margin: 12px 0;
        border: 1px solid #dce2e9;
        border-radius: 12px;
        padding: 10px;
        background: #fff;
    }
    #tx td {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        justify-content: space-between;
        padding: 8px 2px;
        border-bottom: 1px solid #edf1f5;
        overflow-wrap: anywhere;
    }
    #tx td:before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 700;
        color: #52647a;
        flex: 0 0 100px;
    }
    #tx td:last-child {
        display: block;
        border: 0;
    }
    #tx td:last-child:before {
        display: block;
        margin-bottom: 8px;
    }
    .mapform {
        display: grid;
        grid-template-columns: 1fr;
        gap: 5px;
    }
    .mapform select,
    .mapform button {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
    .topline {
        align-items: flex-start;
    }
    .topline h2 {
        overflow-wrap: anywhere;
    }
    .sticky {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}
/* v6 — jeden arkusz dla wszystkich modułów */
.header-subtitle {
    color: #e0eaf7;
}
.logout {
    float: right;
    color: #fff;
}
.header-link {
    color: #fff;
}
.qty-width {
    width: 125px;
}
.login {
    max-width: 440px;
    margin: 8vh auto;
}
.login section {
    box-shadow: 0 12px 38px #172b4d14;
}
.login form {
    display: grid;
    gap: 12px;
}
.login input,
.login button {
    width: 100%;
    margin: 0;
}
#tx td[data-label='MDB'] strong {
    font-size: 17px;
    color: #164f8e;
}
#tx td[data-label='UUID'] {
    font-size: 11px;
    color: #64748b;
    overflow-wrap: anywhere;
}
nav a[aria-current='page'] {
    background: #eaf2fc;
}
@media (max-width: 700px) {
    .logout {
        float: none;
        display: inline-block;
        margin-top: 8px;
    }
    .qty-width {
        width: 82px;
    }
    .login {
        margin: 6vh auto;
        padding: 12px;
    }
    #tx td[data-label='MDB'] {
        background: #edf5ff;
        border-radius: 7px;
        padding: 10px 6px;
    }
    #tx td[data-label='MDB'] strong {
        font-size: 20px;
    }
    #tx td[data-label='UUID'] {
        display: none;
    }
    #tx td[data-label='Przypisanie produktu'] {
        display: block;
    }
    #tx td[data-label='Przypisanie produktu']:before {
        display: block;
        margin-bottom: 8px;
    }
}

/* v8: wspólna nawigacja, dynamiczne mapowanie */
.app-nav {
    display: block;
}
.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.nav-toggle {
    display: none;
}
.suggestion {
    display: grid;
    gap: 5px;
    min-width: 180px;
}
.suggestion small {
    color: #53667b;
}
.suggestion button {
    font-size: 12px;
    padding: 6px 9px;
    min-height: 34px;
}
.product-filter {
    width: 100%;
    min-width: 160px;
}
.mapform {
    min-width: 230px;
}
.mapform .product-filter {
    flex-basis: 100%;
}
@media (max-width: 700px) {
    .app-nav {
        padding: 6px;
    }
    .nav-toggle {
        display: block;
        width: 100%;
        text-align: left;
        margin: 0;
    }
    .nav-links {
        display: none;
        flex-direction: column;
        padding-top: 6px;
    }
    .nav-links.nav-open {
        display: flex;
    }
    .nav-links a {
        width: 100%;
        padding: 12px;
    }
    .mapform {
        min-width: 0;
    }
}

/* v9: kompaktowe towarowanie, jeden wspólny arkusz aplikacji */
.slot-list-compact {
    display: block;
}
.shelf {
    margin: 10px 0;
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
}
.shelf-head {
    padding: 7px 12px;
    background: #edf3fb;
    font-weight: 700;
    font-size: 13px;
    color: #344a63;
}
.shelf-items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
}
.slot-compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 74px;
    grid-template-areas: 'name stock' 'controls controls';
    gap: 3px 8px;
    border: 0;
    border-bottom: 1px solid #e8edf3;
    border-radius: 0;
    padding: 9px 11px;
    min-width: 0;
}
.slot-compact:nth-child(odd) {
    border-right: 1px solid #e8edf3;
}
.slot-compact.changed {
    border: 0;
    border-bottom: 1px solid #8bbbe7;
    background: #f1f8ff;
    box-shadow: inset 3px 0 #0b75cf;
}
.slot-identity {
    grid-area: name;
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    font-size: 13px;
    line-height: 1.3;
}
.slot-mdb {
    flex: none;
    font-size: 15px;
    color: #153c66;
}
.slot-product {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.slot-double {
    flex: none;
    color: #62748a;
    font-size: 11px;
    border: 1px solid #d4deea;
    border-radius: 5px;
    padding: 0 3px;
}
.slot-stock {
    grid-area: stock;
    text-align: right;
    font-size: 15px;
    white-space: nowrap;
}
.slot-compact .controls {
    grid-area: controls;
    display: grid;
    grid-template-columns: 42px minmax(44px, 1fr) 42px 64px;
    gap: 5px;
    margin: 1px 0 0;
}
.slot-compact .controls button,
.slot-compact .controls input {
    margin: 0;
    min-height: 38px;
    height: 38px;
    padding: 4px;
    font-size: 18px;
}
.slot-compact .controls .fill {
    min-width: 0;
    font-size: 12px;
}
.slot-compact .controls input {
    width: 100%;
    font-size: 17px;
}
.slot-compact .controls button {
    min-width: 0;
}
.slot-compact .controls input::-webkit-inner-spin-button,
.slot-compact .controls input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.slot-compact .controls input[type='number'] {
    -moz-appearance: textfield;
}
@media (max-width: 700px) {
    .shelf-items {
        grid-template-columns: 1fr;
    }
    .slot-compact {
        grid-template-columns: minmax(0, 1fr) 68px;
        padding: 7px 9px;
    }
    .slot-compact:nth-child(odd) {
        border-right: 0;
    }
    .slot-compact .controls {
        grid-template-columns: 42px minmax(50px, 1fr) 42px 64px;
    }
    .slot-identity {
        font-size: 13px;
    }
    .slot-stock {
        font-size: 14px;
    }
}
/* v10: jeden rekord = jeden wiersz, także na telefonie */
.shelf-items {
    display: block;
}
.slot-compact,
.slot-compact:nth-child(odd) {
    display: grid;
    grid-template-columns: minmax(75px, 1fr) 68px 174px;
    grid-template-areas: 'name stock controls';
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-right: 0;
    min-height: 44px;
}
.slot-identity {
    align-items: center;
    gap: 4px;
    min-width: 0;
    font-size: 12px;
}
.slot-mdb {
    font-size: 13px;
    min-width: 20px;
}
.slot-product {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.slot-stock {
    font-size: 13px;
    text-align: center;
}
.slot-compact .controls {
    display: grid;
    grid-template-columns: 32px 50px 32px 48px;
    gap: 3px;
    margin: 0;
    align-items: center;
}
.slot-compact .controls button,
.slot-compact .controls input {
    height: 34px;
    min-height: 34px;
    padding: 2px 0;
    font-size: 16px;
}
.slot-compact .controls .fill {
    font-size: 11px;
}
@media (max-width: 700px) {
    .slot-compact,
    .slot-compact:nth-child(odd) {
        grid-template-columns: minmax(65px, 1fr) 52px 154px;
        grid-template-areas: 'name stock controls';
        gap: 4px;
        padding: 4px 5px;
        min-height: 42px;
    }
    .slot-identity {
        font-size: 11px;
        gap: 3px;
    }
    .slot-mdb {
        font-size: 12px;
        min-width: 17px;
    }
    .slot-stock {
        font-size: 12px;
    }
    .slot-compact .controls {
        grid-template-columns: 29px 43px 29px 44px;
        gap: 3px;
    }
    .slot-compact .controls button,
    .slot-compact .controls input {
        height: 34px;
        min-height: 34px;
        font-size: 15px;
    }
    .slot-compact .controls .fill {
        font-size: 10px;
    }
    .slot-double {
        font-size: 10px;
        padding: 0 2px;
    }
}
@media (max-width: 370px) {
    .slot-compact,
    .slot-compact:nth-child(odd) {
        grid-template-columns: minmax(52px, 1fr) 46px 142px;
        gap: 3px;
    }
    .slot-compact .controls {
        grid-template-columns: 27px 39px 27px 40px;
        gap: 3px;
    }
    .slot-compact .controls button,
    .slot-compact .controls input {
        height: 32px;
        min-height: 32px;
    }
    .slot-identity {
        font-size: 10px;
    }
    .slot-stock {
        font-size: 11px;
    }
}

/* v14: wspólny znacznik aktualności sprzedaży w nagłówku */
.header-brand {
    display: flex;
    align-items: baseline;
    gap: 10px 18px;
    flex-wrap: wrap;
}
.header-brand h1 {
    margin: 0;
}
.last-transaction {
    font-size: 13px;
    font-weight: 500;
    color: #e0eaf7;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .header-brand {
        gap: 3px 10px;
    }
    .last-transaction {
        font-size: 12px;
        white-space: normal;
    }
}

/* v15: oszczędne filtry i nagłówki tabel */
.filter-panel {
    padding: 9px 12px;
    margin: 9px 0;
}
.compact-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
}
.compact-filters label {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0;
    width: auto;
    min-width: 0;
    white-space: nowrap;
}
.compact-filters label span {
    font-size: 12px;
    font-weight: 600;
    color: #52647a;
}
.compact-filters input,
.compact-filters select {
    margin: 0;
    min-height: 36px;
    padding: 5px 8px;
    font-size: 13px;
}
.compact-filters input[type='date'] {
    width: 143px;
}
.compact-filters select {
    max-width: 185px;
}
.compact-filters button {
    min-height: 36px;
    margin: 0;
    padding: 6px 13px;
}
.table-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.table-heading h2,
.table-heading h3 {
    margin: 0;
}
.table-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.table-heading .table-filter {
    min-width: 0;
    width: clamp(130px, 20vw, 230px);
    min-height: 36px;
    margin: 0;
    padding: 6px 9px;
    font-size: 13px;
}
.csv-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 37px;
    height: 37px;
    flex: none;
    border: 1px solid #b9c7d7;
    border-radius: 8px;
    color: #175ba7;
    background: #eef3fa;
}
.csv-icon:hover {
    background: #dceaf9;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
section {
    margin-top: 10px;
    margin-bottom: 10px;
}
section .hint {
    margin: 7px 0;
}
.toolbar {
    gap: 6px;
}
.toolbar input,
.toolbar select,
.toolbar button {
    min-height: 37px;
}
.panel {
    margin: 9px 0;
}
@media (max-width: 700px) {
    .filter-panel {
        padding: 8px;
    }
    .compact-filters {
        gap: 6px;
    }
    .compact-filters label {
        width: auto;
        margin: 0;
        flex: 1 1 145px;
        justify-content: space-between;
    }
    .compact-filters label span {
        font-size: 11px;
    }
    .compact-filters input[type='date'] {
        width: 118px;
    }
    .compact-filters select {
        width: 125px;
        max-width: 125px;
    }
    .compact-filters button {
        width: auto;
        flex: 0 0 auto;
    }
    .table-heading {
        flex-wrap: nowrap;
        align-items: center;
    }
    .table-heading h2 {
        font-size: 15px;
        line-height: 1.25;
    }
    .table-heading h3 {
        font-size: 14px;
    }
    .table-heading .table-filter {
        width: 120px;
        min-width: 0;
    }
    .table-tools {
        gap: 4px;
    }
    .csv-icon {
        width: 35px;
        height: 35px;
    }
    .toolbar input,
    .toolbar select,
    .toolbar button {
        width: auto;
    }
    .toolbar input {
        flex: 1 1 160px;
    }
    .toolbar select {
        flex: 1 1 130px;
    }
    .toolbar button {
        flex: 0 0 auto;
    }
    .slot-compact {
        overflow: hidden;
    }
}
@media (max-width: 390px) {
    .compact-filters label {
        flex-basis: 100%;
    }
    .compact-filters input[type='date'],
    .compact-filters select {
        width: 60%;
        max-width: 60%;
    }
    .table-heading h2 {
        font-size: 14px;
    }
    .table-heading .table-filter {
        width: 100px;
    }
}

/* v16: jeden wspólny nagłówek, nawigacja i stopka */
.site-header {
    padding: 0;
    background: #172b4d;
}
.site-header-inner {
    max-width: 1320px;
    margin: auto;
    min-height: 58px;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.site-brand {
    font-size: 21px;
    font-weight: 750;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}
.site-brand:hover {
    color: #fff;
    text-decoration: underline;
}
.site-header .header-brand {
    gap: 8px 18px;
}
.site-header .app-logout {
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
}
.site-nav-wrap {
    background: #fff;
    border-bottom: 1px solid #dce2e9;
}
.site-nav-wrap .app-nav {
    max-width: 1320px;
    margin: 0 auto;
    padding: 5px 12px;
    border: 0;
    border-radius: 0;
}
.site-nav-wrap .nav-links {
    gap: 3px;
}
.site-nav-wrap .nav-links a {
    padding: 8px 11px;
    font-size: 13px;
}
.site-footer {
    max-width: 1320px;
    margin: 8px auto 0;
    padding: 14px 16px 24px;
    border-top: 1px solid #dce2e9;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
}
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main {
    flex: 1;
    width: 100%;
}
@media (max-width: 700px) {
    .site-header-inner {
        padding: 9px 12px;
        min-height: 54px;
    }
    .site-brand {
        font-size: 18px;
    }
    .site-header .last-transaction {
        font-size: 11px;
    }
    .site-header .app-logout {
        font-size: 12px;
    }
    .site-nav-wrap .app-nav {
        padding: 4px 10px;
    }
    .site-nav-wrap .nav-toggle {
        min-height: 34px;
        padding: 5px 10px;
    }
    .site-nav-wrap .nav-links a {
        padding: 10px;
    }
    .site-footer {
        padding: 12px;
        font-size: 11px;
        flex-wrap: wrap;
    }
}

/* v17: zwarty naglowek dokumentu magazynowego */
.warehouse-document .document-fields {
    display: grid;
    grid-template-columns:
        minmax(150px, 1.5fr) minmax(155px, 1.2fr) minmax(135px, 1fr) minmax(100px, 0.75fr)
        minmax(130px, 1fr) minmax(135px, 1.2fr);
    gap: 7px;
    align-items: center;
    margin: 9px 0 13px;
}
.warehouse-document .document-fields > input,
.warehouse-document .document-fields > select {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    height: 36px;
    margin: 0;
    padding: 5px 8px;
    font-size: 13px;
}
.warehouse-document .document-fields > input[type='date'] {
    min-width: 0;
}
@media (max-width: 1050px) {
    .warehouse-document .document-fields {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 600px) {
    .warehouse-document .document-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }
    .warehouse-document .document-fields > input,
    .warehouse-document .document-fields > select {
        min-height: 38px;
        height: 38px;
    }
    .warehouse-document .document-fields > input[name='note'] {
        grid-column: span 2;
    }
}

/* v18: jednakowa, zwarta wysokość wierszy tabeli dokumentu */
#bulk-table {
    table-layout: auto;
}
#bulk-table th,
#bulk-table td {
    padding: 5px 10px;
    line-height: 1.25;
    vertical-align: middle;
}
#bulk-table td:last-child,
#bulk-table th:last-child {
    width: 118px;
    text-align: right;
}
#bulk-table .qty-field {
    display: inline-block;
    box-sizing: border-box;
    width: 88px;
    max-width: 100%;
    height: 30px;
    min-height: 30px;
    margin: 0;
    padding: 3px 7px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 20px;
    text-align: right;
}
@media (max-width: 700px) {
    #bulk-table th,
    #bulk-table td {
        padding: 4px 5px;
    }
    #bulk-table td:last-child,
    #bulk-table th:last-child {
        width: 94px;
    }
    #bulk-table .qty-field {
        width: 78px !important;
        height: 32px;
        min-height: 32px;
    }
}
/* Import dostawy: kompaktowy przycisk w nagłówku tabeli */
.import-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    background: var(--surface, #fff);
    color: inherit;
}
.import-button:hover {
    filter: brightness(0.96);
}
.import-result {
    font-size: 12px;
    margin: 3px 0 7px;
    color: var(--muted, #64748b);
}
.import-result:empty {
    display: none;
}

/* v21 dokumenty i lokalny asortyment */
.document-row {
    cursor: pointer;
}
.document-row:hover {
    background: #edf5ff;
}
.document-row[aria-expanded='true'] {
    background: #e8f1ff;
    font-weight: 600;
}
.document-detail td {
    background: #f8fbff;
}
.document-detail-content {
    padding: 7px 4px;
}
.document-detail-content table {
    max-width: 850px;
}
.warehouse-document[hidden],
.document-detail[hidden] {
    display: none !important;
}
.track-form {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
}
.track-form button {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 12px;
}
.track-toggle {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.track-toggle input {
    min-height: 0;
    width: 16px;
    height: 16px;
}
.warehouse-document #bulk-table tr[hidden] {
    display: none !important;
}

/* v23: lista dokumentów, filtry dat i osobny panel pozycji */
.document-period {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}
.document-period input {
    width: 145px;
    min-height: 32px;
    padding: 4px 6px;
}
.document-period button {
    min-height: 32px;
    padding: 4px 10px;
}
.selected-document {
    margin-top: 12px;
    border-top: 1px solid #dce4ee;
    padding-top: 10px;
}
.selected-document[hidden] {
    display: none !important;
}
.document-row[aria-selected='true'] {
    background: #e8f1ff;
    font-weight: 600;
}
.selected-document table {
    width: 100%;
}
@media (max-width: 640px) {
    .document-period {
        order: 3;
        width: 100%;
        margin-left: 0;
    }
    .document-period input {
        flex: 1;
        min-width: 112px;
        width: auto;
    }
    .document-period button {
        flex: 0 0 auto;
    }
}

.skip-link {
    position: fixed;
    top: -100px;
    left: 12px;
    z-index: 100;
    background: #fff;
    padding: 12px;
    border: 2px solid #1959a5;
}
.skip-link:focus {
    top: 12px;
}
.auth-card {
    width: min(100%, 460px);
    margin: clamp(24px, 8vh, 90px) auto;
    padding: 28px;
    box-shadow: 0 12px 40px #172b4d0d;
}
.auth-card h1 {
    font-size: 28px;
    margin: 8px 0 22px;
}
.auth-card label {
    display: flex;
    margin: 14px 0;
    gap: 7px;
}
.auth-card input,
.auth-card button {
    width: 100%;
    margin: 0;
}
.auth-card button {
    margin-top: 12px;
}
.auth-card p {
    line-height: 1.6;
}
.eyebrow {
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.14em;
    color: #52647a;
}
.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.user-menu > a {
    color: #fff;
    overflow-wrap: anywhere;
}
.user-menu form {
    margin: 0;
}
.user-menu button {
    background: transparent;
    border-color: #ffffff66;
    color: #fff;
    min-height: 40px;
    font-size: 13px;
}
.user-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    align-items: end;
}
.user-fields label {
    margin: 0;
}
.user-fields input,
.user-fields select {
    width: 100%;
    margin: 0;
}
.user-fields .check-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}
.user-fields input[type='checkbox'] {
    width: 20px;
    min-height: 20px;
}
.scroll {
    overscroll-behavior-x: contain;
}
.site-header-inner,
.header-brand {
    min-width: 0;
}
@media (max-width: 700px) {
    .table-heading {
        flex-wrap: wrap;
    }
    .table-tools {
        max-width: 100%;
    }
    .topline {
        flex-wrap: wrap;
    }
    .site-header-inner {
        flex-wrap: wrap;
    }
    .user-menu {
        width: 100%;
        justify-content: space-between;
        font-size: 13px;
    }
    .auth-card {
        padding: 22px 18px;
        margin: 24px auto;
    }
    .auth-card input {
        font-size: 16px;
    }
    .user-fields {
        grid-template-columns: minmax(0, 1fr);
    }
    .user-fields label {
        width: 100%;
    }
    .site-footer {
        width: 100%;
    }
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

/* Wspólna gęstość tabel i formularzy w widokach danych. */
.compact-ui {
    --control-height: 34px;
    --cell-space: 6px 8px;
    font-size: 14px;
}
.compact-ui section,
.compact-ui .panel {
    padding: 12px;
    margin: 8px 0;
}
.compact-ui h1 {
    font-size: 20px;
    line-height: 1.3;
    margin: 0 0 8px;
}
.compact-ui h2 {
    font-size: 16px;
    line-height: 1.3;
    margin: 0 0 8px;
}
.compact-ui h3 {
    font-size: 14px;
    margin: 0 0 6px;
}
.compact-ui p {
    margin: 6px 0;
    line-height: 1.4;
}
.compact-ui table {
    font-size: 13px;
    line-height: 1.3;
}
.compact-ui th,
.compact-ui td {
    padding: var(--cell-space);
    vertical-align: middle;
}
.compact-ui tfoot {
    background: #eef3fa;
}
.compact-ui input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
.compact-ui select,
.compact-ui button {
    min-height: var(--control-height);
    padding: 5px 8px;
    margin: 0;
    font-size: 13px;
    border-radius: 6px;
}
.compact-ui input[type='checkbox'],
.compact-ui input[type='radio'] {
    appearance: auto;
    width: 16px;
    height: 16px;
    min-height: 0;
    padding: 0;
    margin: 0;
    flex: 0 0 16px;
    vertical-align: middle;
}
.compact-ui label {
    font-size: 12px;
    margin: 0;
    gap: 3px;
    min-width: 0;
}
.compact-ui .track-toggle {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-height: var(--control-height);
    width: auto;
}
.compact-ui .toolbar,
.compact-ui .fields {
    gap: 6px 10px;
    align-items: end;
}
.compact-ui .toolbar {
    margin-bottom: 8px;
}
.compact-ui .toolbar > label {
    flex: 0 1 auto;
}
.compact-ui .toolbar input[type='file'] {
    max-width: 230px;
}
.compact-ui .table-heading {
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.compact-ui .table-heading h1,
.compact-ui .table-heading h2,
.compact-ui .table-heading .toolbar {
    margin: 0;
}
.compact-ui .hint {
    font-size: 12px;
}
.compact-ui .page-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}
.compact-ui .page-heading h1 {
    margin: 0;
}
.compact-ui .page-heading details {
    font-size: 12px;
    max-width: 620px;
}
.compact-ui summary {
    cursor: pointer;
    color: #175ba7;
}
.compact-ui .location-settings-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto auto;
    align-items: end;
    gap: 10px;
    border-top: 1px solid #e2e8f0;
    padding: 6px 0;
}
.compact-ui .location-settings-row > label:first-of-type input {
    width: 100%;
}
.compact-ui .device-settings-row {
    display: grid;
    grid-template-columns: minmax(140px, 1.2fr) minmax(160px, 1.5fr) 105px 120px;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #e2e8f0;
    padding: 6px 0;
}
.compact-ui .device-settings-row > strong {
    font-size: 13px;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.compact-ui .device-settings-row select {
    width: 100%;
}
.compact-ui .device-settings .table-heading {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    padding: 4px 0;
}
.compact-ui .sync-panel {
    width: 100%;
    max-width: none;
    margin: 8px 0;
}
.compact-ui .sync-row {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) auto;
    gap: 12px;
    align-items: center;
    border-top: 1px solid #e2e8f0;
    padding: 7px 0;
}
.compact-ui .sync-row:last-child {
    padding-bottom: 0;
}
.compact-ui .sync-row h2 {
    display: inline;
    font-size: 14px;
    margin: 0 10px 0 0;
}
.compact-ui .sync-row p {
    display: inline;
    font-size: 12px;
    color: #64748b;
    margin: 0;
}
.compact-ui .sync-row button {
    min-width: 135px;
    white-space: nowrap;
}
.compact-ui .deposit-row {
    background: #f2f7fc;
}
.compact-ui input[aria-label^='Zaznacz'] {
    cursor: pointer;
}
@media (max-width: 700px) {
    .compact-ui {
        --control-height: 38px;
        --cell-space: 5px 7px;
    }
    .compact-ui section,
    .compact-ui .panel {
        padding: 10px;
    }
    .compact-ui .toolbar {
        flex-wrap: wrap;
    }
    .compact-ui .toolbar > label {
        flex: 1 1 145px;
        width: auto;
    }
    .compact-ui .toolbar > label input,
    .compact-ui .toolbar > label select {
        width: 100%;
    }
    .compact-ui .toolbar input[type='file'] {
        max-width: 100%;
    }
    .compact-ui .toolbar > input,
    .compact-ui .toolbar > select {
        min-width: 0;
    }
    .compact-ui .location-settings-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 8px;
        align-items: center;
    }
    .compact-ui .location-settings-row > label:first-of-type {
        grid-column: 1/-1;
    }
    .compact-ui .location-settings-row button {
        justify-self: end;
    }
    .compact-ui .device-settings-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 4px 8px;
    }
    .compact-ui .device-settings-row > strong {
        grid-column: 1/-1;
    }
    .compact-ui .device-settings-row > label:not(.track-toggle) {
        grid-column: 1/-1;
        width: 100%;
    }
    .compact-ui .page-heading {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 4px;
    }
    .compact-ui .sync-row p {
        display: block;
        margin-top: 2px;
        line-height: 1.3;
    }
    .compact-ui .sync-row button {
        min-width: 0;
        width: 135px;
    }
    .compact-ui .scroll table:not(#bulk-table):not(#tx) {
        min-width: 520px;
    }
    .compact-ui #deposit-products table {
        min-width: 360px;
    }
}
@media (max-width: 360px) {
    .compact-ui .sync-row {
        gap: 6px;
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .compact-ui .sync-row button {
        width: 118px;
        font-size: 12px;
    }
    .compact-ui .sync-row p {
        max-width: 150px;
    }
}

/* Produkty objęte kaucją; osobna pozycja rozliczeniowa zachowuje swój kolor. */
.compact-ui tr.deposit-product-row > td {
    background: #fff9e9;
}
.compact-ui tr.deposit-product-row:hover > td {
    background: #fff3d2;
}
.compact-ui .menu-permissions {
    grid-column: 1/-1;
    min-width: 0;
    border: 1px solid #dce2e9;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 0;
}
.compact-ui .menu-permissions legend {
    font-weight: 600;
    font-size: 13px;
    padding: 0 4px;
}
.compact-ui .menu-permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2px 12px;
}

/* Towarowanie korzysta z tych samych rozmiarów pól i obramowań. */
button,
input,
select {
    border-radius: 6px;
}
.device-view {
    font-size: 14px;
}
.device-view .filling-picker {
    padding: 8px 10px;
    margin: 8px 0;
}
.filling-picker form {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.filling-picker label {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    font-size: 13px;
}
.filling-picker select {
    flex: 1;
    min-width: 0;
    width: 100%;
    margin: 0;
}
.device-view .filling-picker button,
.device-view .filling-picker select,
.device-view .filling-actions button {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 13px;
    margin: 0;
    border-width: 1px;
    border-radius: 6px;
}
.filling-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 6px 0;
}
.filling-actions .hint {
    margin-left: auto;
    font-size: 11px;
}
.device-view .slot-compact .controls button,
.device-view .slot-compact .controls input {
    border-width: 1px;
    border-radius: 5px;
}
.device-view .shelf {
    padding: 0;
}
.device-view .sticky button {
    border-radius: 6px;
    padding: 6px 10px;
    min-height: 38px;
    font-size: 14px;
}
@media (max-width: 700px) {
    .device-view .filling-picker {
        padding: 6px 8px;
        margin: 6px 0;
    }
    .filling-picker form {
        gap: 6px;
    }
    .device-view .filling-picker select {
        font-size: 16px;
        min-height: 38px;
    }
    .device-view .filling-picker button {
        flex: none;
        width: auto;
        min-height: 38px;
    }
    .filling-actions {
        margin: 4px 0;
        gap: 5px;
    }
    .filling-actions .hint {
        font-size: 10px;
    }
    .device-view .shelf {
        margin: 6px 0;
    }
    .device-view .shelf-head {
        padding: 4px 8px;
        font-size: 12px;
    }
    .device-view .sticky {
        padding: 7px 10px max(7px, env(safe-area-inset-bottom));
        gap: 8px;
    }
}
@media (max-width: 360px) {
    .filling-picker label {
        font-size: 12px;
    }
    .filling-actions .hint {
        flex-basis: 100%;
        margin-left: 0;
    }
}

/* Wspólny stan sortowania; nagłówki obsługują również Enter i spację. */
.sortable th[aria-sort] {
    cursor: pointer;
    user-select: none;
}
.sortable th[aria-sort='ascending']::after {
    content: ' ↑';
    color: #175ba7;
}
.sortable th[aria-sort='descending']::after {
    content: ' ↓';
    color: #175ba7;
}
.sortable th[aria-sort]:focus-visible {
    outline: 2px solid #78b8f3;
    outline-offset: -2px;
}
.compact-ui .scroll + .hint {
    margin-top: 6px;
}
.compact-ui .table-filter {
    min-height: 34px;
    margin-bottom: 6px;
}

.sortable th:not([aria-sort]) {
    cursor: default;
}

/* Wspólne dynamiczne filtry i akcje wiersza. */
.quick-dates,.row-actions{display:flex;align-items:center;gap:6px;flex-wrap:nowrap}
.row-actions form{margin:0}.button{display:inline-flex;align-items:center;justify-content:center;min-height:34px;padding:5px 8px;border:1px solid #1959a5;border-radius:6px;background:#1959a5;color:#fff;text-decoration:none;font-size:13px;font-weight:650;white-space:nowrap}
.compact-ui .button{min-height:var(--control-height)}
.device-view .slot-compact.stock-critical,.machine-slot.stock-critical,.stock-legend .stock-critical{background:#fff0f2}
.device-view .slot-compact.stock-low,.machine-slot.stock-low,.stock-legend .stock-low{background:#fff9e3}
.stock-legend{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0;font-size:12px}
.stock-legend>span{padding:4px 8px;border:1px solid #e2e8f0;border-radius:5px}
.planogram-scroll{overflow-x:auto;padding-bottom:6px;overscroll-behavior-x:contain}
.machine-planogram{min-width:0;width:100%;background:#f1f4f8;border:1px solid #dce2e9;border-radius:6px;padding:6px}
.machine-shelf+.machine-shelf{margin-top:7px}
.machine-shelf h2{font-size:11px;margin:0 0 4px;color:#52647a}
.machine-grid{display:grid;gap:4px;align-items:stretch}
.machine-slot{min-width:0;padding:5px;background:#fff;border:1px solid #dce2e9;border-radius:4px;display:flex;flex-direction:column;gap:4px}
.machine-position{display:flex;align-items:center;justify-content:space-between;gap:4px;flex-wrap:nowrap;font-size:11px;line-height:1.2;color:#52647a;white-space:nowrap}
.machine-product{font-size:11px;font-weight:700;line-height:1.3;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
.machine-footer{display:flex;align-items:center;justify-content:space-between;gap:5px;margin-top:auto;min-width:0;line-height:1.2}
.machine-footer small{font-size:9px;color:#64748b;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.machine-footer strong{flex:none;white-space:nowrap;font-size:10px;color:#344a63}
@media(max-width:700px){.machine-planogram{padding:4px}.machine-grid{gap:4px}}
.button:hover{background:#124781;color:#fff}.button.secondary{background:#fff;color:#175ba7}
.compact-ui .row-actions button{white-space:nowrap}.live-status:empty{display:none}
#content[aria-busy=true] .scroll{opacity:.65}.history-panels details+details{border-top:1px solid #e2e8f0;margin-top:8px;padding-top:8px}.history-panels summary{font-weight:600;font-size:14px}.history-panels details[open] summary{margin-bottom:10px}
@media(max-width:700px){.quick-dates{flex-wrap:wrap}.compact-ui .compact-filters .quick-dates button{width:auto;flex:none}.row-actions{gap:4px}}

/* Krótkie, jednoliniowe filtry raportów; na mniejszych ekranach zawijane grupami. */
.device-view .filling-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}
.filling-picker form {
    flex: 0 1 380px;
    min-width: 0;
}
.filling-picker .filling-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin: 0;
}
@media (max-width: 480px) {
    .device-view .filling-picker { gap: 6px; }
    .filling-picker form { flex: 1 1 auto; }
    .filling-picker label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
.compact-ui .report-filters {
    gap: 5px 8px;
    align-items: center;
}
.compact-ui .report-filters label {
    width: auto;
    flex: 0 0 auto;
    gap: 4px;
    white-space: nowrap;
}
.compact-ui .report-filters input[type='date'] {
    width: 112px;
    max-width: 112px;
    min-width: 0;
    padding: 4px 5px;
    font-size: 12px;
}
.compact-ui .report-filters select {
    width: 132px;
    max-width: 132px;
    padding: 4px 6px;
    font-size: 12px;
}
.compact-ui .report-filters select[name='deposit_filter'] {
    width: 122px;
}
.compact-ui .report-filters button {
    font-size: 12px;
    padding: 4px 7px;
    white-space: nowrap;
}
.report-filters .quick-dates {
    gap: 4px;
    flex-wrap: nowrap;
}
@media (min-width: 1200px) {
    .compact-ui .report-filters { flex-wrap: nowrap; }
}
