:root {
    --green: #28A745;
    --green-dark: #1d7f35;
    --dark: #212529;
    --muted: #6c757d;
    --bg: #F8F9FA;
    --panel: #ffffff;
    --border: #dfe4ea;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0d6efd;
    --shadow: 0 18px 45px rgba(33, 37, 41, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--dark);
    background: var(--bg);
}

a { color: inherit; }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(40, 167, 69, .18), transparent 30%),
        linear-gradient(135deg, #f8f9fa 0%, #edf3ef 100%);
}

.login-card {
    width: min(430px, 100%);
    background: var(--panel);
    padding: 34px;
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.login-logo { width: 190px; height: auto; display: block; margin-bottom: 16px; }
.login-card h1 { margin: 0; font-size: 30px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; line-height: 1.45; }

.form-grid { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 650; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 13px;
    background: #fff;
    color: var(--dark);
    font: inherit;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(40, 167, 69, .18);
    border-color: var(--green);
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 11px 18px;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    transition: .15s ease;
    background: #fff;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn:disabled { opacity: .65; cursor: wait; }
.btn-gus { min-height: 42px; padding-inline: 16px; white-space: nowrap; box-shadow: 0 8px 18px rgba(40, 167, 69, .18); }
.btn-outline { border-color: var(--border); color: var(--dark); }
.btn-outline:hover { border-color: var(--green); color: var(--green-dark); }
.btn-danger { color: var(--danger); border-color: rgba(220, 53, 69, .25); }
.btn-mini { min-height: 32px; padding: 7px 11px; font-size: 12px; }
.icon-button { border: 0; background: transparent; font-size: 24px; cursor: pointer; display: none; }

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin: 16px 0;
    font-weight: 650;
}
.alert-error { background: #ffecef; color: #8a1020; border: 1px solid #ffc7d0; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 290px 1fr;
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}
.brand { display: block; padding: 10px 8px 18px; }
.brand img { width: 190px; max-width: 100%; }

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.main-nav a, .nav-group summary {
    width: 100%;
    border-radius: 12px;
    padding: 10px 12px;
    text-decoration: none;
}
.main-nav a {
    color: #35404a;
    display: block;
    line-height: 1.22;
}
.main-nav a:hover, .main-nav a.active { background: rgba(40, 167, 69, .1); color: var(--green-dark); }
.main-nav a.disabled { opacity: .48; cursor: not-allowed; }
.nav-direct { font-weight: 800; }
.nav-group {
    border: 1px solid transparent;
    border-radius: 15px;
    overflow: hidden;
}
.nav-group[open] {
    background: rgba(248, 249, 250, .95);
    border-color: var(--border);
}
.nav-group summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    color: #35404a;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after {
    content: '›';
    flex: 0 0 auto;
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    color: var(--muted);
    transition: transform .16s ease;
}
.nav-group[open] summary::after { transform: rotate(90deg); color: var(--green-dark); }
.nav-group summary:hover { background: rgba(40, 167, 69, .08); color: var(--green-dark); }
.nav-group-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 2px 6px 9px;
}
.nav-group-links a {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 8px 10px 8px 24px;
    font-size: 14px;
    white-space: normal;
}

.main-content { min-width: 0; }
.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-end;
    padding: 14px 26px;
    background: rgba(248, 249, 250, .82);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.userbox { display: grid; text-align: right; }
.userbox span { color: var(--muted); font-size: 13px; }
.content-area { padding: 28px; }

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 22px;
}
.page-head h1 { margin: 0 0 6px; font-size: clamp(28px, 3vw, 42px); }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.card, .panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card { padding: 20px; }
.card-kicker { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.card strong { display: block; font-size: 42px; line-height: 1.1; margin: 7px 0; }
.card p { margin: 0; color: var(--muted); }
.panel { padding: 20px; margin-bottom: 18px; }
.panel h2 { margin-top: 0; }

.timeline { display: grid; gap: 10px; }
.timeline div { display: flex; gap: 12px; align-items: center; }
.timeline b {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(40, 167, 69, .12);
    color: var(--green-dark);
    display: inline-grid;
    place-items: center;
}

.table-wrap { overflow-x: auto; }
.table-search { max-width: 340px; margin-bottom: 14px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.data-table th { white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.data-table small { color: var(--muted); }
.table-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.contractor-actions {
    min-width: 172px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
}
.contractor-actions .btn-action {
    width: 100%;
    min-height: 36px;
    padding: 8px 11px;
    border-radius: 10px;
    justify-content: flex-start;
    font-size: 12.5px;
    line-height: 1.15;
    font-weight: 850;
    box-shadow: 0 4px 12px rgba(33, 37, 41, .08);
    white-space: nowrap;
}
.contractor-actions .btn-action::before {
    display: inline-grid;
    place-items: center;
    width: 19px;
    height: 19px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 900;
    background: rgba(255,255,255,.22);
    flex: 0 0 19px;
}
.btn-action-gus { background: var(--green); color: #fff; border-color: var(--green); }
.btn-action-gus::before { content: "↻"; }
.btn-action-gus:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-action-edit { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-action-edit::before { content: "✎"; }
.btn-action-edit:hover { background: #111820; border-color: #111820; }
.btn-action-delete { background: #fff1f2; color: #b42318; border-color: #f3b7bd; }
.btn-action-delete::before { content: "×"; background: rgba(180, 35, 24, .12); }
.btn-action-delete:hover { background: #dc3545; color: #fff; border-color: #dc3545; }
.btn-action-delete:hover::before { background: rgba(255,255,255,.25); }
.empty { text-align: center; color: var(--muted); padding: 36px !important; }
.row-cancelled { opacity: .68; text-decoration: line-through; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 800;
    background: #eef2f7;
    color: #44515d;
    white-space: nowrap;
}
.badge-ksef { background: rgba(13, 110, 253, .12); color: #0a58ca; }
.badge-nowa { background: rgba(255, 193, 7, .18); color: #8a6200; }
.badge-zadekretowana { background: rgba(13, 110, 253, .12); color: #0a58ca; }
.badge-przekazana-pracownikowi { background: rgba(40, 167, 69, .14); color: var(--green-dark); }
.badge-opisana { background: rgba(40, 167, 69, .2); color: var(--green-dark); }
.badge-wykreslona { background: rgba(220, 53, 69, .12); color: #a51d2a; }
.badge-anulowany { background: rgba(220, 53, 69, .12); color: #a51d2a; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(33, 37, 41, .55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20;
}
.modal.is-open { display: flex; }
.modal-card {
    width: min(560px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 22px;
    padding: 24px;
    position: relative;
    box-shadow: 0 25px 60px rgba(0,0,0,.22);
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: 0;
    background: #f1f3f5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
}
.form-message { margin: 0; font-weight: 700; }
.form-message.ok { color: var(--green-dark); }
.form-message.error { color: var(--danger); }
.hidden { display: none !important; }

code {
    background: #f1f3f5;
    border-radius: 7px;
    padding: 2px 6px;
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 30;
        width: 290px;
        transform: translateX(-105%);
        transition: .2s ease;
        box-shadow: var(--shadow);
    }
    .sidebar.is-open { transform: translateX(0); }
    .icon-button { display: inline-grid; place-items: center; }
    .topbar { justify-content: space-between; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-head { flex-direction: column; }
    .actions { justify-content: flex-start; }
}

@media (max-width: 640px) {
    .content-area { padding: 18px; }
    .cards { grid-template-columns: 1fr; }
    .topbar { padding: 12px 16px; }
    .userbox { display: none; }
    .login-card { padding: 24px; }
}

@media print {
    .sidebar, .topbar, .actions, .btn, .table-search { display: none !important; }
    .app-shell { display: block; }
    .content-area { padding: 0; }
    .panel, .card { box-shadow: none; border-color: #999; }
}

/* Kontrahenci — MultiNIP / antyduplikat */
.monitor-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}
.monitor-head h2 { margin-bottom: 6px; }
.monitor-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 9px 12px;
    font-weight: 750;
    white-space: nowrap;
}
.stat-pill b { color: var(--green-dark); }
.stat-pill.danger b { color: var(--danger); }
.monitor-details {
    border-top: 1px solid var(--border);
    margin-top: 14px;
    padding-top: 12px;
}
.monitor-details summary {
    cursor: pointer;
    font-weight: 850;
    color: var(--green-dark);
}
.monitor-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}
.monitor-item {
    background: rgba(40, 167, 69, .06);
    border: 1px solid rgba(40, 167, 69, .18);
    border-radius: 14px;
    padding: 12px;
}
.monitor-item.danger {
    background: rgba(220, 53, 69, .06);
    border-color: rgba(220, 53, 69, .18);
}
.monitor-item ul { margin: 8px 0 0; padding-left: 18px; }
.monitor-item li { margin: 4px 0; }
.badge-ok { background: rgba(40, 167, 69, .13); color: var(--green-dark); }
.badge-warning { background: rgba(255, 193, 7, .22); color: #7a5700; }
.badge-danger { background: rgba(220, 53, 69, .12); color: #a51d2a; }
.info-box {
    border: 1px solid rgba(13, 110, 253, .18);
    background: rgba(13, 110, 253, .06);
    border-radius: 14px;
    padding: 12px 14px;
    color: #24415f;
    line-height: 1.45;
}
.form-two-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.modal-card-wide { width: min(680px, 100%); }

@media (max-width: 760px) {
    .monitor-head { flex-direction: column; }
    .monitor-stats { justify-content: flex-start; }
    .form-two-cols { grid-template-columns: 1fr; }
}

.form-section-title {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-top: 2px;
}
.input-with-button {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}
.input-with-button input { width: 100%; }
.contractor-company-fields { align-items: end; }
@media (max-width: 760px) {
    .input-with-button { grid-template-columns: 1fr; }
}

/* Kontrahenci — zwarta tabela + paginacja */
.compact-monitor {
    padding: 16px 18px;
}
.compact-monitor .monitor-head h2 {
    margin-bottom: 4px;
}
.compact-monitor .monitor-head p {
    margin: 0;
}
.contractor-table-panel {
    padding: 18px;
}
.contractor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}
.contractor-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 260px;
}
.contractor-search-input {
    max-width: 520px;
    margin: 0;
}
.btn-compact {
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.date-filter-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}
.date-filter-inline input[type="date"] {
    width: 155px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 10px;
}
.per-page-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}
.per-page-control select {
    width: auto;
    min-width: 78px;
    padding: 8px 10px;
    border-radius: 10px;
}
.pagination-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 13px;
}
.contractors-table {
    table-layout: fixed;
    font-size: 13px;
}
.contractors-table th,
.contractors-table td {
    padding: 9px 10px;
    vertical-align: middle;
}
.contractors-table tbody tr:hover {
    background: rgba(40, 167, 69, .035);
}
.contractors-table th:nth-child(1) { width: 78px; }
.contractors-table th:nth-child(2) { width: 31%; }
.contractors-table th:nth-child(3) { width: 18%; }
.contractors-table th:nth-child(4) { width: 25%; }
.contractors-table th:nth-child(5) { width: 132px; }
.contractors-table th:nth-child(6) { width: 218px; }
.contractor-id-cell b,
.contractor-name-cell b {
    display: block;
    line-height: 1.25;
}
.contractor-id-cell small,
.contractor-name-cell small {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
}
.contractor-identifiers,
.contractor-address-cell {
    overflow-wrap: anywhere;
    line-height: 1.3;
}
.contractor-monitor-cell .badge {
    padding: 4px 8px;
    font-size: 11.5px;
}
.contractors-table .contractor-actions {
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 6px;
}
.contractors-table .contractor-actions .btn-action {
    width: 100%;
    min-height: 31px;
    padding: 7px 8px;
    border-radius: 9px;
    justify-content: center;
    font-size: 11.5px;
    line-height: 1;
    box-shadow: none;
}
.contractors-table .contractor-actions .btn-action::before {
    width: 16px;
    height: 16px;
    font-size: 11px;
    border-radius: 5px;
    flex-basis: 16px;
}
.contractors-table .contractor-actions .btn-action-edit:first-child,
.contractors-table .contractor-actions .btn-action-delete:nth-child(2) {
    grid-column: span 1;
}
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.pagination-info {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}
.pagination-pages {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}
.pagination-pages a,
.pagination-pages span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    text-decoration: none;
    color: var(--dark);
    font-size: 13px;
    font-weight: 800;
}
.pagination-pages a:hover {
    border-color: rgba(40, 167, 69, .45);
    background: rgba(40, 167, 69, .07);
}
.pagination-pages .active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}
.pagination-pages .disabled {
    opacity: .45;
    cursor: not-allowed;
}
.pagination-pages .ellipsis {
    border-color: transparent;
    background: transparent;
    min-width: auto;
}
@media (max-width: 1180px) {
    .contractors-table { min-width: 980px; }
}
@media (max-width: 760px) {
    .contractor-toolbar,
    .pagination-bar {
        align-items: stretch;
        flex-direction: column;
    }
    .contractor-search-box {
        min-width: 0;
    }
    .contractor-search-input {
        max-width: none;
    }
    .pagination-pages {
        justify-content: flex-start;
    }
}

/* VERTIS 2.0 — Kontrahenci: tabela kompaktowa v2 */
.contractors-table th:nth-child(1) { width: 78px; }
.contractors-table th:nth-child(2) { width: 31%; }
.contractors-table th:nth-child(3) { width: 20%; }
.contractors-table th:nth-child(4) { width: auto; }
.contractors-table th:nth-child(5) { width: 258px; text-align: right; }
.contractors-table td:nth-child(5) { text-align: right; }
.contractor-name-cell b {
    margin-bottom: 1px;
}
.contractor-inline-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.contractor-inline-badges .badge {
    padding: 3px 8px;
    font-size: 11.5px;
}
.contractors-table .contractor-actions {
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    flex-wrap: nowrap;
}
.contractors-table .contractor-actions .btn-action {
    width: auto;
    min-width: 74px;
    min-height: 34px;
    padding: 8px 11px;
    border-radius: 10px;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    box-shadow: none;
    white-space: nowrap;
}
.contractors-table .contractor-actions .btn-action-gus {
    min-width: 64px;
}
.contractors-table .contractor-actions .btn-action-edit {
    min-width: 78px;
}
.contractors-table .contractor-actions .btn-action-delete {
    min-width: 72px;
}
.pagination-bar.pagination-top {
    margin: 4px 0 10px;
    padding: 0 0 10px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
}
.pagination-bar.pagination-bottom {
    margin-top: 12px;
}
@media (max-width: 1180px) {
    .contractors-table { min-width: 1040px; }
}

/* VERTIS 2.0 — Kontrahenci: kompakt v3 + raport w modalu */
.compact-monitor {
    padding: 13px 16px;
    margin-bottom: 12px;
}
.compact-monitor .monitor-head {
    align-items: center;
}
.compact-monitor .monitor-head h2 {
    font-size: 17px;
    margin: 0 0 2px;
}
.compact-monitor .monitor-head p {
    font-size: 13px;
}
.stat-pill-button {
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: .15s ease;
}
.stat-pill-button:hover {
    border-color: rgba(40, 167, 69, .42);
    background: rgba(40, 167, 69, .07);
    transform: translateY(-1px);
}
.stat-pill-button.danger:hover {
    border-color: rgba(220, 53, 69, .35);
    background: rgba(220, 53, 69, .06);
}
.contractor-table-panel {
    padding: 14px 16px;
}
.contractor-toolbar {
    margin-bottom: 8px;
}
.pagination-topline {
    margin-bottom: 8px;
}
.contractors-table {
    table-layout: fixed;
    font-size: 12.8px;
}
.contractors-table th,
.contractors-table td {
    padding: 7px 9px !important;
    vertical-align: middle;
}
.contractors-table th:nth-child(1) { width: 76px; }
.contractors-table th:nth-child(2) { width: 35%; }
.contractors-table th:nth-child(3) { width: 21%; }
.contractors-table th:nth-child(4) { width: auto; }
.contractors-table th:nth-child(5) { width: 252px; text-align: right; }
.contractors-table td:nth-child(5) { text-align: right; }
.contractor-id-cell b {
    font-size: 13px;
    line-height: 1.1;
}
.contractor-id-cell small {
    margin-top: 1px;
    font-size: 11px;
    line-height: 1.1;
}
.contractor-name-cell b {
    display: inline;
    margin: 0;
    line-height: 1.15;
}
.contractor-name-cell small {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    line-height: 1.15;
}
.contractor-name-line {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    line-height: 1.15;
}
.contractor-name-line .badge {
    padding: 2px 7px;
    font-size: 10.8px;
    line-height: 1.2;
}
.badge-button {
    border: 0;
    cursor: pointer;
    font-family: inherit;
}
.badge-button:hover {
    filter: brightness(.97);
    box-shadow: 0 0 0 2px rgba(40, 167, 69, .08);
}
.contractor-identifiers,
.contractor-address-cell {
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.contractor-actions-cell {
    text-align: right;
    white-space: nowrap;
}
.contractor-action-row {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
    width: 100%;
}
.contractor-action-row .btn-action {
    width: auto;
    min-height: 30px;
    padding: 6px 9px;
    border-radius: 9px;
    justify-content: center;
    font-size: 11.5px;
    line-height: 1;
    box-shadow: none;
    white-space: nowrap;
}
.contractor-action-row .btn-action::before {
    width: 15px;
    height: 15px;
    font-size: 10px;
    border-radius: 5px;
    flex-basis: 15px;
}
.contractor-action-row .btn-action-gus { min-width: 58px; }
.contractor-action-row .btn-action-edit { min-width: 70px; }
.contractor-action-row .btn-action-delete { min-width: 66px; }
.pagination-bar.pagination-top {
    margin: 2px 0 8px;
    padding: 0 0 8px;
}
.pagination-bar.pagination-bottom {
    margin-top: 8px;
    padding-top: 8px;
}
.pagination-pages a,
.pagination-pages span {
    min-height: 31px;
    min-width: 31px;
    padding: 6px 9px;
}
.modal-card-monitoring {
    width: min(920px, 100%);
}
.monitor-modal-section {
    border-top: 1px solid var(--border);
    margin-top: 16px;
    padding-top: 14px;
}
.monitor-modal-section h3 {
    margin: 0 0 10px;
    font-size: 16px;
}
.monitor-report-list {
    display: grid;
    gap: 10px;
}
.monitor-report-item {
    border: 1px solid rgba(40, 167, 69, .18);
    background: rgba(40, 167, 69, .045);
    border-radius: 14px;
    padding: 11px 12px;
}
.monitor-report-item.danger {
    border-color: rgba(220, 53, 69, .18);
    background: rgba(220, 53, 69, .045);
}
.monitor-report-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
}
.monitor-report-item p {
    margin: 4px 0 0;
}
.monitor-report-item ul {
    margin: 8px 0 0;
    padding-left: 18px;
}
.monitor-report-item li {
    margin: 3px 0;
    line-height: 1.3;
}
.empty-inline {
    color: var(--muted);
    margin: 0;
}
.monitor-limit-note {
    margin-top: 14px;
}
@media (max-width: 1180px) {
    .contractors-table { min-width: 1060px; }
}
.stat-pill-button,
.badge-button {
    text-decoration: none;
}


/* VERTIS 2.0 — poprawka kontrolek: GUS bez zmiany etykiety, X w modalu i Usuń */
.btn[aria-busy="true"] {
    cursor: wait;
    opacity: .72;
}

.modal-close,
a.modal-close,
button.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    padding: 0 !important;
    border: 0;
    border-radius: 999px;
    background: #f1f3f5;
    color: #212529;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    line-height: 1;
    font-size: 0;
    font-weight: 900;
    cursor: pointer;
    box-shadow: none;
}
.modal-close::before,
a.modal-close::before,
button.modal-close::before {
    content: "×";
    display: block;
    font-size: 26px;
    line-height: 1;
    transform: translateY(-1px);
}
.modal-close:hover,
a.modal-close:hover,
button.modal-close:hover {
    background: #e9ecef;
    color: #111820;
}

.contractor-action-row .btn-action-delete::before,
.contractors-table .contractor-actions .btn-action-delete::before,
.btn-action-delete::before {
    content: "✕";
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: transparent !important;
    font-size: 11px;
    line-height: 1;
    font-weight: 900;
}
.contractor-action-row .btn-action-delete {
    gap: 5px;
}
.contractor-action-row .btn-action-gus[aria-busy="true"] {
    min-width: 58px;
}
.btn-gus[aria-busy="true"]::after {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: vertis-spin .65s linear infinite;
}
@keyframes vertis-spin {
    to { transform: rotate(360deg); }
}

/* Faktury — czytelne filtry i kwota jako jedna wartość */
.invoice-table-panel {
    padding: 18px;
}
.invoice-filter-box {
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}
.invoice-search-input {
    min-width: 280px;
    flex: 1 1 320px;
    max-width: 420px;
}
.invoice-worker-input {
    min-width: 220px;
    flex: 0 1 280px;
    max-width: 320px;
}
.invoice-filter-box .date-filter-inline {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
}
.invoice-filter-box .date-filter-inline input[type="date"] {
    width: 155px;
}
.invoice-table-panel .data-table th:nth-child(1) { width: 64px; }
.invoice-table-panel .data-table th:nth-child(2) { width: 116px; }
.invoice-table-panel .data-table th:nth-child(3) { width: 145px; }
.invoice-table-panel .data-table th:nth-child(4) { width: 116px; }
.invoice-table-panel .data-table th:nth-child(7),
.invoice-table-panel .data-table td:nth-child(7) {
    text-align: right;
    white-space: nowrap;
}
@media (max-width: 980px) {
    .invoice-filter-box,
    .invoice-filter-box .date-filter-inline {
        align-items: stretch;
    }
    .invoice-search-input,
    .invoice-worker-input,
    .invoice-filter-box .date-filter-inline input[type="date"] {
        width: 100%;
        max-width: none;
    }
}

/* Faktury — rejestr urzędowy, czysty widok i podgląd kliknięciem */
.invoice-toolbar {
    align-items: flex-start;
}
.invoice-bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: 10px 12px;
    margin: 8px 0 12px;
}
.invoice-bulk-info {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    margin-right: 4px;
}
.invoice-bulk-info b {
    color: var(--green-dark);
}
.btn-danger-soft {
    color: #a51d2a;
    border-color: rgba(220, 53, 69, .26);
    background: rgba(220, 53, 69, .04);
}
.invoices-table {
    table-layout: fixed;
    font-size: 13px;
}
.invoices-table th,
.invoices-table td {
    padding: 10px 9px;
    vertical-align: middle;
}
.invoices-table tbody tr.invoice-row {
    cursor: pointer;
    transition: background .12s ease, box-shadow .12s ease;
}
.invoices-table tbody tr.invoice-row:hover {
    background: rgba(40, 167, 69, .045);
}
.invoices-table tbody tr.invoice-row:focus {
    outline: 2px solid rgba(40, 167, 69, .35);
    outline-offset: -2px;
}
.invoices-table .check-cell {
    width: 42px;
    text-align: center;
}
.invoices-table .check-cell input {
    width: 17px;
    height: 17px;
    cursor: pointer;
}
.invoices-table th:nth-child(2) { width: 54px; }
.invoices-table th:nth-child(3) { width: 118px; }
.invoices-table th:nth-child(4) { width: 138px; }
.invoices-table th:nth-child(5) { width: 118px; }
.invoices-table th:nth-child(6) { width: 190px; }
.invoices-table th:nth-child(7) { width: 30%; }
.invoices-table th:nth-child(8),
.invoices-table td:nth-child(8) {
    width: 126px;
    text-align: right;
    white-space: nowrap;
}
.invoices-table th:nth-child(9) { width: 160px; }
.lp-cell {
    font-weight: 900;
    color: var(--dark);
}
.registry-cell b,
.date-cell b,
.document-cell b,
.contractor-cell b,
.status-cell b {
    display: block;
    line-height: 1.25;
}
.registry-cell small,
.date-cell small,
.document-cell small,
.contractor-cell small,
.status-cell small {
    display: block;
    margin-top: 3px;
    font-size: 11.5px;
    line-height: 1.25;
}
.registry-cell small {
    color: #6f7a85;
    font-weight: 800;
}
.doc-type-pill {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    border-radius: 999px;
    padding: 3px 8px;
    margin: 0 0 5px;
    background: rgba(40, 167, 69, .1);
    color: var(--green-dark);
    font-size: 11.5px;
    line-height: 1;
    font-weight: 900;
    white-space: nowrap;
}
.contractor-cell {
    overflow-wrap: anywhere;
}
.amount-cell b {
    font-size: 14px;
    color: #111820;
}
.status-cell .badge {
    margin-bottom: 3px;
}
.row-cancelled td {
    opacity: .72;
}
.row-cancelled .registry-cell b,
.row-cancelled .document-cell b,
.row-cancelled .contractor-cell b {
    text-decoration: line-through;
}
.invoice-preview-card {
    width: min(760px, 100%);
}
.invoice-preview-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.invoice-preview-head h2 {
    margin: 0;
}
.invoice-preview-head .muted {
    margin: 4px 0 0;
}
.invoice-preview-amount {
    flex: 0 0 auto;
    border: 1px solid rgba(40, 167, 69, .18);
    background: rgba(40, 167, 69, .07);
    color: #0f6a2a;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 18px;
    font-weight: 950;
    white-space: nowrap;
}
.invoice-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.invoice-preview-grid div,
.invoice-preview-contractor {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: 11px 12px;
}
.invoice-preview-grid span,
.invoice-preview-contractor span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 7px;
}
.invoice-preview-grid b,
.invoice-preview-contractor b {
    display: block;
    overflow-wrap: anywhere;
}
.invoice-preview-contractor {
    margin-top: 10px;
}
.invoice-preview-contractor p {
    margin: 5px 0;
    color: #495057;
}
.invoice-preview-contractor small {
    color: var(--muted);
    font-weight: 750;
}
@media (max-width: 980px) {
    .invoice-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .invoice-preview-head {
        flex-direction: column;
    }
    .invoice-preview-amount {
        width: 100%;
        text-align: center;
    }
    .invoice-preview-grid {
        grid-template-columns: 1fr;
    }
}

/* Faktury — dopięcie UI po uruchomieniu akcji */
.invoices-table {
    min-width: 1220px;
}
.invoices-table th,
.invoices-table td {
    white-space: normal;
    overflow: hidden;
}
.invoices-table th {
    line-height: 1.15;
}
.invoices-table td:nth-child(5),
.invoices-table td:nth-child(6),
.invoices-table td:nth-child(7),
.invoices-table td:nth-child(9) {
    overflow-wrap: anywhere;
    word-break: break-word;
}
.invoices-table .contractor-cell b,
.invoices-table .document-cell b,
.invoices-table .status-cell small {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.invoices-table .status-cell .badge {
    max-width: 100%;
    white-space: normal;
    text-align: center;
    justify-content: center;
    line-height: 1.15;
}
.invoices-table th:nth-child(1) { width: 42px; }
.invoices-table th:nth-child(2) { width: 54px; }
.invoices-table th:nth-child(3) { width: 116px; }
.invoices-table th:nth-child(4) { width: 130px; }
.invoices-table th:nth-child(5) { width: 112px; }
.invoices-table th:nth-child(6) { width: 185px; }
.invoices-table th:nth-child(7) { width: auto; }
.invoices-table th:nth-child(8),
.invoices-table td:nth-child(8) {
    width: 128px;
    min-width: 128px;
    text-align: right;
    white-space: nowrap;
}
.invoices-table th:nth-child(9) {
    width: 145px;
}
.invoice-preview-card {
    position: relative;
    padding-top: 28px;
}
.invoice-preview-card .modal-close {
    top: 14px;
    right: 14px;
    z-index: 4;
}
.invoice-preview-head {
    padding-right: 48px;
}
.invoice-preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.invoice-preview-actions .btn[disabled],
.invoice-bulk-toolbar .btn[disabled] {
    opacity: .42;
    cursor: not-allowed;
}
.invoice-action-card {
    width: min(520px, 100%);
}
.modal-action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
@media (max-width: 980px) {
    .invoice-preview-head {
        padding-right: 0;
    }
    .invoice-preview-card {
        padding-top: 54px;
    }
}


/* Faktury — poprawki 2026-07-04: węższe L.P., szerszy status, stabilna tabela */
.invoices-table .lp-header,
.invoices-table .lp-cell {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    text-align: center;
    padding-left: 5px;
    padding-right: 5px;
}
.invoices-table .check-cell {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
}
.invoices-table th:nth-child(2) {
    width: 36px !important;
}
.invoices-table th:nth-child(9),
.invoices-table td:nth-child(9) {
    width: 178px !important;
    min-width: 178px !important;
}
.invoices-table .status-cell .badge {
    width: 100%;
}
.invoice-preview-actions [data-invoice-edit-placeholder] {
    margin-right: auto;
}
@media (max-width: 980px) {
    .invoice-preview-actions [data-invoice-edit-placeholder] {
        margin-right: 0;
    }
}

/* Faktury — formularz ręczny i KSeF */
.contractor-picker {
    border: 1px solid #d8dee6;
    border-radius: 12px;
    background: #fff;
    margin-top: 6px;
    max-height: 240px;
    overflow: auto;
    box-shadow: 0 12px 30px rgba(33, 37, 41, 0.10);
}
.picker-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #eef1f4;
    background: #fff;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
}
.picker-item:hover,
.picker-item:focus {
    background: #f3fbf5;
    outline: none;
}
.picker-item b,
.picker-item small {
    display: block;
}
.picker-item small {
    color: #65717d;
    margin-top: 3px;
    line-height: 1.35;
}
.picker-empty {
    padding: 12px;
    color: #65717d;
}
.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 8px 0;
}
.checkbox-grid label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}
.ksef-card {
    width: min(1180px, calc(100vw - 40px));
}
.ksef-results {
    margin-top: 18px;
    border-top: 1px solid #e3e8ef;
    padding-top: 14px;
}
.ksef-results-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}
.ksef-table-scroll {
    max-height: 420px;
    overflow: auto;
    border: 1px solid #e3e8ef;
    border-radius: 14px;
}
.ksef-import-table {
    min-width: 1050px;
}
.ksef-import-table th,
.ksef-import-table td {
    vertical-align: top;
    white-space: normal;
}

.invoice-contractor-line {
    display: flex;
    gap: 8px;
    align-items: center;
}

.invoice-contractor-line input {
    flex: 1 1 auto;
    min-width: 0;
}

.compact-info {
    margin: 8px 0 12px;
    padding: 10px 12px;
}

.picker-empty-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}

.picker-empty-actions .btn {
    align-self: flex-start;
}

/* VERTIS 2.0 — globalna zasada modali: bez zamykania kliknięciem w tło + poprawne piętrowanie */
.modal.is-open {
    pointer-events: auto;
}
.modal .modal-card {
    pointer-events: auto;
}
#contractorModal.is-open {
    /* kontrahent może być otwierany z faktury, więc musi wejść nad modal faktury */
    z-index: 60;
}
.disabled-action-tip {
    display: inline-flex;
}
.disabled-action-tip .btn[disabled] {
    pointer-events: none;
}

/* Faktury — historia i czytelny antyduplikat */
.invoice-preview-history {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
}
.invoice-preview-history-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
}
.invoice-preview-history-head span {
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.invoice-audit-list {
    max-height: 260px;
    overflow: auto;
    padding: 10px 12px;
}
.invoice-audit-empty {
    color: var(--muted);
    font-weight: 750;
    padding: 8px 0;
}
.invoice-audit-empty.error { color: var(--danger); }
.invoice-audit-item {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #eef0f2;
}
.invoice-audit-item:last-child { border-bottom: 0; }
.invoice-audit-meta b,
.invoice-audit-meta span {
    display: block;
    overflow-wrap: anywhere;
}
.invoice-audit-meta b { font-size: 12px; }
.invoice-audit-meta span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.invoice-audit-main strong { display: block; }
.invoice-audit-main p { margin: 3px 0 0; color: #495057; }
.invoice-audit-main details { margin-top: 7px; }
.invoice-audit-main summary { cursor: pointer; font-weight: 800; color: var(--muted); }
.invoice-audit-main pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    font-size: 11px;
    margin: 5px 0 0;
}
.invoice-action-card textarea,
.duplicate-warning-card textarea {
    min-height: 88px;
}
.duplicate-warning-card h2 { margin-bottom: 6px; }
.duplicate-list {
    display: grid;
    gap: 8px;
    max-height: 280px;
    overflow: auto;
    margin: 12px 0;
}
.duplicate-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 11px 12px;
}
.duplicate-item b,
.duplicate-item small { display: block; overflow-wrap: anywhere; }
.duplicate-item small { color: var(--muted); margin-top: 3px; font-weight: 800; }
.duplicate-item p { margin: 7px 0 0; color: #495057; }
.duplicate-actions { margin-top: 8px; }
@media (max-width: 700px) {
    .invoice-audit-item { grid-template-columns: 1fr; }
}

/* Faktury — opisy, Moje faktury i uproszczona historia */
.invoice-description-row td {
    background: #fbfcfd;
    border-top: 0;
    padding-top: 0;
    color: #5b6470;
    font-size: 12px;
    font-style: italic;
    line-height: 1.45;
}
.invoice-description-row span {
    font-weight: 900;
    color: var(--muted);
    font-style: normal;
    margin-right: 4px;
}
.invoice-preview-description {
    margin-top: 10px;
    border: 1px solid var(--border);
    background: #fbfcfd;
    border-radius: 14px;
    padding: 11px 12px;
}
.invoice-preview-description span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 7px;
}
.invoice-preview-description p {
    margin: 0;
    color: #343a40;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-style: italic;
}
.invoice-manager-actions,
.invoice-worker-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.invoice-manager-actions.hidden,
.invoice-worker-actions.hidden {
    display: none !important;
}
.invoice-description-card textarea {
    min-height: 180px;
}
.invoice-audit-item-simple .invoice-audit-main p {
    margin-top: 4px;
}
.duplicate-meta {
    display: grid;
    gap: 3px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #d8dee6;
}
.duplicate-meta span {
    display: block;
    color: #495057;
    font-size: 12px;
    font-weight: 800;
}
.invoices-table-no-check th:nth-child(1) { width: 36px !important; }
.invoices-table-no-check th:nth-child(2) { width: 116px !important; }
.invoices-table-no-check th:nth-child(3) { width: 130px !important; }
.invoices-table-no-check th:nth-child(4) { width: 112px !important; }
.invoices-table-no-check th:nth-child(5) { width: 185px !important; }
.invoices-table-no-check th:nth-child(6) { width: auto !important; }
.invoices-table-no-check th:nth-child(7),
.invoices-table-no-check td:nth-child(7) {
    width: 128px !important;
    min-width: 128px !important;
    text-align: right;
    white-space: nowrap;
}
.invoices-table-no-check th:nth-child(8),
.invoices-table-no-check td:nth-child(8) {
    width: 178px !important;
    min-width: 178px !important;
}

/* Faktury — doprecyzowanie widoku Moje faktury i raporty */
.invoices-table tr.invoice-row-has-description td {
    border-bottom: 0 !important;
    padding-bottom: 4px;
}
.invoices-table tr.invoice-description-row td {
    border-top: 0 !important;
    border-bottom: 1px solid var(--border);
    padding: 0 9px 11px 9px;
    background: #fff;
}
.invoices-table tr.invoice-description-row:hover td {
    background: #fff;
}
.report-cards {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 18px;
    align-items: start;
}
.report-card h2 {
    margin-top: 0;
}
.report-filter-form .form-two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-print-page {
    background: #fff;
    color: #111820;
    padding: 18px;
}
.report-print-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin: 0 0 14px;
}
.report-shell-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.report-shell-table > thead { display: table-header-group; }
.report-shell-table > tfoot { display: table-footer-group; }
.report-shell-table > thead > tr > td,
.report-shell-table > tbody > tr > td,
.report-shell-table > tfoot > tr > td {
    border: 0;
    padding: 0;
}
.report-shell-table > tbody > tr > td {
    vertical-align: top;
}
.report-print-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 2px solid #212529;
    padding: 0 0 6px;
    margin: 0 0 7px;
}
.report-print-header h1 {
    margin: 0 0 3px;
    font-size: 18px;
    line-height: 1.1;
}
.report-print-header p {
    margin: 0;
    font-size: 9.5px;
    color: #495057;
    line-height: 1.18;
}
.report-print-header img {
    max-width: 96px;
    max-height: 36px;
    object-fit: contain;
}
.report-print-footer {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 12px;
    align-items: center;
    border-top: 1px solid #212529;
    padding: 5px 0 0;
    margin: 8px 0 0;
    font-size: 8.5px;
    line-height: 1.15;
    color: #343a40;
}
.report-print-footer > div:nth-child(2) {
    text-align: center;
    font-weight: 700;
}
.report-print-footer > div:nth-child(3) {
    text-align: right;
}
.report-print-footer img {
    max-width: 72px;
    max-height: 22px;
    object-fit: contain;
    margin-top: 2px;
}
.report-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.1px;
    line-height: 1.12;
    table-layout: fixed;
}
.report-data-table th,
.report-data-table td {
    border: 1px solid #9aa4af;
    padding: 2.6px 3.4px;
    vertical-align: top;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    white-space: normal;
}
.report-data-table th {
    background: #e6edf1;
    text-transform: uppercase;
    font-size: 7.1px;
    line-height: 1.0;
    letter-spacing: 0;
}
.report-data-table small {
    color: #4c5661;
}
.report-data-table tr,
.report-data-table td,
.report-data-table th {
    page-break-inside: avoid;
    break-inside: avoid;
}
.report-data-table .amount-cell-print {
    white-space: nowrap;
    text-align: right;
    font-weight: 800;
}
.report-daily-table {
    font-size: 7.7px;
    line-height: 1.06;
}
.report-daily-table th,
.report-daily-table td {
    padding: 1.9px 2.5px;
}
.report-daily-table .daily-document-cell div {
    margin: 0;
}
.report-daily-table .muted-print {
    color: #4c5661;
    font-weight: 400;
}
.report-daily-table .assigned-center-cell {
    text-align: center;
    vertical-align: middle;
    font-weight: 700;
}
.report-daily-table .signature-cell {
    height: 18px;
    min-width: 142px;
}

.report-invoice-table {
    font-size: 7.55px;
    line-height: 1.05;
}
.report-invoice-table th,
.report-invoice-table td {
    padding: 1.9px 2.5px;
}
.report-invoice-table th {
    font-size: 6.25px;
    line-height: .98;
    background: #e3eaee;
}

.report-invoice-table th:nth-child(1) { width: 28px; }
.report-invoice-table th:nth-child(2) { width: 64px; }
.report-invoice-table th:nth-child(3),
.report-invoice-table th:nth-child(4) { width: 66px; }
.report-invoice-table th:nth-child(7) { width: 78px; }
.report-invoice-table th:nth-child(8) { width: 78px; }
.report-invoice-table th:nth-child(9),
.report-invoice-table th:nth-child(10) { width: 88px; }
.report-daily-table th:nth-child(1) { width: 28px; }
.report-daily-table th:nth-child(2) { width: 68px; }
.report-daily-table th:nth-child(3),
.report-daily-table th:nth-child(4) { width: 68px; }
.report-daily-table th:nth-child(6) { width: 110px; }
.report-daily-table th:nth-child(7) { width: 165px; }
.report-daily-table th {
    font-size: 6.25px;
    line-height: .98;
    background: #e3eaee;
    padding-top: 1.8px;
    padding-bottom: 1.8px;
}
.report-manual-page-body {
    background: #f5f7f8;
}
.report-page {
    box-sizing: border-box;
    width: 100%;
    min-height: 190mm;
    background: #fff;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0 auto 18px;
}
.report-page-content {
    flex: 1 1 auto;
    min-height: 0;
}
.report-page-footer {
    flex: 0 0 auto;
    margin-top: auto;
}
.report-page + .report-page {
    page-break-before: always;
    break-before: page;
}

@media (max-width: 1100px) {
    .report-cards { grid-template-columns: 1fr; }
}

@media print {
    @page { size: A4 landscape; margin: 10mm; }
    html,
    body.report-print-page {
        min-height: 190mm;
    }
    body.report-print-page {
        padding: 0;
        background: #fff;
    }
    .report-shell-table {
        min-height: 190mm;
        height: 190mm;
    }
    .report-shell-table > tbody > tr > td {
        height: 100%;
        vertical-align: top;
    }
    .report-print-header {
        padding-bottom: 5px;
        margin-bottom: 5px;
    }
    .report-print-footer {
        margin-top: 5px;
    }
    .no-print,
    .report-print-actions {
        display: none !important;
    }
    .report-shell-table > thead { display: table-header-group; }
    .report-shell-table > tfoot { display: table-footer-group; }
    .report-data-table {
        page-break-inside: auto;
        break-inside: auto;
    }
    .report-data-table tr,
    .report-data-table td,
    .report-data-table th {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: auto;
    }
    .report-manual-page-body {
        background: #fff;
    }
    .report-page {
        height: 190mm;
        min-height: 190mm;
        margin: 0;
        overflow: hidden;
    }
    .report-page + .report-page {
        page-break-before: always;
        break-before: page;
    }
    .report-data-table th {
        background: #e3eaee !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .report-invoice-table {
        font-size: 7.35px;
        line-height: 1.04;
    }
    .report-invoice-table th {
        font-size: 5.95px;
        line-height: .98;
        padding: 1.55px 1.9px;
    }
    .report-invoice-table td {
        padding: 1.65px 2.1px;
    }
    .report-daily-table {
        font-size: 7.55px;
        line-height: 1.05;
    }
    .report-daily-table th {
        font-size: 6.05px;
        line-height: .98;
        padding: 1.55px 1.9px;
        background: #e3eaee !important;
    }
    .report-daily-table td {
        padding: 1.75px 2.1px;
    }
    .report-daily-table .signature-cell {
        height: 18px;
    }
}

/* VERTIS 2.0 — raporty faktur: stałe 20 pozycji na stronę, czytelnie i bez nachodzenia na stopkę */
.report-manual-page-body .report-page {
    width: 100%;
    min-height: 190mm;
    height: 190mm;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.report-manual-page-body .report-page-header {
    flex: 0 0 auto;
}
.report-manual-page-body .report-page-content {
    flex: 0 0 145mm;
    height: 145mm;
    min-height: 145mm;
    max-height: 145mm;
    overflow: hidden;
}
.report-manual-page-body .report-page-footer {
    flex: 0 0 20mm;
    min-height: 20mm;
    max-height: 20mm;
    margin-top: auto;
}
.report-manual-page-body .report-data-table {
    height: 144mm;
    max-height: 144mm;
    font-size: 7.25px;
    line-height: 1.08;
    table-layout: fixed;
}
.report-manual-page-body .report-data-table th,
.report-manual-page-body .report-data-table td {
    padding: 1.4px 2.2px;
    overflow: hidden;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}
.report-manual-page-body .report-data-table th {
    background: #e4ebef;
    font-size: 6px;
    line-height: 1;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.report-manual-page-body .report-data-table tbody tr {
    height: 6.85mm;
    max-height: 6.85mm;
    page-break-inside: avoid;
    break-inside: avoid;
}
.report-manual-page-body .report-data-table tbody td {
    height: 6.85mm;
    max-height: 6.85mm;
    vertical-align: top;
}
.report-manual-page-body .report-cell-clip {
    display: block;
    max-height: 6.15mm;
    overflow: hidden;
}
.report-manual-page-body .report-contractor-print-cell,
.report-manual-page-body .report-daily-document-wrap {
    max-height: 6.25mm;
}
.report-manual-page-body .amount-cell-print {
    white-space: nowrap;
    text-align: right;
    font-weight: 800;
}
.report-manual-page-body .report-daily-table .assigned-center-cell {
    vertical-align: middle;
    text-align: center;
    font-weight: 700;
}
.report-manual-page-body .report-daily-table .signature-cell {
    height: 6.85mm;
    min-width: 150px;
}
.report-manual-page-body .report-print-header {
    margin-bottom: 5px;
}
.report-manual-page-body .report-print-footer {
    margin-top: 6px;
    padding-top: 5px;
}

@media print {
    .report-manual-page-body .report-page {
        min-height: 190mm;
        height: 190mm;
        overflow: hidden;
    }
    .report-manual-page-body .report-page-content {
        flex-basis: 145mm;
        height: 145mm;
        min-height: 145mm;
        max-height: 145mm;
        overflow: hidden;
    }
    .report-manual-page-body .report-page-footer {
        flex-basis: 20mm;
        min-height: 20mm;
        max-height: 20mm;
        margin-top: auto;
    }
    .report-manual-page-body .report-data-table {
        height: 144mm;
        max-height: 144mm;
        font-size: 7.25px;
        line-height: 1.08;
    }
    .report-manual-page-body .report-data-table th,
    .report-manual-page-body .report-data-table td {
        padding: 1.4px 2.2px;
    }
    .report-manual-page-body .report-data-table th {
        font-size: 6px;
        background: #e4ebef !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .report-manual-page-body .report-data-table tbody tr,
    .report-manual-page-body .report-data-table tbody td {
        height: 6.85mm;
        max-height: 6.85mm;
    }
    .report-manual-page-body .report-cell-clip {
        max-height: 6.15mm;
        overflow: hidden;
    }
    .report-manual-page-body .report-contractor-print-cell,
    .report-manual-page-body .report-daily-document-wrap {
        max-height: 6.25mm;
    }
}

/* VERTIS 2.0 — raporty faktur FIX4: sztywna geometria strony i wierszy */
.report-manual-page-body .report-page {
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 190mm !important;
    height: 190mm !important;
    max-height: 190mm !important;
    display: grid !important;
    grid-template-rows: 15mm 160mm 15mm !important;
    padding: 0 !important;
    margin: 0 auto 18px !important;
    overflow: hidden !important;
    background: #fff !important;
}
.report-manual-page-body .report-page-header {
    box-sizing: border-box !important;
    height: 15mm !important;
    min-height: 15mm !important;
    max-height: 15mm !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 0 2mm 0 !important;
    margin: 0 !important;
    border-bottom: 2px solid #111 !important;
}
.report-manual-page-body .report-page-header h1 {
    font-size: 17px !important;
    line-height: 1.05 !important;
    margin: 0 0 2px !important;
}
.report-manual-page-body .report-page-header p {
    font-size: 8.5px !important;
    line-height: 1.1 !important;
    margin: 0 !important;
    max-height: 5mm !important;
    overflow: hidden !important;
}
.report-manual-page-body .report-page-header img {
    max-width: 22mm !important;
    max-height: 8mm !important;
    object-fit: contain !important;
}
.report-manual-page-body .report-page-content {
    box-sizing: border-box !important;
    height: 160mm !important;
    min-height: 160mm !important;
    max-height: 160mm !important;
    overflow: hidden !important;
    padding: 2mm 0 !important;
}
.report-manual-page-body .report-page-footer {
    box-sizing: border-box !important;
    height: 15mm !important;
    min-height: 15mm !important;
    max-height: 15mm !important;
    overflow: hidden !important;
    display: grid !important;
    grid-template-columns: 1fr 1.2fr 1fr !important;
    align-items: center !important;
    gap: 8mm !important;
    margin: 0 !important;
    padding: 2mm 0 0 0 !important;
    border-top: 1px solid #111 !important;
    font-size: 7px !important;
    line-height: 1.12 !important;
}
.report-manual-page-body .report-page-footer img {
    max-width: 20mm !important;
    max-height: 6mm !important;
    object-fit: contain !important;
}
.report-manual-page-body .report-data-table {
    width: 100% !important;
    height: auto !important;
    max-height: 156mm !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 6.9px !important;
    line-height: 1.08 !important;
}
.report-manual-page-body .report-data-table thead tr,
.report-manual-page-body .report-data-table thead th {
    height: 5.8mm !important;
    max-height: 5.8mm !important;
}
.report-manual-page-body .report-data-table th {
    box-sizing: border-box !important;
    padding: 1mm .9mm !important;
    overflow: hidden !important;
    text-align: center !important;
    vertical-align: middle !important;
    background: #e7edf1 !important;
    font-size: 5.6px !important;
    line-height: 1.04 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}
.report-manual-page-body .report-data-table tbody tr {
    height: 7.5mm !important;
    min-height: 7.5mm !important;
    max-height: 7.5mm !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}
.report-manual-page-body .report-data-table tbody td {
    box-sizing: border-box !important;
    height: 7.5mm !important;
    min-height: 7.5mm !important;
    max-height: 7.5mm !important;
    padding: .75mm .9mm !important;
    overflow: hidden !important;
    vertical-align: top !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
}
.report-manual-page-body .report-cell-clip,
.report-manual-page-body .report-contractor-print-cell,
.report-manual-page-body .report-daily-document-wrap,
.report-manual-page-body .report-document-print-cell {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 4 !important;
    max-height: 6mm !important;
    overflow: hidden !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
}
.report-manual-page-body .amount-cell-print {
    white-space: nowrap !important;
    text-align: right !important;
    vertical-align: middle !important;
    font-weight: 800 !important;
}
.report-manual-page-body .report-daily-table .assigned-center-cell {
    vertical-align: middle !important;
    text-align: center !important;
    font-weight: 700 !important;
}
.report-manual-page-body .report-daily-table .signature-cell {
    vertical-align: middle !important;
    height: 7.5mm !important;
}
.report-manual-page-body .report-page + .report-page {
    page-break-before: always !important;
    break-before: page !important;
}

@media print {
    @page { size: A4 landscape; margin: 10mm; }
    html, body.report-print-page {
        width: auto !important;
        min-height: 190mm !important;
        background: #fff !important;
    }
    body.report-print-page {
        padding: 0 !important;
        margin: 0 !important;
    }
    .report-manual-page-body .report-page {
        width: 100% !important;
        height: 190mm !important;
        min-height: 190mm !important;
        max-height: 190mm !important;
        margin: 0 !important;
        display: grid !important;
        grid-template-rows: 15mm 160mm 15mm !important;
        overflow: hidden !important;
    }
    .report-manual-page-body .report-page-header {
        height: 15mm !important;
        min-height: 15mm !important;
        max-height: 15mm !important;
    }
    .report-manual-page-body .report-page-content {
        height: 160mm !important;
        min-height: 160mm !important;
        max-height: 160mm !important;
        padding: 2mm 0 !important;
        overflow: hidden !important;
    }
    .report-manual-page-body .report-page-footer {
        height: 15mm !important;
        min-height: 15mm !important;
        max-height: 15mm !important;
        overflow: hidden !important;
    }
    .report-manual-page-body .report-data-table {
        max-height: 156mm !important;
        font-size: 6.9px !important;
        line-height: 1.08 !important;
    }
    .report-manual-page-body .report-data-table thead tr,
    .report-manual-page-body .report-data-table thead th {
        height: 5.8mm !important;
        max-height: 5.8mm !important;
    }
    .report-manual-page-body .report-data-table tbody tr,
    .report-manual-page-body .report-data-table tbody td {
        height: 7.5mm !important;
        min-height: 7.5mm !important;
        max-height: 7.5mm !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .report-manual-page-body .report-data-table th {
        background: #e7edf1 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .report-manual-page-body .report-cell-clip,
    .report-manual-page-body .report-contractor-print-cell,
    .report-manual-page-body .report-daily-document-wrap,
    .report-manual-page-body .report-document-print-cell {
        -webkit-line-clamp: 4 !important;
        max-height: 6mm !important;
    }
}

/* VERTIS 2.0 — raporty faktur FIX4 korekta: 4 linie w stałym wierszu */
.report-manual-page-body .report-page-content {
    padding: 0 !important;
}
.report-manual-page-body .report-data-table {
    max-height: 160mm !important;
    font-size: 6.3px !important;
    line-height: 1.08 !important;
}
.report-manual-page-body .report-data-table thead tr,
.report-manual-page-body .report-data-table thead th {
    height: 6mm !important;
    max-height: 6mm !important;
}
.report-manual-page-body .report-data-table tbody tr {
    height: 7.7mm !important;
    min-height: 7.7mm !important;
    max-height: 7.7mm !important;
}
.report-manual-page-body .report-data-table tbody td {
    height: 7.7mm !important;
    min-height: 7.7mm !important;
    max-height: 7.7mm !important;
    padding: .25mm .85mm !important;
}
.report-manual-page-body .report-cell-clip,
.report-manual-page-body .report-contractor-print-cell,
.report-manual-page-body .report-daily-document-wrap,
.report-manual-page-body .report-document-print-cell {
    max-height: 7.2mm !important;
}
.report-manual-page-body .report-daily-table .signature-cell {
    height: 7.7mm !important;
}
@media print {
    .report-manual-page-body .report-page-content {
        padding: 0 !important;
    }
    .report-manual-page-body .report-data-table {
        max-height: 160mm !important;
        font-size: 6.3px !important;
        line-height: 1.08 !important;
    }
    .report-manual-page-body .report-data-table thead tr,
    .report-manual-page-body .report-data-table thead th {
        height: 6mm !important;
        max-height: 6mm !important;
    }
    .report-manual-page-body .report-data-table tbody tr,
    .report-manual-page-body .report-data-table tbody td {
        height: 7.7mm !important;
        min-height: 7.7mm !important;
        max-height: 7.7mm !important;
    }
    .report-manual-page-body .report-data-table tbody td {
        padding: .25mm .85mm !important;
    }
    .report-manual-page-body .report-cell-clip,
    .report-manual-page-body .report-contractor-print-cell,
    .report-manual-page-body .report-daily-document-wrap,
    .report-manual-page-body .report-document-print-cell {
        max-height: 7.2mm !important;
    }
}


.ksef-preview-card {
    width: min(80vw, 1400px);
    max-width: 80vw;
}
.ksef-preview-card .modal-body,
.ksef-preview-content {
    max-height: 78vh;
    overflow: auto;
}
@media (max-width: 900px) {
    .ksef-preview-card {
        width: min(96vw, 100%);
        max-width: 96vw;
    }
}

.ksef-preview-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 14px;
    color: var(--muted);
    font-size: 0.9rem;
}
.ksef-preview-content {
    display: grid;
    gap: 12px;
}
.ksef-preview-section {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}
.ksef-preview-section h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}
.ksef-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
}
.ksef-preview-field span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 2px;
}
.ksef-preview-field b {
    display: block;
    overflow-wrap: anywhere;
}
.ksef-lines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.ksef-lines-table th,
.ksef-lines-table td {
    border: 1px solid var(--border);
    padding: 6px 8px;
    vertical-align: top;
}
.ksef-lines-table th {
    background: #f3f6f4;
    font-size: 0.8rem;
}
.ksef-row-actions {
    white-space: nowrap;
}
@media (max-width: 900px) {
    .ksef-preview-grid { grid-template-columns: 1fr; }
}

/* VERTIS 2.0 — wydruk opisu faktury */
.invoice-description-print-body {
    background: #f8f9fa;
}
.invoice-description-print-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    background: #fff;
    color: #111820;
    box-sizing: border-box;
    padding: 13mm 12mm;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 8mm;
    box-shadow: 0 8px 28px rgba(0,0,0,.12);
}
.invoice-description-print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12mm;
    border-bottom: 2px solid #111820;
    padding-bottom: 5mm;
}
.invoice-description-print-header h1 {
    margin: 0 0 2mm;
    font-size: 22px;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.invoice-description-print-header p {
    margin: 0;
    font-size: 12px;
    color: #343a40;
}
.invoice-description-print-header img {
    max-width: 35mm;
    max-height: 16mm;
    object-fit: contain;
}
.invoice-description-print-content {
    font-size: 11px;
    line-height: 1.28;
}
.invoice-description-print-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0 0 5mm;
}
.invoice-description-print-table th,
.invoice-description-print-table td {
    border: 1px solid #adb5bd;
    padding: 2.2mm 2.4mm;
    vertical-align: top;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;
}
.invoice-description-print-table th {
    width: 20%;
    background: #f1f3f5;
    color: #212529;
    font-weight: 800;
    text-align: left;
}
.invoice-description-print-table td {
    width: 30%;
}
.invoice-description-print-table.compact {
    margin-bottom: 4mm;
}
.invoice-description-print-section {
    margin: 0 0 5mm;
    break-inside: avoid;
    page-break-inside: avoid;
}
.invoice-description-print-section h2 {
    margin: 0 0 2mm;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .025em;
    color: #212529;
}
.invoice-description-print-box {
    border: 1px solid #adb5bd;
    background: #fff;
    padding: 3mm;
    min-height: 12mm;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;
}
.invoice-description-print-description .description-box {
    min-height: 42mm;
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
}
.invoice-description-print-meta {
    margin-top: 2mm;
    font-size: 10px;
    color: #495057;
    text-align: right;
}
.invoice-description-print-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14mm;
    margin-top: 10mm;
    break-inside: avoid;
    page-break-inside: avoid;
}
.invoice-description-print-signatures div {
    border-top: 1px solid #111820;
    padding-top: 2mm;
    min-height: 12mm;
    text-align: center;
    font-size: 10px;
    color: #343a40;
}
.invoice-description-print-footer {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 8mm;
    align-items: center;
    border-top: 1px solid #111820;
    padding-top: 3mm;
    font-size: 8.5px;
    line-height: 1.18;
    color: #343a40;
}
.invoice-description-print-footer > div:nth-child(2) {
    text-align: center;
    font-weight: 800;
}
.invoice-description-print-footer > div:nth-child(3) {
    text-align: right;
}
.invoice-description-print-footer img {
    max-width: 22mm;
    max-height: 8mm;
    object-fit: contain;
}

@media print {
    body.invoice-description-print-body {
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .invoice-description-print-page {
        width: 210mm !important;
        min-height: 297mm !important;
        height: 297mm !important;
        margin: 0 !important;
        padding: 12mm !important;
        box-shadow: none !important;
        page-break-after: always;
    }
    .invoice-description-print-table tr,
    .invoice-description-print-section,
    .invoice-description-print-signatures {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
}


/* VERTIS 2.0 — modale 80% ekranu + korekta dostępności */
.modal-card,
.modal-card-wide,
.invoice-preview-card,
.invoice-description-card,
.duplicate-warning-card,
.ksef-card,
.ksef-preview-card,
.modal-card-monitoring {
    width: min(80vw, 1280px) !important;
    max-width: 80vw !important;
}
.invoice-action-card {
    width: min(80vw, 900px) !important;
    max-width: 80vw !important;
}
.modal-card {
    max-height: 90vh !important;
}
@media (max-width: 900px) {
    .modal-card,
    .modal-card-wide,
    .invoice-preview-card,
    .invoice-description-card,
    .duplicate-warning-card,
    .ksef-card,
    .ksef-preview-card,
    .modal-card-monitoring,
    .invoice-action-card {
        width: min(96vw, 100%) !important;
        max-width: 96vw !important;
    }
}

/* VERTIS 2.0 — wydruk opisu faktury: układ A4 pionowo */
.invoice-description-print-page {
    page: invoiceDescriptionPortrait;
}
@page invoiceDescriptionPortrait {
    size: A4 portrait;
    margin: 0;
}
@media print {
    body.invoice-description-print-body {
        width: 210mm !important;
        min-height: 297mm !important;
    }
    .invoice-description-print-page {
        width: 210mm !important;
        min-width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        height: 297mm !important;
        max-height: 297mm !important;
        margin: 0 !important;
        page-break-after: auto !important;
        break-after: auto !important;
    }
}

/* Korespondencja przychodząca */
.correspondence-filter-form {
    display: grid;
    gap: .6rem;
    margin-bottom: .75rem;
}
.correspondence-filter-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.6fr) repeat(5, minmax(130px, .8fr));
    gap: .55rem;
    align-items: end;
}
.correspondence-filter-grid label {
    display: grid;
    gap: .22rem;
    min-width: 0;
}
.correspondence-filter-grid span {
    font-size: .72rem;
    font-weight: 800;
    color: #68717a;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.correspondence-filter-grid input,
.correspondence-filter-grid select {
    width: 100%;
}
.correspondence-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    justify-content: flex-end;
}
.correspondence-table th,
.correspondence-table td {
    vertical-align: top;
}
.correspondence-row {
    cursor: pointer;
}
.correspondence-row:hover {
    background: rgba(40, 167, 69, .045);
}
.correspondence-modal-sections {
    display: grid;
    gap: .65rem;
    margin-top: .75rem;
}
.correspondence-modal-section {
    border: 1px solid rgba(33, 37, 41, .10);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.correspondence-modal-section summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem .85rem;
    cursor: pointer;
    font-weight: 800;
    background: #f8f9fa;
}
.correspondence-modal-section summary small {
    font-weight: 600;
    color: #6c757d;
}
.correspondence-modal-section[open] {
    box-shadow: 0 8px 22px rgba(33, 37, 41, .06);
}
.correspondence-modal-section[open] > .mini-history-list,
.correspondence-modal-section[open] > form {
    margin: .75rem .85rem;
}
.row-actions-details summary {
    cursor: pointer;
    font-weight: 700;
    color: #1f7a35;
}
.row-actions-stack {
    display: grid;
    gap: .45rem;
    min-width: 260px;
    margin-top: .45rem;
}
.inline-action-form,
.compact-edit-form {
    display: grid;
    gap: .35rem;
    padding: .45rem;
    border: 1px solid rgba(33, 37, 41, .08);
    border-radius: 10px;
    background: #fff;
}
.inline-action-form select,
.inline-action-form input,
.inline-action-form textarea {
    width: 100%;
}
.correspondence-comment-form textarea,
.correspondence-transfer-form textarea {
    resize: vertical;
}
.mini-history-item {
    padding: .4rem 0;
    border-bottom: 1px dashed rgba(33, 37, 41, .12);
}
.mini-history-item:last-child {
    border-bottom: 0;
}
.mini-history-item p {
    margin: .2rem 0 0;
    white-space: normal;
}
.file-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .45rem 0;
    border-bottom: 1px dashed rgba(33, 37, 41, .12);
}
.file-line:last-child {
    border-bottom: 0;
}
.file-line a {
    font-weight: 800;
}
.correspondence-preview-actions {
    justify-content: space-between;
}
.correspondence-preview-actions .invoice-manager-actions,
.correspondence-preview-actions .invoice-worker-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}
.correspondence-file-upload-form input[type="file"] {
    padding: .5rem;
    border: 1px solid rgba(33, 37, 41, .16);
    border-radius: 9px;
}
.badge-wycofana,
.badge-case-odrzucona {
    background: #f8d7da;
    color: #842029;
}
.badge-case-nowa {
    background: #e2e3e5;
    color: #41464b;
}
.badge-case-w-trakcie {
    background: #cff4fc;
    color: #055160;
}
.badge-case-wstrzymana {
    background: #fff3cd;
    color: #664d03;
}
.badge-case-zakonczona {
    background: #d1e7dd;
    color: #0f5132;
}
.report-correspondence-table th,
.report-correspondence-table td,
.report-correspondence-signature-table th,
.report-correspondence-signature-table td {
    font-size: 8pt;
    line-height: 1.15;
    padding-top: 2.2mm;
    padding-bottom: 2.2mm;
}
.report-correspondence-signature-table .signature-cell {
    min-width: 46mm;
    height: 10.5mm;
}
.report-correspondence-signature-page .report-print-header h1,
.report-correspondence-page .report-print-header h1 {
    font-size: 14pt;
}
.report-correspondence-signature-page .report-print-header p,
.report-correspondence-page .report-print-header p {
    font-size: 8pt;
}
@media (max-width: 1100px) {
    .correspondence-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .correspondence-filter-search {
        grid-column: 1 / -1;
    }
}
@media (max-width: 700px) {
    .correspondence-filter-grid {
        grid-template-columns: 1fr;
    }
    .correspondence-filter-actions {
        justify-content: stretch;
    }
    .correspondence-filter-actions .btn {
        flex: 1 1 auto;
    }
    .row-actions-stack {
        min-width: 0;
    }
}

/* System / konto użytkownika */
.system-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    align-items: start;
}


.system-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin: 0 0 1rem;
}

.system-subnav a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--dark);
    text-decoration: none;
    font-weight: 800;
    font-size: 13px;
}

.system-subnav a:hover,
.system-subnav a.is-active {
    border-color: rgba(40, 167, 69, .45);
    background: rgba(40, 167, 69, .12);
    color: var(--green-dark);
}

.system-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.system-admin-tile {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    min-height: 118px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--dark);
    text-decoration: none;
    box-shadow: var(--shadow);
}

.system-admin-tile strong {
    font-size: 1.05rem;
}

.system-admin-tile span {
    color: var(--muted);
    line-height: 1.35;
}

.system-admin-tile:hover {
    transform: translateY(-1px);
    border-color: rgba(40, 167, 69, .35);
    box-shadow: 0 14px 34px rgba(33, 37, 41, .12);
}

.system-admin-cards {
    margin-bottom: 1rem;
}

.system-section {
    margin-top: 1rem;
}

.section-head-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.system-profile-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: .75rem 0 1rem;
}

.system-profile-summary strong,
.system-profile-summary span,
.system-profile-summary small {
    display: block;
}

.system-avatar {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-weight: 800;
    background: rgba(40, 167, 69, .14);
    color: var(--green-dark);
    border: 1px solid rgba(40, 167, 69, .22);
}

.system-meta-list {
    display: grid;
    gap: .65rem;
    margin: 0;
}

.system-meta-list div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem 0;
    border-bottom: 1px solid rgba(0,0,0,.07);
}

.system-meta-list dt {
    color: var(--muted);
    font-size: .86rem;
}

.system-meta-list dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
}

.system-users-table .action-cell {
    min-width: 190px;
}

.system-inline-form {
    min-width: 240px;
}

.system-inline-form input,
.system-inline-form textarea,
.system-inline-form select {
    width: 100%;
}

.permission-matrix th,
.permission-matrix td {
    vertical-align: middle;
}

.permission-cell {
    text-align: center;
}

.permission-cell input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-height: 42px;
    font-weight: 700;
}

.check-row input {
    width: auto;
}


/* Audit log — kompaktowe filtry w administracji */
.audit-head-row {
    display: block;
}
.audit-head-row > div {
    margin-bottom: .8rem;
}
.audit-filter-form {
    display: grid;
    grid-template-columns: minmax(132px, 150px) minmax(132px, 150px) minmax(190px, 1fr) minmax(135px, 160px) minmax(135px, 160px) minmax(86px, 96px) auto auto;
    gap: .55rem;
    align-items: end;
    max-width: 100%;
}
.audit-filter-form label {
    display: grid;
    gap: .22rem;
    min-width: 0;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .025em;
}
.audit-filter-form input,
.audit-filter-form select {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 10px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    font-weight: 650;
}
.audit-filter-form .per-page-control {
    display: grid;
    gap: .22rem;
    white-space: normal;
}
.audit-filter-form .btn {
    min-height: 38px;
    white-space: nowrap;
}
@media (max-width: 1180px) {
    .audit-filter-form {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }
}
@media (max-width: 760px) {
    .audit-filter-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .section-head-row {
        display: block;
    }

    .section-head-row .btn {
        margin-top: .75rem;
    }

    .system-meta-list div {
        display: block;
    }

    .system-meta-list dd {
        text-align: left;
        margin-top: .2rem;
    }
}


.invoice-preview-third-subjects {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 0.75rem;
    background: rgba(40, 167, 69, 0.06);
}

.invoice-preview-third-subjects > span {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--muted-color, #6c757d);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.invoice-preview-third-subjects ul {
    margin: 0;
    padding-left: 1.1rem;
}

.invoice-preview-third-subjects li + li {
    margin-top: 0.35rem;
}

.system-secret-note {
    display: block;
    margin-top: 0.25rem;
    color: var(--muted-color, #6c757d);
    font-size: 0.78rem;
}

/* System admin — Stage 3 formularze i macierz */
.system-two-column {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    align-items: start;
}

.system-card-form {
    display: grid;
    gap: 1rem;
}

.system-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.system-settings-grid.one-column {
    grid-template-columns: 1fr;
}

.system-setting-field {
    display: grid;
    gap: .35rem;
    min-width: 0;
    font-weight: 800;
    color: var(--dark);
}

.system-setting-field span {
    font-size: .86rem;
}

.system-setting-field small {
    color: var(--muted);
    font-weight: 650;
    line-height: 1.35;
}

.system-setting-field input,
.system-setting-field textarea,
.system-setting-field select {
    width: 100%;
    min-height: 42px;
}

.system-setting-field input[type="file"] {
    padding: 9px 10px;
    background: #fff;
}

.system-setting-field.is-secret input,
.system-setting-field.is-secret textarea {
    border-color: rgba(255, 193, 7, .55);
    background: rgba(255, 193, 7, .05);
}

.system-raw-settings {
    padding: 0;
}

.system-raw-settings summary {
    cursor: pointer;
    padding: 1rem 1.25rem;
    font-weight: 900;
}

.system-raw-settings .system-section {
    margin: 0;
    border: 0;
    box-shadow: none;
}

.permission-module-grid {
    display: grid;
    gap: 1rem;
}

.permission-module-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}

.permission-module-card > header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1rem;
    background: rgba(40, 167, 69, .07);
    border-bottom: 1px solid var(--border);
}

.permission-module-card h2 {
    margin: 0;
    font-size: 1rem;
}

.permission-module-card header span {
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
}

.permission-module-table-wrap {
    box-shadow: none;
    border-radius: 0;
    margin: 0;
}

.permission-matrix-compact th,
.permission-matrix-compact td {
    padding: 9px 10px;
    font-size: 13px;
}

.sticky-action-row {
    position: sticky;
    bottom: 0;
    padding: .85rem 0 0;
    background: linear-gradient(to top, #fff 82%, rgba(255,255,255,0));
    z-index: 3;
}

.system-file-card h2 {
    margin-top: 0;
}

.system-file-preview {
    display: grid;
    place-items: center;
    min-height: 120px;
    padding: 1rem;
    margin: .75rem 0 1rem;
    border: 1px dashed var(--border);
    border-radius: 16px;
    background: #fff;
}

.system-file-preview img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.logo-preview img {
    max-height: 110px;
}

.favicon-preview img {
    max-width: 64px;
    max-height: 64px;
}

@media (max-width: 760px) {
    .system-two-column,
    .system-settings-grid {
        grid-template-columns: 1fr;
    }
    .permission-module-card > header {
        display: block;
    }
}

/* Stage 9 — globalne uporządkowanie UI/UX */
.content-area > .panel,
.content-area > .table-wrap,
.report-card,
.system-card,
.admin-card {
    border-radius: 18px;
}

.page-head {
    gap: 16px;
    align-items: flex-start;
}

.page-head .actions,
.modal-action-row,
.invoice-preview-actions,
.bulk-actions,
.correspondence-filter-actions,
.contractor-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    line-height: 1.15;
    justify-content: center;
    text-decoration: none;
}

.btn-outline {
    background: #fff;
}

.btn-danger-soft,
.btn-danger {
    white-space: nowrap;
}

.data-table,
.report-data-table {
    border-spacing: 0;
}

.table-wrap {
    overflow-x: auto;
}

.data-table tbody tr:hover {
    background: rgba(40, 167, 69, .045);
}

.data-table th,
.report-data-table th {
    vertical-align: middle;
}

.data-table td,
.report-data-table td {
    vertical-align: top;
}

.empty,
.empty-inline,
.picker-empty {
    color: var(--muted);
    background: rgba(248, 249, 250, .75);
    border-radius: 14px;
}

.badge {
    white-space: nowrap;
    vertical-align: middle;
}

.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 12px;
}

.report-summary-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 12px;
    background: #fff;
    min-height: 70px;
}

.report-summary-card span,
.report-summary-card small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.report-summary-card strong {
    display: block;
    margin: 3px 0;
    font-size: 15px;
    color: var(--dark);
    line-height: 1.25;
}

.report-filter-form .modal-action-row {
    justify-content: flex-start;
}

.report-filter-form input,
.report-filter-form select,
.audit-filter-form input,
.audit-filter-form select,
.correspondence-filter-form input,
.correspondence-filter-form select {
    min-height: 40px;
}

.checkbox-line {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    color: var(--dark);
    font-weight: 600;
}

.checkbox-line input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 18px;
}

.modal-card {
    max-height: min(88vh, 900px);
    overflow: auto;
}

.modal-card h2,
.panel h2,
.report-card h2 {
    line-height: 1.2;
}

@media (max-width: 900px) {
    .report-summary-grid {
        grid-template-columns: 1fr;
    }

    .page-head .actions,
    .modal-action-row {
        width: 100%;
    }

    .page-head .actions .btn,
    .modal-action-row .btn,
    .report-filter-form .modal-action-row .btn {
        flex: 1 1 180px;
    }
}

@media print {
    .report-summary-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: 8px;
    }

    .report-summary-card {
        padding: 7px 8px;
        min-height: auto;
        break-inside: avoid;
    }

    .report-summary-card strong {
        font-size: 11px;
    }

    .report-summary-card span,
    .report-summary-card small {
        font-size: 8px;
    }
}

/* Stage 6+9 hotfix: pulpit i podsumowania raportów */
.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: stretch;
    padding: 26px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 6px);
    background:
        radial-gradient(circle at 92% 12%, rgba(40, 167, 69, .18), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f5fbf7 100%);
    box-shadow: var(--shadow);
}
.dashboard-hero h1 { margin: 4px 0 8px; font-size: clamp(30px, 4vw, 48px); line-height: 1.05; }
.dashboard-hero p { margin: 0; max-width: 760px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.dashboard-eyebrow { color: var(--green-dark); font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.dashboard-hero-side {
    min-width: 180px;
    display: grid;
    align-content: center;
    justify-items: end;
    gap: 6px;
    padding: 18px;
    border: 1px solid rgba(40, 167, 69, .22);
    border-radius: 18px;
    background: rgba(255,255,255,.72);
}
.dashboard-hero-side span { color: var(--muted); font-size: 13px; font-weight: 700; }
.dashboard-hero-side strong { color: var(--dark); font-size: 18px; }
.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.dashboard-metric-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.dashboard-metric-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.dashboard-metric-card strong { display: block; margin: 6px 0 4px; font-size: 38px; line-height: 1; color: var(--green-dark); }
.dashboard-metric-card p { margin: 0; color: var(--muted); line-height: 1.4; }
.dashboard-grid-main {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
    gap: 18px;
    align-items: start;
}
.dashboard-grid-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-panel { min-height: 100%; }
.dashboard-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.dashboard-action-card,
.dashboard-shortcut,
.dashboard-feed-item {
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.dashboard-action-card:hover,
.dashboard-shortcut:hover,
.dashboard-feed-item:hover {
    transform: translateY(-1px);
    border-color: rgba(40, 167, 69, .34);
    box-shadow: 0 12px 24px rgba(11, 31, 18, .08);
}
.dashboard-action-card { display: grid; gap: 5px; padding: 15px; }
.dashboard-action-card > span {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(40, 167, 69, .1);
    color: var(--green-dark);
    font-weight: 900;
}
.dashboard-action-card strong { font-size: 16px; }
.dashboard-action-card small { color: var(--muted); line-height: 1.35; }
.dashboard-shortcut-list,
.dashboard-feed { display: grid; gap: 10px; }
.dashboard-shortcut { display: flex; gap: 12px; align-items: center; padding: 13px; }
.dashboard-shortcut > span {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(40, 167, 69, .1);
    color: var(--green-dark);
    font-weight: 900;
}
.dashboard-shortcut strong,
.dashboard-shortcut small { display: block; }
.dashboard-shortcut small { color: var(--muted); margin-top: 2px; }
.dashboard-feed-item { display: grid; gap: 3px; padding: 13px; }
.dashboard-feed-item strong { color: var(--dark); }
.dashboard-feed-item span,
.dashboard-feed-item small { color: var(--muted); line-height: 1.35; }
.report-summary-final-content {
    display: grid;
    align-content: start;
    gap: 18px;
    padding-top: 10mm;
}
.report-summary-final-page .report-summary-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}
.report-summary-final-page .report-summary-card {
    min-height: 96px;
    padding: 18px;
}
.report-summary-final-page .report-summary-card strong { font-size: 22px; }
.report-summary-final-page .report-summary-card span,
.report-summary-final-page .report-summary-card small { font-size: 13px; }

@media (max-width: 1100px) {
    .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid-main,
    .dashboard-grid-secondary { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .dashboard-hero { grid-template-columns: 1fr; padding: 20px; }
    .dashboard-hero-side { justify-items: start; }
    .dashboard-metrics,
    .dashboard-action-grid { grid-template-columns: 1fr; }
}
@media print {
    .report-summary-final-page .report-summary-grid { grid-template-columns: 1fr; }
    .report-summary-final-page .report-summary-card {
        padding: 14px;
        min-height: 70px;
    }
    .report-summary-final-page .report-summary-card strong { font-size: 18px; }
    .report-summary-final-page .report-summary-card span,
    .report-summary-final-page .report-summary-card small { font-size: 11px; }
}

/* Stage 6+9 hotfix 2: pulpit, topbar, raporty w jednej karcie */
.content-area > section,
.content-area > .panel,
.content-area > .table-wrap {
    margin-bottom: 24px;
}
.content-area > section:last-child,
.content-area > .panel:last-child,
.content-area > .table-wrap:last-child {
    margin-bottom: 0;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) auto minmax(260px, 1fr);
    justify-content: stretch;
    gap: 16px;
}
.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.topbar-right { justify-content: flex-end; }
.system-version-box {
    display: grid;
    gap: 2px;
    line-height: 1.05;
    padding: 8px 12px;
    border: 1px solid rgba(40, 167, 69, .18);
    border-radius: 14px;
    background: rgba(255,255,255,.72);
    min-width: 142px;
}
.system-version-box span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .045em;
}
.system-version-box strong {
    color: var(--green-dark);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .035em;
}
.topbar-clock {
    justify-self: center;
    align-self: center;
    min-width: 132px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--green-dark);
    font-size: clamp(24px, 2.4vw, 34px);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    font-weight: 950;
    letter-spacing: .055em;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255,255,255,.72);
}

.dashboard-hero,
.dashboard-metrics,
.dashboard-grid-main,
.dashboard-grid-secondary {
    margin-bottom: 24px;
}
.dashboard-hero { padding: 30px; }
.dashboard-hero h1 { margin-bottom: 0; }
.dashboard-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}
.dashboard-grid-main,
.dashboard-grid-secondary {
    grid-template-columns: 1fr;
    gap: 24px;
}
.dashboard-panel {
    min-height: auto;
    padding: 24px;
}
.dashboard-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.dashboard-shortcut-list,
.dashboard-feed { gap: 12px; }

.report-cards {
    grid-template-columns: 1fr;
    gap: 24px;
}
.report-card { padding: 24px; }
.report-card + .report-card { margin-top: 0; }
.report-filter-form { gap: 18px; }
.report-filter-form .modal-action-row { margin-top: 4px; }

@media (max-width: 1100px) {
    .topbar {
        grid-template-columns: 1fr auto;
    }
    .topbar-clock {
        order: 3;
        grid-column: 1 / -1;
        justify-self: center;
    }
    .topbar-left { justify-content: flex-start; }
    .topbar-right { justify-content: flex-end; }
    .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .topbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    .topbar-left,
    .topbar-right {
        justify-content: space-between;
        width: 100%;
    }
    .topbar-clock {
        grid-column: auto;
        order: 0;
        width: 100%;
    }
    .dashboard-metrics,
    .dashboard-action-grid { grid-template-columns: 1fr; }
    .dashboard-panel,
    .report-card { padding: 18px; }
}

/* Zamówienia — kreator / robocze / rejestry */
.order-wizard-panel { overflow: visible; }
.order-wizard-form { gap: 18px; }
.order-step-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: #fff;
}
.order-step-card h2 { margin-top: 0; }
.compact-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.order-procedure-preview {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 12px 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #f8f9fa;
}
.order-procedure-preview strong { color: var(--green-dark); }
.order-procedure-preview small { color: #b42318; }
.order-item-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 120px 120px;
    gap: 10px;
    margin-bottom: 10px;
}
.order-number-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
    padding: 14px 16px;
    border: 1px solid rgba(40, 167, 69, .22);
    border-radius: 16px;
    background: rgba(40, 167, 69, .06);
}
.order-number-hint strong { font-size: 18px; }
.order-number-hint small { flex-basis: 100%; color: #6c757d; }
.order-table .table-actions { min-width: 210px; }
.badge-robocze { background: #eef2ff; color: #3538cd; }
.badge-gotowe-do-zatwierdzenia { background: #fff7e6; color: #996400; }
.badge-zatwierdzone { background: #e9f8ef; color: #1f7a3a; }
.badge-w-toku { background: #e7f1ff; color: #0b5ed7; }
.badge-zrealizowane { background: #e9f8ef; color: #1f7a3a; }
.badge-anulowane { background: #ffecef; color: #8a1020; }
@media (max-width: 780px) {
    .order-item-row { grid-template-columns: 1fr; }
}
.required-star { color: #dc3545; font-weight: 900; margin-left: 2px; }
.readonly-input { background: #f1f3f5 !important; color: #495057; cursor: not-allowed; }
.field-help { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.order-criteria-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 160px;
    gap: 10px;
    margin-bottom: 10px;
}
.order-criteria-summary {
    margin: 8px 0 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}
.danger-text { color: #dc3545 !important; }
.order-wizard-form .alert-info {
    margin: 0 0 14px;
}
.order-item-row label,
.order-criteria-row label {
    margin: 0;
}
@media (max-width: 780px) {
    .order-criteria-row { grid-template-columns: 1fr; }
}
.alert-info {
    background: #eef7ff;
    color: #17496b;
    border: 1px solid #cfe8ff;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 700;
}

/* Zamówienia FIX3 — kreator ekran po ekranie */
.order-stepper-form {
    display: block;
    max-width: 1180px;
    margin: 0 auto;
}
.order-wizard-topline {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}
.order-step-pill {
    border-radius: 999px;
    padding: 8px 13px;
    background: rgba(40, 167, 69, .12);
    color: var(--green-dark);
    font-weight: 900;
    white-space: nowrap;
}
.order-step-current {
    font-size: 18px;
    font-weight: 900;
    color: var(--text);
}
.order-step-route {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 12px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}
.order-progress-bar {
    height: 8px;
    border-radius: 999px;
    background: #eef0f2;
    overflow: hidden;
    margin-bottom: 20px;
}
.order-progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--green);
    transition: width .18s ease;
}
.order-wizard-step {
    display: none;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    background: #fff;
    box-shadow: 0 12px 26px rgba(0,0,0,.055);
}
.order-wizard-step.is-active { display: block; }
.order-wizard-step h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.order-type-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}
.order-type-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: #fff;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    box-shadow: 0 7px 16px rgba(0,0,0,.045);
    min-height: 132px;
}
.order-type-card b {
    display: block;
    font-size: 16px;
    margin-bottom: 8px;
}
.order-type-card small {
    color: var(--muted);
    font-weight: 700;
    line-height: 1.35;
}
.order-type-card.active {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(40, 167, 69, .16), 0 10px 20px rgba(0,0,0,.06);
}
.order-clean-grid {
    display: grid;
    gap: 16px;
    align-items: start;
}
.order-clean-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.order-clean-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.order-clean-grid label,
.order-wizard-step label {
    font-weight: 900;
}
.order-clean-grid input,
.order-clean-grid select,
.order-clean-grid textarea,
.order-wizard-step input,
.order-wizard-step select,
.order-wizard-step textarea {
    margin-top: 6px;
}
.order-procedure-preview.large {
    margin-top: 18px;
    padding: 16px;
    font-size: 15px;
}
.order-procedure-preview.large strong { font-size: 22px; }
.order-readonly-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid rgba(40, 167, 69, .24);
    border-radius: 14px;
    padding: 14px 16px;
    background: rgba(40, 167, 69, .06);
    margin-bottom: 18px;
    max-width: 360px;
}
.order-readonly-choice span { color: var(--muted); font-weight: 900; }
.order-readonly-choice b { color: var(--green-dark); font-size: 18px; }
.order-step-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.order-step-actions .btn-outline:first-child { margin-right: auto; }
.is-procedure-hidden { display: none !important; }
.order-contractor-picker { position: relative; }
.order-contractor-picker .picker-results {
    position: absolute;
    z-index: 50;
    left: 0;
    right: 0;
    top: calc(100% - 4px);
    max-height: 300px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 16px 34px rgba(0,0,0,.16);
    padding: 6px;
}
.order-contractor-picker .picker-item {
    width: 100%;
    display: block;
    text-align: left;
    border: 0;
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    cursor: pointer;
}
.order-contractor-picker .picker-item:hover { background: #f3f8f5; }
.order-contractor-picker .picker-item b,
.order-contractor-picker .picker-item small { display: block; }
.order-contractor-picker .picker-item small { color: var(--muted); margin-top: 3px; }
.order-contractor-picker .picker-empty { padding: 10px 12px; color: var(--muted); font-weight: 800; }
.field-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, .14) !important;
}
.order-stepper-form .form-message { margin-top: 14px; }
@media (max-width: 980px) {
    .order-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .order-clean-grid.two,
    .order-clean-grid.three { grid-template-columns: 1fr; }
    .order-wizard-topline { grid-template-columns: 1fr; }
    .order-step-route { justify-self: flex-start; white-space: normal; }
}
@media (max-width: 620px) {
    .order-type-grid { grid-template-columns: 1fr; }
    .order-wizard-step { padding: 18px; }
    .order-step-actions { flex-direction: column-reverse; }
    .order-step-actions .btn { width: 100%; }
}

/* Zamówienia FIX4 — modal wykonawcy, pozycje bez powielania nagłówków, podgląd roboczych */
.order-field-block {
    font-weight: 900;
}
.order-field-block .btn {
    margin-top: 8px;
}
.order-picked-contractor {
    margin-top: 6px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8f9fa;
    color: var(--muted);
    font-weight: 800;
    min-height: 44px;
}
.contractor-modal-results {
    position: static !important;
    display: block;
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 8px;
    margin-top: 12px;
}
.contractor-modal-results.hidden { display: none; }
.contractor-modal-results .picker-item {
    width: 100%;
    display: block;
    text-align: left;
    border: 0;
    border-radius: 10px;
    background: #fff;
    padding: 12px;
    cursor: pointer;
}
.contractor-modal-results .picker-item:hover { background: #f3f8f5; }
.contractor-modal-results .picker-item b,
.contractor-modal-results .picker-item small { display: block; }
.contractor-modal-results .picker-item small { color: var(--muted); margin-top: 3px; }
.order-items-table {
    margin-top: 10px;
}
.order-item-header,
.order-item-row {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 120px 120px 86px;
    gap: 10px;
    align-items: end;
}
.order-item-header {
    font-weight: 900;
    margin-bottom: 6px;
    padding: 0 2px;
}
.order-item-row {
    margin-bottom: 10px;
}
.order-item-row input,
.order-item-row select { margin-top: 0 !important; }
.order-criteria-row {
    grid-template-columns: minmax(260px, 1fr) 160px 86px;
    align-items: end;
}
.order-click-row { cursor: pointer; }
.order-click-row:hover { background: rgba(40, 167, 69, .055); }
.order-drafts-table td { vertical-align: middle; }
.order-draft-modal-card { width: min(900px, 100%); }
.order-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.order-detail-grid > div {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: #f8f9fa;
}
.order-detail-grid small {
    display: block;
    color: var(--muted);
    font-weight: 900;
    margin-bottom: 4px;
}
.order-detail-grid b { word-break: break-word; }
.order-detail-section {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 14px;
}
.order-detail-section h3 { margin: 0 0 8px; }
.order-history-details {
    border-top: 1px solid var(--border);
    margin-top: 14px;
    padding-top: 14px;
}
.order-history-details summary {
    cursor: pointer;
    font-weight: 900;
}
.order-history-details summary small { color: var(--muted); margin-left: 6px; }
.order-modal-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}
.print-document {
    max-width: 980px;
    margin: 0 auto;
}
.print-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-bottom: 18px;
}
@media print {
    .no-print, .sidebar, .topbar, .page-head { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    .panel.print-document { box-shadow: none !important; border: 0 !important; padding: 0 !important; }
}
@media (max-width: 780px) {
    .order-item-header { display: none; }
    .order-item-row { grid-template-columns: 1fr; }
    .order-criteria-row { grid-template-columns: 1fr; }
    .order-detail-grid { grid-template-columns: 1fr; }
}


/* Zamówienia — ujednolicenie modala roboczych z fakturami/korespondencją */
.order-draft-modal-card {
    width: min(900px, 100%);
    padding-top: 28px;
}
.order-preview-head {
    padding-right: 48px;
}
.order-preview-number {
    max-width: 260px;
    overflow-wrap: anywhere;
    white-space: normal;
    text-align: right;
}
.order-detail-grid.invoice-preview-grid {
    margin: 14px 0 0;
}
.order-detail-grid.invoice-preview-grid > div {
    background: #fff;
    border-radius: 14px;
    padding: 11px 12px;
}
.order-detail-grid.invoice-preview-grid small {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 7px;
}
.order-detail-section {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    margin-top: 12px;
}
.order-detail-section h3 {
    margin: 0 0 8px;
    font-size: 15px;
}
.order-history-details {
    margin-top: 12px;
    padding-top: 0;
    border-top: 0;
}
.order-modal-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
@media (max-width: 980px) {
    .order-preview-head {
        padding-right: 0;
    }
    .order-preview-number {
        max-width: none;
        text-align: center;
    }
}

/* Zamówienia FIX6 — filtry, gwiazdki i jednolite tabele */
.required-star {
    display: inline !important;
    vertical-align: baseline;
    line-height: inherit;
    white-space: nowrap;
}
.order-wizard-step label,
.order-clean-grid label,
.order-field-block {
    line-height: 1.35;
}
.order-filter-panel {
    margin-bottom: 14px;
}
.order-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) repeat(6, minmax(130px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}
.order-filter-grid label {
    font-size: 12px;
    font-weight: 900;
    color: var(--muted);
}
.order-filter-grid input,
.order-filter-grid select {
    margin-top: 5px;
}
.hidden-by-order-filter {
    display: none !important;
}
.order-active-table td,
.order-drafts-table td {
    vertical-align: middle;
}
.order-requests-active-section {
    margin-top: 18px;
    margin-bottom: -4px;
    padding-bottom: 8px;
    box-shadow: none;
}
@media (max-width: 1200px) {
    .order-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .order-filter-grid { grid-template-columns: 1fr; }
}

/* Zamówienia FIX8 — poprawka gwiazdek w kreatorze i statusu wycofania */
.order-wizard-step label,
.order-clean-grid label,
.order-criteria-row label {
    display: block !important;
}
.order-wizard-step label > input,
.order-wizard-step label > select,
.order-wizard-step label > textarea,
.order-clean-grid label > input,
.order-clean-grid label > select,
.order-clean-grid label > textarea,
.order-criteria-row label > input,
.order-criteria-row label > select,
.order-criteria-row label > textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
}
.order-wizard-step .required-star,
.order-clean-grid .required-star,
.order-criteria-row .required-star,
.order-item-header .required-star {
    display: inline !important;
    margin-left: 3px;
    white-space: nowrap;
    vertical-align: baseline;
}
.badge-wycofane { background: #f1f3f5; color: #495057; }

/* Zamówienia - wydruki A4 pionowo */
.order-print-body {
    background: #fff;
    color: #111;
    font-family: Arial, Helvetica, sans-serif;
    padding: 18px;
}
.order-print-body .order-doc-page {
    width: 210mm !important;
    min-height: 297mm !important;
    height: auto !important;
    margin: 0 auto 18px !important;
    padding: 10mm !important;
    display: grid !important;
    grid-template-rows: auto 1fr auto !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    background: #fff !important;
}
.order-doc-header {
    display: grid;
    grid-template-columns: 1fr 1.8fr 28mm;
    align-items: start;
    gap: 8mm;
    margin-bottom: 10mm;
}
.order-doc-header h1 {
    text-align: center;
    font-size: 21px;
    line-height: 1.12;
    margin: 9mm 0 0;
    font-weight: 800;
    letter-spacing: .2px;
    text-transform: uppercase;
}
.order-doc-unit {
    font-size: 13px;
    line-height: 1.3;
}
.order-doc-unit > span {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
}
.order-doc-unit-name {
    font-weight: 800;
}
.order-doc-logo-box {
    width: 26mm;
    min-height: 24mm;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}
.order-doc-logo-box img {
    max-width: 25mm;
    max-height: 25mm;
    object-fit: contain;
}
.order-doc-content {
    min-height: 0;
}
.order-print-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0 0 8mm;
    font-size: 13px;
    line-height: 1.28;
}
.order-print-table th,
.order-print-table td {
    border: 1.4px solid #111;
    padding: 4mm 3mm;
    vertical-align: top;
}
.order-print-table th {
    width: 30%;
    text-align: left;
    font-weight: 800;
    background: #e6e6e6;
}
.order-print-table td {
    background: #fff;
}
.order-print-table-large th,
.order-print-table-large td {
    padding: 5mm 4mm;
}
.order-print-section-row th {
    background: #e6e6e6 !important;
    font-size: 14px;
    padding: 3.5mm 3mm;
    text-align: left;
}
.order-print-strong {
    font-weight: 800;
}
.order-party-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8mm;
    margin: 0 0 8mm;
}
.order-party-box {
    border: 1.4px solid #111;
    min-height: 30mm;
    font-size: 13px;
    line-height: 1.3;
}
.order-party-box h3 {
    margin: 0;
    padding: 3mm;
    font-size: 14px;
    background: #e6e6e6;
    border-bottom: 1.4px solid #111;
}
.order-party-box p {
    margin: 0;
    padding: 0 3mm 1.5mm;
}
.order-party-box h3 + p {
    padding-top: 3mm;
}
.order-party-box .strong {
    font-weight: 800;
}
.order-items-table th,
.order-items-table td {
    padding: 2mm 2.2mm;
}
.order-items-table tr:not(.order-print-section-row) th:nth-child(1),
.order-items-table tr:not(.order-print-section-row) td:nth-child(1) { width: 10%; }
.order-items-table tr:not(.order-print-section-row) th:nth-child(3),
.order-items-table tr:not(.order-print-section-row) td:nth-child(3) { width: 13%; }
.order-items-table tr:not(.order-print-section-row) th:nth-child(4),
.order-items-table tr:not(.order-print-section-row) td:nth-child(4) { width: 13%; }
.order-bottom-grid .order-party-box { min-height: 22mm; }
.order-signature-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(48mm, 1fr));
    gap: 5mm;
    margin-top: 12mm;
}
.order-signature-box {
    border: 1.4px solid #111;
    height: 35mm;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
    padding: 4mm;
    box-sizing: border-box;
    white-space: pre-line;
    font-size: 12px;
}
.order-signature-line,
.order-single-signature .order-signature-line {
    width: 90%;
    border-top: 1.2px solid #111;
    margin-bottom: 3mm;
}
.order-sign-cell {
    height: 48mm;
}
.order-single-signature {
    min-height: 38mm;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
}
.order-doc-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8mm;
    align-items: end;
    border-top: 1.2px solid #111;
    padding-top: 4mm;
    margin-top: 8mm;
    font-size: 10px;
}
.order-doc-footer > div:last-child {
    text-align: right;
}
.order-doc-footer img {
    max-width: 25mm;
    max-height: 8mm;
    object-fit: contain;
    margin-top: 1mm;
}
.order-print-message {
    border: 1px solid #d0d7de;
    padding: 12mm;
    font-size: 15px;
    text-align: center;
}
@media print {
    @page { size: A4 portrait; margin: 0; }
    html, body.order-print-body {
        width: 210mm !important;
        min-height: 297mm !important;
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .order-print-body .order-doc-page {
        width: 210mm !important;
        min-height: 297mm !important;
        margin: 0 !important;
        padding: 10mm !important;
        page-break-after: always;
        break-after: page;
    }
    .order-print-body .order-doc-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }
    .order-print-table th,
    .order-print-table td,
    .order-print-section-row th,
    .order-party-box h3 {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .report-print-actions,
    .no-print {
        display: none !important;
    }
}

/* Zamówienia - korekta wydruków FIX10: bardziej zwarte A4 i czyszczenie przepełnień */
.order-print-body { padding: 8px; }
.order-print-body .order-doc-page {
    padding: 8mm !important;
    margin-bottom: 8px !important;
}
.order-doc-header {
    grid-template-columns: 1fr 1.7fr 24mm;
    gap: 6mm;
    margin-bottom: 6mm;
}
.order-doc-header h1 {
    font-size: 18px;
    margin-top: 5mm;
    line-height: 1.08;
}
.order-doc-unit {
    font-size: 11px;
    line-height: 1.22;
}
.order-doc-unit > span { font-size: 10px; }
.order-doc-logo-box { width: 23mm; min-height: 21mm; }
.order-doc-logo-box img { max-width: 22mm; max-height: 22mm; }
.order-print-table {
    margin-bottom: 5mm;
    font-size: 11px;
    line-height: 1.18;
}
.order-print-table th,
.order-print-table td {
    padding: 2.2mm 2.4mm;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.order-print-table-large th,
.order-print-table-large td { padding: 2.5mm 2.6mm; }
.order-print-section-row th {
    font-size: 11.5px;
    padding: 2.2mm 2.4mm;
}
.order-party-grid {
    gap: 5mm;
    margin-bottom: 5mm;
}
.order-party-box {
    min-height: 20mm;
    font-size: 11px;
    line-height: 1.18;
}
.order-party-box h3 {
    font-size: 11.5px;
    padding: 2mm 2.4mm;
}
.order-party-box p { padding: 0 2.4mm 1mm; }
.order-party-box h3 + p { padding-top: 2mm; }
.order-items-table th,
.order-items-table td { padding: 1.3mm 1.6mm; }
.order-bottom-grid .order-party-box { min-height: 17mm; }
.order-signature-row {
    gap: 4mm;
    margin-top: 7mm;
}
.order-signature-box {
    height: 25mm;
    padding: 3mm;
    font-size: 10.5px;
}
.order-signature-line,
.order-single-signature .order-signature-line { margin-bottom: 2mm; }
.order-sign-cell { height: 35mm; }
.order-single-signature { min-height: 30mm; font-size: 11px; }
.order-doc-footer {
    padding-top: 2.5mm;
    margin-top: 5mm;
    font-size: 9px;
}
.order-doc-footer img { max-height: 6mm; }
@media print {
    .order-print-body .order-doc-page { padding: 8mm !important; }
}
.order-protocol-form .order-detail-section { margin-top: 18px; }
.order-checkbox-list { display: grid; gap: 8px; margin: 10px 0 14px; }
.order-checkbox-list .checkline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.order-checkbox-list .checkline input { width: auto; }

.order-protocol-subhead {
    display: grid;
    gap: 3px;
    margin: 8px 0 10px;
}
.order-protocol-subhead small {
    color: var(--muted);
    font-size: 12px;
}
.order-protocol-query-table {
    display: grid;
    gap: 8px;
}
.order-protocol-query-head,
.order-protocol-query-row {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(180px, 260px) auto;
    gap: 10px;
    align-items: center;
}
.order-protocol-query-head {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    padding: 0 2px;
}
.order-protocol-query-row .btn-small {
    white-space: nowrap;
    padding: 8px 12px;
}
.order-protocol-offer-head { margin-top: 18px; }
.order-protocol-offers {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fbfcfd;
}
.order-protocol-offer-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 650;
}
.order-protocol-offer-line input { width: auto; }
.order-request-source-details { margin-top: 16px; }
.order-request-source-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-top: 12px;
}
.order-request-source-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    background: #fff;
}
.order-request-source-card.full { grid-column: 1 / -1; }
.order-request-source-card small {
    display: block;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.order-request-source-card p { margin: 0; white-space: normal; }
@media (max-width: 900px) {
    .order-protocol-query-head { display: none; }
    .order-protocol-query-row { grid-template-columns: 1fr; }
    .order-request-source-grid { grid-template-columns: 1fr; }
}

/* Zamówienia — raporty FIX16: A4 poziomo */
.order-report-cards {
    grid-template-columns: repeat(2, minmax(320px, 1fr));
}
.order-report-card .muted {
    margin-top: -4px;
}
.order-report-print-page {
    background: #f5f7f8;
}
.order-report-print-page .order-report-page {
    width: 279mm !important;
    min-height: 192mm !important;
    height: 192mm !important;
    max-height: 192mm !important;
    display: grid !important;
    grid-template-rows: 16mm 158mm 18mm !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    overflow: hidden !important;
}
.order-report-print-page .report-page-header {
    height: 16mm !important;
    min-height: 16mm !important;
    max-height: 16mm !important;
}
.order-report-print-page .report-page-content {
    height: 158mm !important;
    min-height: 158mm !important;
    max-height: 158mm !important;
    padding: 2.5mm 0 !important;
    overflow: hidden !important;
}
.order-report-print-page .report-page-footer {
    height: 18mm !important;
    min-height: 18mm !important;
    max-height: 18mm !important;
}
.order-report-table {
    table-layout: fixed !important;
    font-size: 7.6px !important;
    line-height: 1.08 !important;
}
.order-report-table th,
.order-report-table td {
    padding: 2.1px 2.4px !important;
    overflow: hidden !important;
}
.order-report-table th {
    font-size: 5.9px !important;
    line-height: .96 !important;
}
.order-report-table tbody tr,
.order-report-table tbody td {
    height: 14.7mm !important;
    max-height: 14.7mm !important;
    vertical-align: top !important;
}
.order-report-table th:nth-child(1) { width: 8mm; }
.order-report-table th:nth-child(2) { width: 36mm; }
.order-report-table th:nth-child(3) { width: 74mm; }
.order-report-table th:nth-child(4) { width: 25mm; }
.order-report-table th:nth-child(5) { width: 59mm; }
.order-report-table th:nth-child(6) { width: 24mm; }
.order-report-table th:nth-child(7) { width: 24mm; }
.order-report-table th:nth-child(8) { width: 26mm; }
.order-report-number-cell b {
    display: block;
    font-size: 7px;
    line-height: 1.08;
}
.order-report-number-cell small {
    display: block;
    font-size: 6.2px;
    margin-top: 1px;
}

@media (max-width: 1100px) {
    .order-report-cards { grid-template-columns: 1fr; }
}

@media print {
    html,
    body.order-report-print-page {
        width: auto !important;
        min-height: 192mm !important;
        background: #fff !important;
    }
    body.order-report-print-page {
        padding: 0 !important;
        margin: 0 !important;
    }
    .order-report-print-page .order-report-page {
        width: 279mm !important;
        height: 192mm !important;
        min-height: 192mm !important;
        max-height: 192mm !important;
        margin: 0 !important;
        page-break-after: always !important;
        break-after: page !important;
    }
    .order-report-print-page .order-report-page:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }
}

.btn-link {
    border-color: transparent;
    background: transparent;
    color: var(--green-dark);
    padding-inline: 8px;
}
.btn-link:hover {
    color: var(--green);
    text-decoration: underline;
}
.login-reset-link {
    margin-top: 12px;
    width: 100%;
}
.modal-small {
    width: min(520px, 100%);
}

/* VERTIS 2.0 — dokumentowy podgląd faktury KSeF */
.ksef-preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.ksef-preview-toolbar h2 {
    margin: 0;
}
.invoice-ksef-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
}
.ksef-document {
    background: #fff;
    color: #000;
    max-width: 1120px;
    margin: 0 auto;
    padding: 30px 36px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    line-height: 1.35;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.08);
}
.ksef-document-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.55fr);
    gap: 24px;
    align-items: start;
    border-bottom: 1px solid #cfd3d7;
    padding-bottom: 18px;
    margin-bottom: 16px;
}
.ksef-document-brand {
    font-size: 22px;
    margin-top: 4px;
}
.ksef-document-brand span {
    color: #d60000;
    font-weight: 800;
}
.ksef-document-title {
    text-align: right;
}
.ksef-document-title h2 {
    margin: 0 0 2px;
    font-size: 24px;
    color: #000;
}
.ksef-document-title p {
    margin: 2px 0;
}
.ksef-document-subjects {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
    border-bottom: 1px solid #cfd3d7;
    padding-bottom: 16px;
    margin-bottom: 16px;
}
.ksef-document-subject h3,
.ksef-document-section h3 {
    margin: 0 0 7px;
    font-size: 17px;
    color: #000;
}
.ksef-document-subject p,
.ksef-document-section p {
    margin: 2px 0;
}
.ksef-document-section {
    border-bottom: 1px solid #cfd3d7;
    padding-bottom: 16px;
    margin-bottom: 16px;
}
.ksef-document-third-section > h3 {
    margin-bottom: 10px;
}
.ksef-document-subjects-third {
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 0;
}
.ksef-document-subjects-third .ksef-document-subject {
    break-inside: avoid;
}
.ksef-document-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 12px;
}
.ksef-document-table th,
.ksef-document-table td {
    border: 1px solid #b8bdc2;
    padding: 6px 8px;
    vertical-align: top;
}
.ksef-document-table th {
    background: #f1f3f5;
    text-align: left;
    font-weight: 700;
}
.ksef-document-table .num,
.ksef-document-total {
    text-align: right;
}
.ksef-document-total {
    margin: 12px 0 0;
    font-size: 14px;
}
.ksef-document-empty {
    border: 1px dashed #b8bdc2;
    padding: 10px;
    color: #495057;
}
.ksef-document-wz {
    max-width: 380px;
}
@media (max-width: 900px) {
    .ksef-document {
        padding: 20px 16px;
    }
    .ksef-document-header,
    .ksef-document-subjects {
        grid-template-columns: 1fr;
    }
    .ksef-document-title {
        text-align: left;
    }
}
@media print {
    body.ksef-printing * {
        visibility: hidden !important;
    }
    body.ksef-printing #ksefPreviewModal,
    body.ksef-printing #ksefPreviewModal * {
        visibility: visible !important;
    }
    body.ksef-printing #ksefPreviewModal {
        position: static !important;
        inset: auto !important;
        display: block !important;
        background: #fff !important;
        padding: 0 !important;
    }
    body.ksef-printing #ksefPreviewModal .modal-card {
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        box-shadow: none !important;
        border: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    body.ksef-printing #ksefPreviewModal .modal-close,
    body.ksef-printing #ksefPreviewModal .ksef-preview-toolbar,
    body.ksef-printing #ksefPreviewModal .ksef-preview-meta,
    body.ksef-printing #ksefPreviewModal .form-message,
    body.ksef-printing #ksefPreviewModal .empty {
        display: none !important;
    }
    body.ksef-printing #ksefPreviewModal .ksef-preview-content {
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }
    body.ksef-printing .ksef-document {
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        width: 100% !important;
        font-size: 10.5pt !important;
    }
    body.ksef-printing .ksef-document-section,
    body.ksef-printing .ksef-document-subjects,
    body.ksef-printing .ksef-document-header {
        break-inside: avoid;
    }
    body.ksef-printing .ksef-document-table {
        page-break-inside: auto;
    }
    body.ksef-printing .ksef-document-table tr {
        break-inside: avoid;
    }
}

.form-message.warning { color: #9a6700; }
.badge-warning { background: #fff3cd; color: #664d03; border-color: #ffecb5; }
.ksef-log-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.ksef-log-summary-grid div { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fff; }
.ksef-log-summary-grid span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.ksef-log-summary-grid b { display: block; font-size: 14px; }
.ksef-log-items-table td { vertical-align: top; }
.technical-details summary { cursor: pointer; font-weight: 700; }
.technical-json { max-width: 520px; max-height: 260px; overflow: auto; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #f8f9fa; font-size: 12px; white-space: pre-wrap; }

/* Faktury — korekta listy: badge KSeF, Podmiot3 i proporcje kolumn */
.invoices-table:not(.invoices-table-no-check) th:nth-child(3),
.invoices-table:not(.invoices-table-no-check) td:nth-child(3) {
    width: 92px !important;
    min-width: 92px !important;
}
.invoices-table-no-check th:nth-child(2),
.invoices-table-no-check td:nth-child(2) {
    width: 92px !important;
    min-width: 92px !important;
}
.invoices-table:not(.invoices-table-no-check) th:nth-child(7),
.invoices-table:not(.invoices-table-no-check) td:nth-child(7),
.invoices-table-no-check th:nth-child(6),
.invoices-table-no-check td:nth-child(6) {
    width: auto !important;
}
.date-cell .invoice-source-line {
    margin-top: 4px;
}
.date-cell .invoice-source-line .badge {
    line-height: 1;
    padding: 3px 7px;
}
.document-cell .ksef-number-line {
    display: block;
    font-size: 9.5px;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: #65717d;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    max-width: 100%;
}
.contractor-cell .contractor-third-subject {
    margin-top: 4px;
    color: #65717d;
    font-size: 11px;
    line-height: 1.22;
    font-weight: 700;
}
