/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #333;
    color: white;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    margin-top: 60px;
}

.sidebar {
    width: 220px;
    background: #e9ecef;
    border-right: 1px solid #ccc;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;    
}

.content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f5f5f5;    
}

.footer {
    background: #333;
    color: #fff;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 901px) {

    .sidebar {
        position: fixed;
        top: 60px;
        bottom: 40px;
        left: 0;
        width: 240px;
        overflow: hidden;
        z-index: 2000;
    }

    .layout {
        margin-left: 240px;
        margin-bottom: 40px;
    }

    .footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }
}

.header-title {
    font-size: 22px;
    font-weight: bold;
    text-align: center;
}

.hamburger {
    display: none;
    font-size: 28px;
    cursor: pointer;
}

.header-right .logout {
    text-decoration: none;
    /* color: #333; */
    font-weight: 500;
}

.username {
    font-weight: bold;
}

.logout {
    color: white;
    text-decoration: underline;
}

.sidebar nav a {
    display: block;
    padding: 10px;
    margin-bottom: 10px;
    background: white;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    border: 1px solid #ddd;
}

.sidebar nav a:hover {
    background: #dceeff;
    border-color: #0078d4;
}


/* BUTTONS */
button,
input[type="submit"] {
    background: #0078d4;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
}

button:hover,
input[type="submit"]:hover {
    background: #005fa3;
}

/* FORMS */
input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #bbb;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 15px;
}

/* LOGIN PAGE */
.login-container {
    max-width: 400px;
    margin: 40px auto;
    background: rgb(238, 237, 237);
    padding: 25px;
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    align-self: flex-start;
}


.error-box {
    background: #ffdddd;
    border: 1px solid #ff8888;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    color: #a30000;
}

.no-nav .layout {
    margin-left: 0;
}

@media (max-width: 900px) {
    .hamburger { display:block; }

    .sidebar {
        position: fixed;
        top: 60px;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        z-index: 2000;
    }

    .sidebar.open {
        transform: translateX(0);
    }    

    .overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1500;
    }

    .overlay.show {
        display: block;
    }  

    .layout {
        display: block;
        margin-left: 0;
    }      

    .footer {
        position: static;
        margin-top: auto;
    }

    .content {
        overflow: visible;
    }

    /* .with-nav .content {
        margin-left: 0;
    }     */
}

@media (max-width: 768px) {
    .login-container {
        margin: 20px;
        padding: 20px;
    }

    header h2 {
        font-size: 18px;
    }
}

.lnp-header {
  background: #ddd;
  padding: 6px 20px;
  font-size: .8em;
  margin-bottom: 10px;
  text-align: center;
}

.lnp-footer {
  background: #ddd;
  padding: 6px 20px;
  font-size: .8em;
  margin-top: 10px;
  text-align: center;
} 

.lnp-content {
    flex: 1;
    display: flex;
    flex-direction: column;  
}

/* home */
.home-orders {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.orders-table th,
.orders-table td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.btn-view {
    padding: 6px 12px;
    background: #007bff;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
}

.btn-view:hover {
    background: #0056b3;
}

@media (max-width: 768px) {
    .orders-table thead {
        display: none;
    }

    .orders-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #eee;
        padding: 10px;
        border-radius: 6px;
    }

    .orders-table td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
    }

    .orders-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #555;
    }
}

.page-header {
    text-align: center;
    width: 100%;
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.page-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.orders-list {
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(0,0,0,0.05);
    min-height: 300px;
}

.page-footer {
    margin-top: auto;
    padding: 10px 20px;
    background: #ecf0f1;
    border-radius: 4px;
    text-align: center;
    color: #555;
    font-size: 14px;
    box-shadow: 0 0 6px rgba(0,0,0,0.05);
}

.home-customers {
    margin-top: 30px;
    max-width: 1000px;
    margin: 0 auto;    
    display: flex;
    flex-direction: column;
    flex: 1;      
}

/* --------------------------------------------- */
/* CUSTOMERS PAGE                                */
/* --------------------------------------------- */

.customers-list-container {
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.customers-search {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    margin-bottom: 15px;
    transition: border-color 0.2s ease;
}

.customers-search:focus {
    border-color: #2c3e50;
    outline: none;
}

.customers-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.customer-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.customer-row:hover {
    background: #eef2f5;
    transform: translateY(-1px);
}

.customer-name {
    font-weight: 600;
    color: #2c3e50;
}

.customer-code {
    color: #555;
    font-size: 14px;
    text-align: right;
}

@media (max-width: 768px) {
    .customer-row {
        flex-direction: column;
        gap: 4px;
        padding: 12px;
    }

    .customer-code {
        font-size: 13px;
        color: #777;
        text-align: left;
    }
}




/* ============================================================
   ORDER NEW 
   ============================================================ */

.page-order-new {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.page-order-new .page-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 15px;
}

.page-order-new .page-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
    padding-right: 10px;
}

.page-order-new .btn-action {
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.page-order-new .btn-action.clear {
    background: #2c3e50;
    color: #fff;
    margin-right: auto;
}

.page-order-new .btn-action.save {
    background: #2c3e50;
    color: #fff;
}

.page-order-new .btn-action.save:hover {
    background: #1f2d3a;
}

.page-order-new .btn-action.back {
    background: #bdc3c7;
    color: #2c3e50;
}

.page-order-new .btn-action.back:hover {
    background: #aeb4b8;
}

.page-order-new .order-header-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.page-order-new .order-header-grid.no-delivery {
    grid-template-columns: 1fr;
}

.page-order-new .order-header-grid label {
    font-weight: bold;
    margin-bottom: 6px;
    display: block;
}

.page-order-new .order-header-grid input[type="date"] {
    width: 160px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
}

.page-order-new .grid-col {
    min-width: 0;
}

.page-order-new .customer-display {
    padding: 9px 10px;
    background: #f2f2f2;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    white-space: nowrap;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

@media (max-width: 768px) {
    .page-order-new .order-header-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .page-order-new .grid-col {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .page-order-new .order-header-grid:not(.no-delivery) .grid-col:nth-child(2),
    .page-order-new .order-header-grid.no-delivery .grid-col:nth-child(1) {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-order-new .customer-display {
        width: 100%;
        margin-top: 4px;
    }
}

.page-order-new .filters-bar {
    padding: 0;
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.page-order-new .filters-bar select {
    width: 300px;
    flex: 0 0 auto;
    font-size: 12px;
}

.page-order-new .filters-bar .search-wrapper {
    position: relative;
    flex: 1;
    align-items: center;
    line-height: 0px;
    height: 38px;
}

.page-order-new .filters-bar .search-wrapper input {
    width: 100%;
    padding-right: 28px;
    box-sizing: border-box;
    font-size: 14px;   
}

.page-order-new .filters-bar .clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    color: #999;
    display: none;
}

.sidebar .filters-bar {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    margin-top: 25px;
    border: 1px solid #ddd;
}

.sidebar .order-filter {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    margin-top: 30px;
    border: 1px solid #ddd;  
    font-size: 12px;
}

.sidebar .order-filter .tree-title {
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0 6px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar .order-filter .tree {
    list-style: none;
    padding-left: 0;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 6px;    
}

.sidebar .order-filter .tree,
.sidebar .order-filter .tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar .order-filter .tree li {
    padding: 4px 6px;
}

.sidebar .order-filter .item-row {
    display: grid;
    grid-template-columns: 16px 1fr;
    column-gap: 6px;
}


.sidebar .order-filter .tree li ul {
    display: none;
    padding-left: 10px;
}

.sidebar .order-filter .tree li.open > ul {
    display: block;
}

.sidebar .order-filter .tree .arrow {
    width: 12px;
    height: 12px;
    cursor: pointer;
    background-size: 12px 12px;
    background-image: url('data:image/svg+xml;utf8,<svg fill="black" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M8 5l8 7-8 7z"/></svg>');
    transition: transform .2s;
}

.sidebar .order-filter .tree .arrow.empty {
    opacity: 0;
    cursor: default;
}

.sidebar .order-filter .tree li.open > .item-row > .arrow {
    transform: rotate(90deg);
}

.sidebar .order-filter .tree .group {
    cursor: pointer;
}

.sidebar .order-filter .tree .group.active {
    background: #d0e7ff;
    border-radius: 4px;
}


@media (max-width: 768px) {
    .page-order-new .filters-bar {
        flex-direction: column;
    }

    .page-order-new .filters-bar .search-wrapper 
    {
        width: 100%;
        flex: none;
    }
}

.page-order-new .products-header {
    display: grid;
    grid-template-columns: 70px 1fr 60px 250px 90px;
    font-weight: bold;
    padding: 4px 12px;
    border-bottom: 2px solid #ccc;
    margin-top: 10px;
    background: #f7f7f7;
    font-size: 14px;
}

@media (max-width: 768px) {
    .page-order-new .products-header {
        display: none;
    }
}

/* --------------------------------------------- */
/* LISTA PRODUKTÓW                               */
/* --------------------------------------------- */

.page-order-new .products-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.page-order-new .product-row {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: 70px 1fr 60px 250px 90px;
    padding: 4px 8px;
    /* border-bottom: 1px solid #eee; */
    border: 2px solid transparent;   /* stała grubość */
    border-bottom-color: #eee;     
    background: #fff;
    transition: background 0.2s ease;
    font-size: 14px;
}

.page-order-new .product-row > div {
    display: flex;
    align-items: center;
}

.page-order-new .product-row:hover {
    background: #eef2f5;
}

.page-order-new .products-header .product-qty {
    padding-left: 50px;
}

@media (max-width: 768px) {

    .page-order-new .product-row {
        display: block;
        padding: 8px;
        border: 1px solid #ddd;
        border-radius: 6px;
        margin-bottom: 10px;
        background: #fff;
        font-size: 16px;
    }

    .page-order-new .product-row > div {
        margin-bottom: 6px;
    }

    .page-order-new .product-row .product-name {
        font-weight: bold;
        font-size: 16px;
    }

    .page-order-new .product-row .product-code::before {
        content: "Kod: ";
        font-weight: bold;
        padding-right: 30px;
    }

    .page-order-new .product-row .product-price::before {
        content: "Cena: ";
        font-weight: bold;
        padding-right: 14px;
        text-align: left;
    }

    .page-order-new .product-row .product-qty::before {
        content: "Ilość: ";
        font-weight: bold;
        padding-right: 20px;
    }

    .page-order-new .product-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 10px;
        gap: 10px;
    }

    .page-order-new .product-row .product-price .qty-price {
        text-align: left;
        padding-left: 8px;
    }    
}

/* --------------------------------------------- */
/* AKCJE PRODUKTU / EDYCJA                       */
/* --------------------------------------------- */

.page-order-new .product-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.page-order-new .product-actions button {
    background: #f0f0f0;
    border: 1px solid #ccc;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    line-height: 1;
    border-radius: 4px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.page-order-new .product-actions button:hover {
    background: #e2e2e2;
    border-color: #999;
}

.page-order-new .product-actions button:active {
    transform: scale(0.9);
}

.page-order-new .edit-qty {
    height: 100%;
    padding: 4px 6px;
    box-sizing: border-box;
    width: 80px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #fff;
    text-align: right;
    font-size: 14px;
}

.page-order-new .edit-note{
    height: 100%;
    padding: 4px 6px;
    box-sizing: border-box;
    width: 100%;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

.page-order-new .product-actions .save_row,
.page-order-new .product-actions .cancel_row {
    padding: 4px 4px;
    font-size: 13px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    color: #fff;
}

.page-order-new .product-actions .save_row {
    background: #28a745;
}

.page-order-new .product-actions .save_row:hover {
    background: #218838;
}

.page-order-new .product-actions .cancel_row {
    background: #dc3545;
}

.page-order-new .product-actions .cancel_row:hover {
    background: #c82333;
}

.page-order-new .product-row input {
    margin: 0;
}

.product-note {
    grid-column: 1 / -1;
    padding-top: 5px; 
    display: none !important;
}


.product-note:not(:empty) {
    grid-column: 1 / -1;
    border-top: 1px solid black;
    margin-top: 6px; 
}

.product-note:not(:empty)::before {
    content: "Uwagi:";
    font-weight: bold;
    display: block;
    padding-right: 8px; 
}


/* --------------------------------------------- */
/* STATYSTYKI PRODUKTU                           */
/* --------------------------------------------- */

.page-order-new .product-row .product-stats {
    grid-column: 1 / -1;
    margin-top: 10px;
    background: #fafafa;
    border-top: 1px solid #eee;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    display: none;
}

.page-order-new .product-stats.stats-grid {
    display: none;
    grid-template-columns: 150px 1fr 1fr 1fr;
    gap: 6px 10px;
}

.page-order-new .product-stats.stats-grid.open {
    display: grid;
}

.page-order-new .product-stats.stats-grid .cell {
    display: flex;
    align-items: center;
    min-height: 26px;
}

.page-order-new .product-stats .h-okres,
.page-order-new .product-stats .h-sprzedaz,
.page-order-new .product-stats .h-korekty {
    font-weight: 700;
}

@media (max-width: 768px) {

    .page-order-new .product-stats.stats-grid {
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-areas:
            "h-okres h-sprzedaz h-korekty"
            "okres-4 sprzedaz-4 korekty-4"
            "okres-3 sprzedaz-3 korekty-3"
            "okres-6 sprzedaz-6 korekty-6";
        gap: 6px 10px;
        margin-top: 10px;
    }

    .page-order-new .product-stats .h-okres      { grid-area: h-okres; }
    .page-order-new .product-stats .h-sprzedaz   { grid-area: h-sprzedaz; }
    .page-order-new .product-stats .h-korekty    { grid-area: h-korekty; }

    .page-order-new .product-stats .okres-4      { grid-area: okres-4; }
    .page-order-new .product-stats .sprzedaz-4   { grid-area: sprzedaz-4; }
    .page-order-new .product-stats .korekty-4    { grid-area: korekty-4; }

    .page-order-new .product-stats .okres-3      { grid-area: okres-3; }
    .page-order-new .product-stats .sprzedaz-3   { grid-area: sprzedaz-3; }
    .page-order-new .product-stats .korekty-3    { grid-area: korekty-3; }

    .page-order-new .product-stats .okres-6      { grid-area: okres-6; }
    .page-order-new .product-stats .sprzedaz-6   { grid-area: sprzedaz-6; }
    .page-order-new .product-stats .korekty-6    { grid-area: korekty-6; }
}


.page-order-new .kor-neg {
    color: #c82333;
}

.is-prom {
    /* color: #c82333; */
    color: green;
    font-weight: bold;
}

.tree-select option {
    white-space: pre;
}
select option {
    white-space: pre;
}


.product-row.active {
    border: 2px solid black;
    border-radius: 4px;

    /* background-color: #f5f5f5; */
}


.dropdown {
    position: relative;
    width: 300px;
    user-select: none;
    font-size: 12px;
}

.dropdown-selected {
    padding: 12px;
    border: 1px solid #aaa;
    background: #fff;
    cursor: pointer;
    border-radius: 4px;  
}

.dropdown.open .dropdown-selected {
    border: 2px solid #4a90e2;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    border: 1px solid #aaa;
    background: #fff;
    display: none;
    margin: 0;
    padding: 0;
    list-style: none;
    z-index: 10;
    max-height: 350px;
    overflow-y: auto;      
}

.dropdown-list li {
    padding: 4px;
    cursor: pointer;
}

.dropdown-list li:hover {
    background: #eee;
}

.dropdown-list li.active {
    background: #d0e7ff;
    font-weight: bold;
}











.qty-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #ccc;
    background: #f7f7f7;
    cursor: pointer;
    font-size: 18px;
    color: black;
    /* line-height: 1; */
    border-radius: 4px;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;    
}

.qty-btn:hover {
    background: #e0e0e0;
}

.qty-price {
    min-width: 45px;
    text-align: right;
    display: inline-block;
}

.qty-value {
    min-width: 40px;
    text-align: right;
    display: inline-block;
}

.qty-unit {
    font-size: 13px;
    min-width: 20px;
}

.qty-info {
    padding-left: 4px;
    opacity: 0.7;
    font-size: 13px;    
}

.products-header .product-price {
  padding-left: 10px;
}

.summary-worth {
    margin-top: 10px;
    margin-bottom: 5px;

    box-sizing: border-box;
    /* padding: 4px 8px; */
    /* border: 2px solid transparent;    */
    /* background: #eee; */
    transition: background 0.2s ease;
    font-size: 16px; 
    font-weight: bold;
}