* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "DejaVu Sans", Arial, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
}
.layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 260px;
    background: #1f3b57;
    color: #fff;
    padding: 24px;
}
.brand {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}
.user-box {
    background: rgba(255,255,255,0.08);
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 24px;
    line-height: 1.5;
}
.menu a {
    display: block;
    color: #fff;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.06);
}
.menu a:hover { background: rgba(255,255,255,0.14); }
.content {
    flex: 1;
    padding: 28px;
}
.card {
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
    margin-bottom: 22px;
}
h1, h2, h3 { margin-top: 0; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
.form-row-single {
    grid-template-columns: 1fr;
}
label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}
input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.btn {
    display: inline-block;
    padding: 11px 16px;
    border-radius: 10px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
}
.btn-primary { background: #0f766e; color: #fff; }
.btn-secondary { background: #334155; color: #fff; }
.btn-warning { background: #b45309; color: #fff; }
.btn-success { background: #15803d; color: #fff; }
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}
.flash {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 700;
}
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-info { background: #dbeafe; color: #1d4ed8; }
.login-box {
    max-width: 460px;
    margin: 70px auto;
}
.status-new { background: #f8d7da; }
.status-processing { background: #fff3cd; }
.status-ordered { background: #ffe5b4; }
.status-sent { background: #d1e7dd; }
.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
}
.actions-inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.small { font-size: 13px; color: #475569; }
.date-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    text-decoration: none;
    background: #e2e8f0;
    color: #0f172a;
    font-weight: 700;
}
.date-chip-active {
    background: #0f766e;
    color: #fff;
}
.date-chip-count {
    display: inline-flex;
    min-width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255,255,255,0.75);
    color: #0f172a;
    padding: 0 6px;
    font-size: 12px;
}
.date-chip-active .date-chip-count {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px;
}
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .section-head { flex-direction: column; }
}

.btn-danger { background: #b91c1c; color: #fff; }

.draft-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.draft-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f8fafc;
}
.draft-remove-form {
    flex-shrink: 0;
}


.admin-inline-form {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    margin: 0;
}
.admin-inline-form .admin-inline-status {
    width: 180px;
    flex: 0 0 180px;
}
.admin-inline-form .admin-inline-note {
    flex: 0 1 180px;
    min-width: 140px;
    max-width: 220px;
}
.admin-inline-form .admin-inline-submit {
    flex: 0 0 auto;
}
.admin-inline-form select,
.admin-inline-form input[type="text"] {
    margin: 0;
}
.admin-inline-form button {
    white-space: nowrap;
}
@media (max-width: 1100px) {
    .admin-inline-form {
        flex-wrap: wrap;
    }
    .admin-inline-form .admin-inline-status,
    .admin-inline-form .admin-inline-note,
    .admin-inline-form .admin-inline-submit {
        flex: 1 1 100%;
        width: 100%;
    }
}


.save-indicator {
    font-size: 12px;
    min-height: 16px;
    margin-top: 4px;
}
.save-indicator.saving { color: #1d4ed8; }
.save-indicator.saved { color: #15803d; }
.save-indicator.error { color: #b91c1c; }
.save-indicator.pending { color: #b45309; }


.ean-copy-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ean-text {
    font-weight: 700;
}
.btn-copy-ean {
    padding: 6px 10px;
    font-size: 12px;
}


.status-with-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.status-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: #fff;
    color: #334155;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    cursor: help;
    vertical-align: middle;
}
.status-info:hover {
    background: #334155;
    color: #fff;
}
.admin-inline-form .status-info {
    flex: 0 0 auto;
}


/* Stav + modré informační i v jednom řádku */
.status-with-info,
.admin-inline-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.status-info {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px;
    border-radius: 999px !important;
    border: 0 !important;
    background: #2563eb !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    cursor: help;
    vertical-align: middle;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

.status-info:hover {
    background: #1d4ed8 !important;
    color: #ffffff !important;
}

.admin-inline-status select {
    flex: 0 0 auto;
}


/* Lepší rozestup mezi stavem a poznámkou v administraci */
.admin-inline-form {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
    flex-wrap: nowrap !important;
}

.admin-inline-status {
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    flex: 0 0 235px !important;
    min-width: 235px !important;
    max-width: 235px !important;
}

.admin-inline-status select {
    width: 205px !important;
}

.admin-inline-note {
    margin-left: 8px !important;
    flex: 0 0 210px !important;
    min-width: 210px !important;
    max-width: 210px !important;
}

.admin-inline-note input[type="text"] {
    width: 210px !important;
}

@media (max-width: 1250px) {
    .admin-inline-form {
        flex-wrap: wrap !important;
    }

    .admin-inline-status,
    .admin-inline-note {
        flex: 1 1 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
    }

    .admin-inline-status select,
    .admin-inline-note input[type="text"] {
        width: 100% !important;
    }
}


/* Ovládání počtu kusů a poznámky v rozpracovaném listu */
.draft-item-main {
    flex: 1 1 260px;
}
.draft-controls-form {
    display: grid;
    grid-template-columns: auto;
    gap: 6px;
    min-width: 250px;
}
.qty-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.qty-control input[type="text"] {
    width: 70px;
    text-align: center;
    padding: 8px 6px;
}
.qty-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: #334155;
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    line-height: 1;
}
.qty-btn:hover {
    background: #1f2937;
}
.draft-controls-form label {
    margin-bottom: 0;
    font-size: 13px;
}
@media (max-width: 900px) {
    .draft-item {
        flex-direction: column;
    }
    .draft-controls-form {
        width: 100%;
    }
}


/* Úprava uloženého počtu a odpověď prodejny */
.saved-qty-form,
.store-reply-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}
.saved-qty-form .qty-control {
    display: inline-flex;
}
.saved-qty-form .btn-small,
.store-reply-form .btn-small,
.btn-small {
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 8px;
}
.store-reply-form input[type="text"] {
    min-width: 220px;
}


.saved-qty-form + .small,
td .small {
    line-height: 1.35;
}


/* V50 - upozornění na dříve zadaný EAN */
.duplicate-warning-card {
    border: 2px solid #f59e0b;
    background: #fffbeb;
}
.duplicate-warning-card h2 {
    color: #92400e;
}
.duplicate-warning-card .actions-inline {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}


/* V52 - dodací list na prodejnu */
.delivery-quantity-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.delivery-quantity-form input[type="number"] {
    width: 100px;
}


/* V53 - okno množství a měrné jednotky */
.delivery-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.delivery-modal {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}
.delivery-modal h2 {
    margin-top: 0;
}
.delivery-product-info {
    padding: 12px;
    border-radius: 9px;
    background: #f1f5f9;
    margin-bottom: 16px;
    line-height: 1.5;
}
.delivery-quantity-form select {
    width: 80px;
}


/* V55 - přehled aktuálních dodacích listů */
.delivery-current-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 14px;
}

.delivery-current-card {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 14px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.delivery-current-card h3 {
    margin: 0 0 6px;
}

.delivery-current-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 9px 10px;
    border-radius: 8px;
    background: #ecfdf5;
    color: #166534;
}

@media (max-width: 1000px) {
    .delivery-current-grid {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 700px) {
    .delivery-current-grid {
        grid-template-columns: 1fr;
    }
}


/* V57 - uzavřené dodací listy */
.delivery-closed-filter {
    margin: 14px 0 18px;
}
.delivery-closed-table td {
    vertical-align: middle;
}
.delivery-closed-table .actions-inline {
    flex-wrap: wrap;
}


/* V58 - větší okno pro zadání množství */
.delivery-quantity-modal {
    width: min(92vw, 720px) !important;
    max-width: 720px !important;
    padding: 28px !important;
    border-radius: 16px;
}

.delivery-quantity-modal h2,
.delivery-quantity-modal h3 {
    font-size: 26px;
    margin-bottom: 18px;
}

.delivery-quantity-modal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.delivery-quantity-modal-form label {
    font-size: 18px;
    font-weight: 700;
}

.delivery-quantity-input,
.delivery-unit-select {
    width: 100%;
    min-height: 62px;
    font-size: 24px !important;
    padding: 12px 16px !important;
    border-radius: 10px;
}

.delivery-unit-select {
    cursor: pointer;
}

.delivery-quantity-modal .actions-inline,
.delivery-quantity-modal .form-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.delivery-modal-button {
    min-height: 58px;
    padding: 14px 24px !important;
    font-size: 19px !important;
    flex: 1 1 220px;
}

@media (max-width: 700px) {
    .delivery-quantity-modal {
        width: 95vw !important;
        padding: 20px !important;
    }

    .delivery-quantity-modal h2,
    .delivery-quantity-modal h3 {
        font-size: 22px;
    }

    .delivery-modal-button {
        flex-basis: 100%;
    }
}


/* V60 - větší okno při prvním přidávání produktu */
.delivery-add-product-modal {
    width: min(94vw, 820px) !important;
    max-width: 820px !important;
    min-height: 420px;
    padding: 34px !important;
    border-radius: 18px !important;
}

.delivery-add-product-modal h2,
.delivery-add-product-modal h3 {
    font-size: 30px !important;
    line-height: 1.2;
    margin-bottom: 22px !important;
}

.delivery-add-product-modal .small,
.delivery-add-product-modal p {
    font-size: 18px !important;
    line-height: 1.5;
}

.delivery-add-product-form {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 22px !important;
    align-items: end;
}

.delivery-add-product-form label {
    display: block;
    font-size: 20px !important;
    font-weight: 700;
    margin-bottom: 8px;
}

.delivery-add-product-form input[name="quantity"],
.delivery-add-product-form select[name="unit"] {
    width: 100% !important;
    min-height: 72px !important;
    font-size: 28px !important;
    padding: 14px 18px !important;
    border-radius: 12px !important;
}

.delivery-add-product-form .actions-inline,
.delivery-add-product-form .form-actions {
    grid-column: 1 / -1;
    display: flex !important;
    gap: 16px !important;
    margin-top: 8px;
}

.delivery-add-product-form button,
.delivery-add-product-form .btn {
    min-height: 64px !important;
    font-size: 21px !important;
    padding: 16px 28px !important;
    flex: 1 1 240px;
}

@media (max-width: 720px) {
    .delivery-add-product-modal {
        width: 96vw !important;
        min-height: auto;
        padding: 22px !important;
    }

    .delivery-add-product-form {
        grid-template-columns: 1fr;
    }

    .delivery-add-product-form .actions-inline,
    .delivery-add-product-form .form-actions {
        grid-column: 1;
        flex-direction: column;
    }

    .delivery-add-product-form button,
    .delivery-add-product-form .btn {
        width: 100%;
    }
}


/* V61 - skutečný dialog pro zadání množství produktu */
.delivery-add-product-modal-real {
    width: min(94vw, 860px) !important;
    max-width: 860px !important;
    padding: 34px !important;
    border-radius: 18px !important;
}

.delivery-add-product-modal-real h2 {
    font-size: 30px !important;
    margin-bottom: 22px !important;
}

.delivery-add-product-modal-real .product-info,
.delivery-add-product-modal-real .small,
.delivery-add-product-modal-real p {
    font-size: 18px !important;
    line-height: 1.5 !important;
}

.delivery-add-product-form-real {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 22px !important;
    align-items: end !important;
}

.delivery-add-product-form-real label {
    display: block !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    margin-bottom: 8px !important;
}

.delivery-add-quantity-input,
.delivery-add-unit-select {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 74px !important;
    min-height: 74px !important;
    font-size: 30px !important;
    padding: 14px 18px !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
}

.delivery-add-product-form-real .actions-inline,
.delivery-add-product-form-real .form-actions {
    grid-column: 1 / -1 !important;
    display: flex !important;
    gap: 16px !important;
    margin-top: 8px !important;
}

.delivery-add-product-form-real button,
.delivery-add-product-form-real .btn {
    min-height: 64px !important;
    font-size: 21px !important;
    padding: 16px 28px !important;
}

@media (max-width: 720px) {
    .delivery-add-product-modal-real {
        width: 96vw !important;
        padding: 22px !important;
    }

    .delivery-add-product-form-real {
        grid-template-columns: 1fr !important;
    }

    .delivery-add-product-form-real .actions-inline,
    .delivery-add-product-form-real .form-actions {
        grid-column: 1 !important;
        flex-direction: column !important;
    }
}
