:root {
    --sky-card-blue: #5b79ac;
    --sky-app-bg: #f3f5f7;
    --sky-sidebar-bg: #171b20;
    --sky-sidebar-hover: #242a31;
    --sky-sidebar-active: #303740;
    --sky-border: #dfe3e8;
    --sky-text: #1c2530;
    --sky-muted: #667382;
    --tblr-font-sans-serif: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --tblr-primary: #2563eb;
    --tblr-primary-rgb: 37, 99, 235;
    --tblr-border-radius: 6px;
    --tblr-border-radius-lg: 8px;
    --tblr-navbar-vertical-width: 15rem;
    --a5-page-width: 148mm;
    --a5-page-height: 210mm;
    --a5-page-margin: 5mm;
    /* Korekta druku dwustronnego: przesunięcie REWERSU w poziomie. Drukarki mają
       nierówne marginesy lewy/prawy, więc po odwróceniu kartki rewers rozjeżdża się
       z awersem o dwukrotność tego offsetu. Wartość ustawia operator w Ustawieniach
       (zapis w localStorage — zależy od konkretnej drukarki, nie od danych). */
    --duplex-offset-x: 0mm;
    --a5-preview-bottom-padding: 5mm;
    --a5-print-area-height: 210mm;
    --a5-section-gap: 3mm;
    --a5-system-section-height: 136mm;
    --a5-main-section-height: 71mm;
    --a5-card-font-size: 10.5px;
    --a5-inspection-row-height: 6mm;
    --a5-data-cell-padding: 2px;
    --a5-owner-horizontal-padding: 6px;
}

body {
    font-family: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--sky-app-bg);
    color: var(--sky-text);
}

/* --- Ekran logowania --- */
/* Do czasu potwierdzenia sesji ukrywamy i aplikację, i formularz (brak mignięcia treści). */
html.auth-pending #app-container,
html.auth-pending #login-screen { visibility: hidden; }
html.auth-required #app-container { display: none !important; }
html:not(.auth-required) #login-screen { display: none; }

#login-screen {
    align-items: center;
    background: #edf0f3;
    display: flex;
    /* kolumna: karta logowania, a pod nią wersja na szarym tle */
    flex-direction: column;
    inset: 0;
    justify-content: center;
    padding: 1.5rem;
    position: fixed;
    z-index: 2000;
}

.login-box-sm {
    background: #fff;
    border: 1px solid var(--sky-border);
    border-radius: 8px;
    box-shadow: 0 20px 45px rgba(25, 35, 48, .12);
    max-width: 380px;
    padding: 2rem 2.25rem;
    width: 100%;
}

.login-brand {
    align-items: center;
    color: var(--sky-text);
    display: flex;
    font-size: 1.5rem;
    font-weight: 700;
    gap: .65rem;
    justify-content: center;
}

.login-brand i {
    align-items: center;
    background: #2fb344;
    border-radius: 7px;
    color: #fff;
    display: inline-flex;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.login-sub {
    color: var(--sky-muted);
    font-size: .875rem;
    margin: .55rem 0 1.75rem;
    text-align: center;
}

.app-sidebar.navbar-vertical {
    background: var(--sky-sidebar-bg);
    border-right: 0;
}

.app-sidebar .navbar-brand {
    height: 72px;
    padding: 0 .75rem;
}

.brand-link {
    align-items: center;
    color: #fff;
    display: flex;
    gap: .7rem;
    text-decoration: none;
}

.brand-link:hover {
    color: #fff;
}

.brand-link strong,
.brand-link small {
    display: block;
    letter-spacing: 0;
    line-height: 1.15;
}

.brand-link strong {
    font-size: 1.05rem;
    font-weight: 700;
}

.brand-link small {
    color: rgba(255, 255, 255, .48);
    font-size: .68rem;
    font-weight: 500;
    margin-top: .2rem;
}

.brand-mark {
    align-items: center;
    background: #2fb344;
    border-radius: 7px;
    color: #fff;
    display: inline-flex;
    flex: 0 0 36px;
    font-size: 1.1rem;
    height: 36px;
    justify-content: center;
}

.app-sidebar .navbar-nav {
    gap: 2px;
}

.app-sidebar .nav-link {
    border-radius: 6px;
    color: rgba(255, 255, 255, .68);
    margin: 0 .65rem;
    min-height: 42px;
    padding: .65rem .75rem;
}

.app-sidebar .nav-link:hover {
    background: var(--sky-sidebar-hover);
    color: #fff;
}

.app-sidebar .nav-link.active {
    background: var(--sky-sidebar-active);
    color: #fff;
    font-weight: 600;
}

.app-sidebar .nav-link-icon {
    color: inherit;
    font-size: 1rem;
    margin-right: .7rem;
    width: 1.25rem;
}

.nav-section-label {
    color: rgba(255, 255, 255, .36);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: 0;
    list-style: none;
    padding: 1.15rem 1.4rem .4rem;
    text-transform: uppercase;
}

.page-wrapper {
    background: var(--sky-app-bg);
}

.app-topbar {
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--sky-border);
    min-height: 72px;
    padding: .7rem 0;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-topbar .container-xl {
    align-items: center;
    display: flex;
    gap: 1rem;
}

.page-heading {
    flex: 0 0 auto;
    min-width: 9rem;
}

.page-pretitle {
    color: var(--sky-muted);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
}

.page-title {
    color: var(--sky-text);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.25;
    margin: .15rem 0 0;
}

.page-body {
    padding: 1.5rem 0 2rem;
}

.header-actions {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    gap: .5rem;
    justify-content: flex-end;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.header-actions::-webkit-scrollbar {
    display: none;
}

.header-actions .btn {
    align-items: center;
    display: inline-flex;
    gap: .4rem;
}

.user-chip {
    align-items: center;
    border-left: 1px solid var(--sky-border);
    display: flex;
    gap: .45rem;
    margin-left: .25rem;
    padding-left: .75rem;
}

.user-chip .avatar {
    background: #e8edf2;
    color: #465362;
}

.user-chip-label {
    color: var(--sky-muted);
    font-size: .78rem;
    max-width: 13rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.card {
    border-color: var(--sky-border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(25, 35, 48, .04);
}

.card-header {
    background: #fff;
    border-bottom-color: var(--sky-border);
    min-height: 3.5rem;
}

.card-title {
    color: var(--sky-text);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0;
}

.card-kicker {
    color: var(--sky-muted);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: 0;
    margin-bottom: .1rem;
    text-transform: uppercase;
}

.stats-grid {
    margin-bottom: 1rem;
}

.stat-card .card-body {
    align-items: center;
    display: flex;
    gap: 1rem;
    min-height: 108px;
}

.stat-icon {
    flex: 0 0 48px;
    font-size: 1.25rem;
    height: 48px;
}

.stat-label {
    color: var(--sky-muted);
    font-size: .82rem;
    font-weight: 600;
}

.stat-value {
    color: var(--sky-text);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.1;
    margin-top: .2rem;
}

.data-table th,
.data-table td {
    border-color: #e8ebef;
    font-size: .86rem;
    vertical-align: middle;
}

.data-table thead th {
    color: #4f5d6b;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: 0;
    white-space: nowrap;
}

.data-table tbody tr {
    height: 48px;
}

.data-table tbody td:last-child {
    white-space: nowrap;
}

.sortable-col {
    cursor: pointer;
    padding-right: 1.75rem !important;
    position: relative;
    user-select: none;
}

.sort-icon {
    color: var(--sky-muted);
    font-size: .75rem;
    position: absolute;
    right: .55rem;
    top: 50%;
    transform: translateY(-50%);
}

.filter-row th {
    background: #f7f8fa;
    padding: .5rem;
}

.filter-input {
    background: #fff;
    border: 1px solid #d8dde3;
    border-radius: 5px;
    color: var(--sky-text);
    font-size: .8125rem;
    padding: .35rem .5rem;
    width: 100%;
}

.filter-input:focus {
    border-color: #8bb3f8;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .1);
    outline: 0;
}

.active-row td {
    background-color: rgba(37, 99, 235, .08) !important;
    font-weight: 600;
}

.status-badge {
    border-radius: 999px;
    display: inline-block;
    font-size: .8125rem;
    font-weight: 700;
    line-height: 1;
    padding: .35rem .6rem;
}

.status-valid {
    background: #e9f7ec;
    color: #18712c;
}

.status-warning {
    background: #fff5db;
    color: #8a5a00;
}

.status-expired {
    background: #fcebec;
    color: #9a2d33;
}

.btn-sm {
    white-space: nowrap;
}

.modal-content {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(19, 27, 36, .22);
}

.modal-header,
.modal-footer {
    border-color: var(--sky-border);
}

/* Moduł Terminy: data produkcji, z której policzono termin. Drobna i wyszarzona —
   ma pozwolić sprawdzić wyliczenie, a nie konkurować z samym terminem. */
.deadline-dom {
    margin-top: .125rem;
    font-size: .75rem;
    color: var(--sky-muted);
    white-space: nowrap;
}

/* Przekroczona wartość musi rzucać się w oczy w gęstej tabeli dat,
   dlatego nie sam kolor tekstu, ale też tło i grubość. */
.deadline-over {
    display: inline-block;
    padding: .0625rem .375rem;
    border-radius: var(--tblr-border-radius);
    background: #fde8e8;
    color: #b02a2a;
    font-weight: 600;
}

/* Picker daty produkcji — dwa widoki w jednym panelu: dekada lat, a po wybraniu
   roku dwanaście miesięcy. Panel wisi pod polem, wewnątrz modala sprzętu. */
.dom-picker {
    position: relative;
}

.dom-picker-panel {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    width: 17rem;
    max-width: 100%;
    padding: .5rem;
    background: #fff;
    border: 1px solid var(--sky-border);
    border-radius: var(--tblr-border-radius-lg);
    box-shadow: 0 12px 32px rgba(19, 27, 36, .18);
}

.dom-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .25rem;
}

.dom-picker-title,
.dom-picker-step {
    border: 0;
    background: transparent;
    border-radius: var(--tblr-border-radius);
    color: var(--sky-text);
    cursor: pointer;
    line-height: 1;
}

.dom-picker-title {
    padding: .375rem .5rem;
    font-weight: 600;
}

.dom-picker-step {
    padding: .375rem .625rem;
    font-size: 1rem;
}

.dom-picker-title:hover,
.dom-picker-step:hover:not(:disabled) {
    background: var(--sky-app-bg);
}

/* Krok "w przód" gaśnie, gdy siatka sięga już bieżącego roku — dalej nie ma czego wybierać. */
.dom-picker-step:disabled {
    opacity: .3;
    cursor: default;
}

.dom-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .125rem;
}

.dom-picker-cell {
    padding: .625rem .25rem;
    border: 0;
    border-radius: var(--tblr-border-radius);
    background: transparent;
    color: var(--sky-text);
    font-size: .875rem;
    cursor: pointer;
}

.dom-picker-cell:hover:not(:disabled) {
    background: var(--sky-app-bg);
}

/* Lata spoza wyświetlanej dekady i miesiące następnego roku — widoczne, ale wygaszone,
   dokładnie jak w pickerze Windows: wciąż można w nie kliknąć. */
.dom-picker-cell.is-muted {
    color: var(--sky-muted);
}

.dom-picker-cell.is-selected {
    background: var(--tblr-primary);
    color: #fff;
}

/* Wypełniacz po datach z przyszłości: trzyma wysokość siatki, sam pozostaje niewidoczny
   i — dzięki visibility — nie łapie kliknięć ani hoveru. */
.dom-picker-cell.is-spacer {
    visibility: hidden;
}

/* Modale słownikowe (producent, model) otwierane wprost z formularza sprzętu leżą
   na nim, a nie zamiast niego. Bootstrap daje obu ten sam z-index, więc bez tego
   formularz pod spodem świeci tak samo jasno i nie widać, który jest aktywny. */
.modal.modal-stacked {
    z-index: 1080;
}

.modal-backdrop.modal-backdrop-stacked {
    z-index: 1075;
}

.del-insp-btn {
    background: #d63939;
    border: 0;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: .7em;
    margin-left: 5px;
    padding: 2px 6px;
}

.edit-insp-btn {
    background: #2563eb;
    border: 0;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: .7em;
    padding: 2px 6px;
}

/* Physical card preview and print layout */
.physical-card {
    align-items: flex-start;
    color: #000;
    display: flex;
    flex-direction: row;
    font-family: Arial, sans-serif;
    font-size: var(--a5-card-font-size);
    gap: 10mm;
    justify-content: flex-start;
    margin: 0 auto;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.print-page {
    background: #fff;
    border-radius: 4px;
    box-sizing: border-box;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .15);
    display: flex;
    flex: 0 0 var(--a5-page-width);
    flex-direction: column;
    gap: 0;
    height: 209mm;
    justify-content: flex-start;
    max-width: none;
    overflow: hidden;
    padding: 0;
    width: var(--a5-page-width);
}

/* --- Linia cięcia z nożyczkami --- */
.cut-line {
    align-items: center;
    box-sizing: border-box;
    color: #aaa;
    display: flex;
    flex: 0 0 var(--a5-section-gap);
    font-size: 11px;
    height: var(--a5-section-gap);
    width: 100%;
}

.cut-line::after {
    border-top: 1px dashed #bbb;
    content: '';
    flex: 1;
}

.cut-scissors {
    display: inline-block;
    font-size: 13px;
    line-height: 1;
    margin-right: 2px;
}

.print-page .card-section:first-child {
    flex: 1 1 0;
    min-height: 0;
}

.print-page .card-section:last-child {
    flex: 0 0 var(--a5-main-section-height);
    height: var(--a5-main-section-height);
}

.back-page {
    page-break-before: always;
    overflow: hidden;
}

.card-section {
    border: 2px solid var(--sky-card-blue);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-section > * {
    flex-shrink: 0;
}

.card-section > .flex-spacer {
    flex-shrink: 1;
}

.card-header-blue {
    background: var(--sky-card-blue);
    color: #fff;
    font-size: 1.1em;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: 2px;
    padding: 3px 5px;
    text-align: center;
}

.en-text {
    color: #4a4a4a;
    font-size: .75em;
    font-style: italic;
    font-weight: 400;
}

.card-header-blue .en-text {
    color: #e0e0e0;
}

.card-owner-row {
    border-bottom: 2px solid var(--sky-card-blue);
    display: flex;
}

.logo-box {
    align-items: center;
    border-right: 2px solid var(--sky-card-blue);
    color: #777;
    display: flex;
    flex-direction: column;
    font-size: .8em;
    justify-content: center;
    padding: 2px;
    width: 92px;
}

.logo-box .bi {
    font-size: 1.5rem;
}

.owner-details {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.card-owner-row {
}

.owner-label {
    color: #3b5998;
    font-size: .8em;
    font-weight: 700;
    padding: 1px var(--a5-owner-horizontal-padding);
}

.owner-name-phone {
    border-bottom: 1px solid var(--sky-card-blue);
    display: flex;
    font-size: 1.2em;
    font-weight: 700;
    overflow: hidden;
    padding: 1px var(--a5-owner-horizontal-padding);
    white-space: nowrap;
}

.owner-name-phone span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.owner-name-phone .phone-text,
.owner-phone-label {
    flex: none;
    width: 170px;
}

.owner-name-label {
    flex: 1;
}

.owner-sublabels {
    color: #3b5998;
    display: flex;
    font-size: .65em;
    font-weight: 700;
    padding: 0 var(--a5-owner-horizontal-padding);
}

.owner-address {
    border-bottom: 1px solid var(--sky-card-blue);
    font-size: 1em;
    font-weight: 700;
    overflow: hidden;
    padding: 1px var(--a5-owner-horizontal-padding);
    text-overflow: ellipsis;
    white-space: nowrap;
}

table.card-components-table,
table.card-inspections-table,
table.card-main-canopy-table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
}

.flex-spacer {
    flex-grow: 1;
    flex-shrink: 1;
    min-height: 0;
}

table.card-components-table th,
table.card-components-table td,
table.card-main-canopy-table th,
table.card-main-canopy-table td {
    border: 1px solid var(--sky-card-blue);
    overflow: hidden;
    padding: var(--a5-data-cell-padding);
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

table.card-inspections-table th,
table.card-inspections-table td {
    border: 1px solid var(--sky-card-blue);
    overflow: hidden;
    padding: 4px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

table.card-components-table th,
table.card-inspections-table th,
table.card-main-canopy-table th {
    color: #3b5998;
    font-size: .75em;
    font-weight: 400;
}

.card-components-table th,
.card-components-table td {
    width: 25%;
}

.card-inspections-table th:nth-child(1),
.card-inspections-table td:nth-child(1) {
    width: 14%;
}

.card-inspections-table th:nth-child(2),
.card-inspections-table td:nth-child(2) {
    width: 30%;
}

.card-inspections-table th:nth-child(3),
.card-inspections-table td:nth-child(3) {
    width: 20%;
}

.card-inspections-table th:nth-child(4),
.card-inspections-table td:nth-child(4) {
    width: 22%;
}

.card-inspections-table th:nth-child(5),
.card-inspections-table td:nth-child(5) {
    width: 14%;
}

.card-main-canopy-table th:first-child,
.card-main-canopy-table td:first-child {
    width: 75%;
}

.card-main-canopy-table th:last-child,
.card-main-canopy-table td:last-child {
    width: 25%;
}

.row-label {
    color: #3b5998;
    font-size: .75em;
    font-weight: 700;
    text-align: right !important;
}

.bold-val {
    font-size: 1.05em;
    font-weight: 700;
}

table.card-inspections-table tbody tr,
table.card-inspections-table tbody td {
    height: var(--a5-inspection-row-height);
    max-height: var(--a5-inspection-row-height);
}

table.card-inspections-table tbody td {
    font-size: .9em;
}

@media (max-width: 991.98px) {
    .app-sidebar .navbar-brand {
        height: 56px;
    }

    .app-topbar {
        position: static;
    }

    .app-topbar .container-xl {
        align-items: center;
        flex-wrap: nowrap;
    }

    .page-heading {
        min-width: 0;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .header-actions {
        flex: 1 1 auto;
        justify-content: flex-end;
        margin-top: 0;
        padding-bottom: .15rem;
        width: auto;
    }

    .page-body {
        padding-top: 1rem;
    }

    .physical-card {
        flex-direction: column;
    }
}

@media (max-width: 575.98px) {
    .app-topbar {
        padding: .65rem 0;
    }

    .user-chip {
        display: none;
    }

    .header-actions .btn span {
        display: none;
    }

    .header-actions .btn:not(.btn-icon) {
        height: 32px;
        justify-content: center;
        padding-left: .55rem;
        padding-right: .55rem;
        width: 32px;
    }

    .stats-grid {
        --tblr-gutter-y: .75rem;
    }

    .stat-card .card-body {
        min-height: 88px;
    }
}

@media print {

    .no-print,
    .modal,
    .modal-backdrop,
    .app-sidebar,
    .app-topbar {
        display: none !important;
    }

    @page {
        margin: 0mm 0mm 0mm 0mm;
        size: A5 portrait;
    }

    html {
        border: none !important;
        margin: 0 !important;
        outline: none !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
        border: none !important;
        margin: 0 !important;
        outline: none !important;
        padding: 0 !important;
    }

    #app-container,
    .page,
    .page-wrapper,
    .page-body,
    .container-xl,
    #view-rig-detail {
        border: none !important;
        box-shadow: none !important;
        display: block !important;
        left: auto !important;
        margin: 0 !important;
        max-width: none !important;
        outline: none !important;
        padding: 0 !important;
        position: static !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
    }

    .print-page {
        border: none !important;
        outline: none !important;
    }

    table.card-components-table,
    table.card-inspections-table,
    table.card-main-canopy-table {
        border: 0 !important;
    }

    body.print-card-only .view:not(#view-rig-detail),
    body.print-card-only #view-rig-detail> :not(#rig-print-area) {
        display: none !important;
    }

    body.print-card-only #rig-print-area {
        display: block !important;
    }

    .physical-card {
        border: 0;
        box-shadow: none;
        display: block !important;
        font-size: var(--a5-card-font-size);
        max-width: none;
        overflow: visible;
        padding-bottom: 0;
        width: 100%;
    }

    .print-page {
        border-radius: 0;
        box-shadow: none;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        gap: 0;
        justify-content: flex-start;
        margin: 0;
        height: 209mm !important;
        /* twarda wysokość mniejsza niż 210mm papieru, by uniknąć 3 strony */
        max-width: none;
        overflow: hidden;
        padding: 0;
        width: 100%;
    }

    .back-page {
        page-break-before: always;
        /* Rewers drukowany do góry nogami. Przy ręcznym druku dwustronnym obrót o 180°
           kompensuje nierówne marginesy lewy/prawy drukarki (góra i dół są równe),
           więc obie strony pokrywają się po złożeniu. Sposób podania papieru dobiera operator.
           translateX zostaje do przyszłej kalibracji — przy 0mm nie zmienia nic.
           UWAGA: po obrocie dodatnia korekta przesuwa wizualnie w LEWO. */
        transform: rotate(180deg) translateX(var(--duplex-offset-x));
        transform-origin: center center;
    }

    .card-section {
        border: 2px solid #5b79ac;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        margin: 0 !important;
        overflow: hidden;
    }

    .print-page .card-section:first-child {
        flex: 1 1 0;
        min-height: 0;
    }

    .print-page .card-section:last-child {
        flex: 0 0 var(--a5-main-section-height);
        height: var(--a5-main-section-height);
    }

    .card-header-blue {
        -webkit-print-color-adjust: exact;
        background-color: var(--sky-card-blue) !important;
        color: #fff !important;
        print-color-adjust: exact;
    }

    .owner-label,
    .owner-sublabels,
    table th,
    .row-label {
        color: #3b5998 !important;
    }

    .del-insp-btn {
        display: none !important;
    }

    table.card-inspections-table tbody tr,
    table.card-inspections-table tbody td {
        height: var(--a5-inspection-row-height) !important;
        max-height: var(--a5-inspection-row-height) !important;
    }

    table.card-inspections-table tbody td {
        overflow: hidden !important;
    }

    .print-page {
        gap: 0;
    }

    /* Linia cięcia – widoczna na wydruku */
    .cut-line {
        color: #333;
        flex: 0 0 var(--a5-section-gap);
        height: var(--a5-section-gap);
    }

    .cut-line::after {
        border-top: 0.5pt dashed #555;
    }

    .cut-scissors {
        color: #333;
        font-size: 10pt;
    }

    /* --- TRYB NADRUKU (OVERPRINT) --- */
    /* Strona bez żadnego zaznaczonego wpisu nie jest drukowana (brak pustej kartki A5). */
    body.print-overprint-only .print-page.overprint-empty {
        display: none !important;
    }
    body.print-overprint-only .card-wrapper,
    body.print-overprint-only .card-section {
        border: none !important;
        box-shadow: none !important;
    }
    body.print-overprint-only .card-header-blue,
    body.print-overprint-only .card-owner-row,
    body.print-overprint-only .cut-line,
    body.print-overprint-only .flex-spacer,
    body.print-overprint-only .card-components-table,
    body.print-overprint-only .card-main-canopy-table {
        visibility: hidden !important;
    }
    body.print-overprint-only table {
        border: none !important;
    }
    body.print-overprint-only th,
    body.print-overprint-only td {
        border: none !important;
    }
    body.print-overprint-only th {
        visibility: hidden !important;
    }
    body.print-overprint-only tr:not(.print-selected) td {
        visibility: hidden !important;
    }
    body.print-overprint-only tr.print-selected td {
        visibility: visible !important;
        color: #000 !important;
    }
    body.print-overprint-only .status-badge {
        /* W trybie nadruku usuwamy ewentualne tła i marginesy żeby tekst był czysty */
        background: transparent !important;
        color: #000 !important;
        border: none !important;
    }
}
/* --- UI SELECTION MODE --- */
.print-row-toggle-label {
    display: none;
}
body.selection-mode .print-row-toggle-label {
    display: inline-block;
}
body.selection-mode .del-insp-btn {
    display: none !important;
}

/* --- Wersja aplikacji (ekran logowania + stopka menu) --- */
.app-version {
    color: var(--sky-muted);
    font-size: .75rem;
    letter-spacing: .02em;
    margin: 0;
    text-align: center;
}

/* Na ekranie logowania: poza kartą, na szarym tle strony. */
#login-version {
    margin-top: 1rem;
}

/* W menu: dosunięta do dołu paska bocznego, przygaszona (ciemne tło). */
.sidebar-version {
    color: rgba(255, 255, 255, .45);
    margin-top: auto;
    padding: 1rem .5rem .25rem;
}

/* --- Arkusz kalibracyjny druku dwustronnego --- */
/* Widoczny wyłącznie na wydruku; na ekranie nie zaśmieca widoku. */
#calibration-sheet { display: none; }

@media print {
    /* Gdy drukujemy arkusz, chowamy całą aplikację — także kartę zestawu. */
    body.print-calibration-only > *:not(#calibration-sheet) { display: none !important; }

    #calibration-sheet { display: block !important; }

    #calibration-sheet .calib-page {
        box-sizing: border-box;
        height: 209mm;      /* jak karta: mniej niż 210 mm, żeby nie wypchnąć trzeciej strony */
        page-break-after: always;
        position: relative;
        width: 100%;
    }

    #calibration-sheet .calib-page:last-child { page-break-after: auto; }

    /* Arkusz kalibracyjny NIE może być korygowany — mierzymy nim surowy offset drukarki. */
    #calibration-sheet .calib-page { transform: none !important; }
}
