@media print {
    @page {
        size: A4 landscape;
        margin: 0;
    }
    thead {
        display: table-header-group;
    }
    tfoot {
        display: table-footer-group;
    }
    tr {
        page-break-inside: avoid !important;
    }
    tr.page-break {
        page-break-before: always;
    }

    /* --- Logo Container Print Layout (Flexbox) --- */
    .logo-container {
        display: flex;
        flex-direction: column;
        height: 100vh; /* Full page height */
        justify-content: flex-start; /* Align items from the top */
        align-items: center; /* Center items horizontally */
        /* position: relative; */ /* Not needed for this flex approach */
        page-break-after: always; /* Ensure table starts on next page */
    }

    .logo {
        /* Let flexbox handle positioning, remove absolute */
        /* position: absolute; ... */
        max-width: 70%; /* Adjust as needed */
        max-height: 65vh; /* Limit logo height to leave space */
        width: auto;
        height: auto;
        object-fit: contain;
        margin-top: 10vh; /* Space from top */
        margin-bottom: auto; /* Pushes subsequent elements down */
    }

    .contact-info {
        /* Let flexbox handle positioning, remove absolute */
        /* position: absolute; ... */
        width: 100%; /* Ensure it takes full width for centering */
        text-align: center;
        margin-top: 4vh; /* Add Space above contact info, pushing it down from logo */
        margin-bottom: 4vh; /* Reset Space above company info */
        padding-bottom: 0;
    }

    .contact-details {
        padding-bottom: 4vh;
    }

    /* Target the specific paragraph within contact-info for company details */
    .company-details {
        /* Let flexbox handle positioning, remove absolute */
        /* position: absolute; ... */
        width: 100%; /* Ensure it takes full width for centering */
        text-align: center;
        margin-top: 0;
        margin-bottom: 2vh; /* Space from bottom */
        font-size: 0.8em; /* Keep smaller font */
        color: #666; /* Keep color */
    }
    /* --- End Logo Container Print Layout --- */

    /* --- Product Description Print Styling --- */
    .product-description-print {
        width: 80%; /* Match logo width roughly */
        text-align: center;
        margin: 2vh auto; /* Vertical margin, auto horizontal for centering */
        margin-bottom: 4vh;
        font-size: 0.9em;
    }
    /* .product-description-print p {
        margin-bottom: 0.5em;
    } */
    /* --- End Product Description Print Styling --- */

    .screen-img {
        display: none;
    }
    .print-img {
        display: inline; /* Ensure print image is shown */
    }

    /* Font size reduction for print */
    table {
        font-size: 84% !important; /* Added !important */
        /* Annotation: Reduce overall font size for printing as requested */
    }
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0px;
    background-color: #ffffff;
    font-size: small;
    line-height: 1.4;
}
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden;
}
th, td {
    border: 1px solid #e0e0e0;
    padding: 2px;
    text-align: center;
}
th {
    background-color: #2c5282;
    color: white;
    text-transform: uppercase;
    font-weight: bold;
    padding: 2px 4px; /* Reduced padding for header */
}

/* Prevent wrapping in the last header cell */
thead tr:last-child th:last-child {
    white-space: nowrap;
}

/* Bold specific columns */
td:nth-child(1), /* No column */
td:nth-child(3) /* Nazwa column */
/* td:nth-child(8) - Rule removed as column is merged */
{
    font-weight: bold;
}

/* Style for product amount added under name */
.product-amount {
    display: block; /* Ensure it takes its own line */
    font-size: 0.9em;
    font-weight: normal; /* Make it less prominent than name */
    color: #555;
    margin-top: 3px; /* Add space below name */
    text-align: center; /* Align with name */
}

/* Allow image cell to overflow and act as positioning context */
td:nth-child(2) {
    /* overflow: visible; */ /* Reverted */
    position: relative; /* Needed for absolute positioning of child */
    /* text-align: center; */ /* Reverted */
    width: 64px; /* Force cell width for overflow effect */
    border-right: none; /* Keep border hidden */
}

/* Hide border between image (2nd) and name (3rd) DATA cells */
td:nth-child(3) {
    border-left: none;
    vertical-align: middle; /* Align content vertically centered */
}

/* Style for product category and name */
.product-category,
.product-name {
    white-space: nowrap;    /* Prevent wrapping */
    overflow: hidden;       /* Hide overflow */
    text-overflow: ellipsis; /* Show ... for overflow */
    display: block;         /* Ensure block layout */
    line-height: 1.2;       /* Adjust line height slightly */
}

.product-name {
    font-weight: bold; /* Keep name bold */
}

/* --- Styles for Merged Price Column (Now Column 6) --- */

/* Style the container cell for the merged prices */
td:nth-child(6) { /* Updated from nth-child(7) */
    text-align: center; /* Changed from right to center */
    vertical-align: middle;
    padding: 8px 12px;
}

/* --- End Styles for Merged Price Column --- */

.table-title {
    text-align: center;
    padding: 8px;
}
.table-title-text {
    font-size: 1.5em;
    /* margin-bottom: 10px; */
}
.logo {
    max-width: 80%;
    max-height: 60vh;
    height: auto;
    /* margin-top: 15vh; */ /* Base margin, overridden in print */
    display: inline;
}
.contact-info {
    text-align: center;
    /* margin-top: 4vh; */ /* Base margin, overridden in print */
    /* padding-bottom: 4vh; */ /* Base padding, overridden in print */
}
.contact-info p {
    margin-bottom: 0.5em; /* Adjust this value as needed */
}

/* Ensure the last paragraph in contact-info doesn't have extra bottom margin if not desired */
.contact-info p:last-child {
    margin-bottom: 0;
}

.contact-info a {
    color: #2c5282;
    text-decoration: none;
}
.contact-info p.company-details {
    font-size: 0.8em;
    color: #666;
    /* margin-top: 4vh; */ /* Base margin, overridden in print */
}
.logo-container {
    display: none; /* Hide by default */
    /* height: 100vh; */ /* Height is set within @media print */
    /* flex properties set within @media print */
    /* align-items: center; */
    /* justify-content: center; */
    /* page-break-after: always; */ /* Set within @media print */
}
.screen-img, .print-img {
    max-width: 128px;
    max-height: 128px;
    border-radius: 5px;
    /* Restore absolute positioning for centering & overflow */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    transform-origin: center center; /* Ensure scaling originates from the center */
    /* Remove positioning/alignment/margin tricks */
    /* vertical-align: middle; */
    margin-left: 0; /* Reset margins */
    margin-right: 0; /* Reset margins */
    /* margin-left: -25%; */
    /* margin-right: -25%; */
}
@media print {
    .logo-container {
        display: flex;
    }
    .screen-img {
        display: none;
    }
    .print-img {
        display: inline;
    }
}
.screen-img {
    display: inline;
}
.print-img {
    display: none;
}
.logo-container {
    height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    page-break-after: always;
}
/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    cursor: pointer;
}
.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
}
.screen-img {
    cursor: pointer;
    transition: transform 0.2s;
}
.screen-img:hover {
    /* Combine centering translation with scaling */
    transform: translate(-50%, -50%) scale(1.1);
    /* transform: scale(1.1); */ /* Incorrect: overwrites translate */
}

/* --- Nutrition List Styling (Divs) --- */

.nutrition-list {
  /* Container for the nutrition items */
  padding: 3px 0; /* Vertical padding */
}

.nutrition-item {
  display: flex;
  justify-content: space-between; /* Label left, value right */
  align-items: baseline;       /* Align text baselines */
  padding: 1px 5px;           /* Small padding around each item */
  line-height: 1.1;          /* Adjust line height for readability */
}

.nutrition-label {
  /* text-align: left; /* Default */
  margin-right: 1em; /* Space between label and value */
}

.nutrition-value {
  text-align: right;
  white-space: nowrap; /* Prevent wrapping */
  font-weight: bold; /* Make values stand out */
  flex-shrink: 0;    /* Prevent value from shrinking */
}

/* Style for indented items */
.nutrition-item-indented .nutrition-label {
  padding-left: 1.5em; /* Indentation */
}

/* Ensure bold tags within labels work as expected */
.nutrition-label b {
   font-weight: bold;
}

/* Ensure nutrition fact spans don't wrap internally */
.nutrition-fact-item {
  white-space: nowrap;
}

/* --- End Nutrition List Styling --- */

/* --- Ingredients List Styling --- */
.ingredients-list p {
    margin-top: 0.2em; /* Reduce top margin */
    margin-bottom: 0.2em; /* Reduce bottom margin */
    line-height: 1.2; /* Slightly adjust line height for reduced margin */
}

.table-cell {
    height: 12.75vh;          /* Set a fixed viewport height */
    vertical-align: middle; /* Align content to the top */
    padding-top: 5px;      /* Add some padding at the top */
}

td:nth-child(4) {
    text-align: left;
}

/* Align ingredients cell (4th child) to the left */
.table-cell:nth-child(4) {
    text-align: left;
}

/* Style for suggested price (similar to product amount) */
.suggested-price {
    display: block; /* Ensure it takes its own line if needed */
    font-size: 0.9em;
    font-weight: normal;
    color: #555;
    margin-top: 3px; /* Add a little space above */
}