/* ============================================================
   VÝDEJNÍ MÍSTA — CSS
   Styl: minimalistický, černo-bílý
   ============================================================ */

/* ---- Variables ---- */
:root {
    --sidebar-w: 260px;
    --color-black: #000000;
    --color-white: #ffffff;
    --color-bg: #f4f4f4;
    --color-border: #e0e0e0;
    --color-border-dark: #b0b0b0;
    --color-muted: #777777;
    --color-hover-bg: #f0f0f0;
    --color-section-bg: #ffffff;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background-color: var(--color-bg);
    color: var(--color-black);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
}

code {
    font-size: .85em;
    color: #222;
    background: #f0f0f0;
    padding: .1em .35em;
    border-radius: 2px;
}


/* ============================================================
   PŘIHLAŠOVACÍ STRÁNKA
   ============================================================ */
#login-page {
    min-height: 100dvh;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-box {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem 2rem 1.75rem;
}

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

.login-brand-logo {
    max-width: 110px;
    height: auto;
    flex-shrink: 0;
}

.login-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -.03em;
    margin-bottom: .15rem;
    color: var(--color-black);
}

.login-subtitle {
    font-size: .78rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 600;
    margin-bottom: 0;
}

.login-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #555;
    margin-bottom: .35rem;
    display: block;
}

.login-input {
    border-color: var(--color-border);
    font-size: .9rem;
    padding: .55rem .75rem;
}

.login-input:focus {
    border-color: var(--color-black);
    box-shadow: none;
}

.login-input.is-invalid {
    border-color: var(--color-black);
    border-width: 2px;
    /* Zakáže Bootstrap's vykřičník uvnitř pole — chyby zobrazujeme textem pod polem */
    background-image: none;
    padding-right: .75rem;
}

.login-password-wrap {
    position: relative;
}

/* Password input — vždy dát místo pro eye button vpravo */
.login-password-wrap .login-input {
    padding-right: 2.5rem;
}

.login-eye {
    position: absolute;
    right: .65rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: .2rem;
    line-height: 1;
    z-index: 5;
}

.login-eye:hover {
    color: var(--color-black);
}

.login-error {
    font-size: .75rem;
    color: var(--color-black);
    font-weight: 600;
    margin-top: .3rem;
    min-height: 1rem;
}

.login-error--general {
    background: #f5f5f5;
    border: 1.5px solid var(--color-black);
    padding: .5rem .75rem;
    display: none;
}

.login-error--general.visible {
    display: block;
}

.login-btn {
    font-size: .9rem;
    font-weight: 700;
    padding: .65rem;
    letter-spacing: .02em;
}

.login-footer {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
    font-size: .73rem;
    color: #bbb;
    text-align: center;
}

@media (max-width: 400px) {
    .login-box {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .login-title {
        font-size: 1.1rem;
    }

    .login-subtitle {
        font-size: .7rem;
    }

    .login-brand-logo {
        max-width: 85px;
    }

    #loginForm .mb-3 {
        margin-bottom: .5rem !important;
    }

    #loginForm .mb-4 {
        margin-bottom: .75rem !important;
    }
}

/* Skrytí aplikace dokud není přihlášeno */
body:not(.logged-in) .mobile-header,
body:not(.logged-in) #sidebar,
body:not(.logged-in) .main-content {
    display: none !important;
}


/* ============================================================
   MOBILE HEADER
   ============================================================ */
.mobile-header {
    position: sticky;
    top: 0;
    z-index: 200;
    min-height: 50px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
}


/* ============================================================
   SIDEBAR
   ============================================================ */

/* Desktop: sidebar vždy viditelný a fixní */
@media (min-width: 992px) {
    #sidebar {
        width: var(--sidebar-w) !important;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: none !important;
        visibility: visible !important;
        border-right: 1px solid var(--color-border);
    }

    .main-content {
        margin-left: var(--sidebar-w);
    }
}

/* Sidebar body */
#sidebar .offcanvas-body,
#sidebar {
    background: var(--color-white);
}

/* Brand */
.sidebar-brand {
    min-height: 56px;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-brand-logo {
    height: 28px;
    width: auto;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: .75rem;
    letter-spacing: .1em;
}

/* Operator info */
.sidebar-user {
    background: #f8f8f8;
    border-bottom: 1px solid var(--color-border);
}

/* Nav links — shared base */
.nav-main-link,
.nav-group-toggle,
.nav-sub-link {
    display: flex;
    align-items: center;
    width: 100%;
    padding: .55rem 1.25rem;
    font-size: .84rem;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.nav-main-link:hover,
.nav-group-toggle:hover,
.nav-sub-link:hover {
    background: var(--color-hover-bg);
    color: var(--color-black);
}

.nav-main-link.active {
    background: var(--color-black);
    color: var(--color-white);
}

/* Group header */
.nav-group-toggle {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    padding-top: .9rem;
    padding-bottom: .4rem;
}

.nav-group-toggle:hover {
    background: transparent;
    color: #444;
}

/* Arrow rotation */
.nav-arrow {
    transition: transform .2s;
}

.nav-group-toggle[aria-expanded="false"] .nav-arrow {
    transform: rotate(-90deg);
}

/* Sub links */
.nav-sub-link {
    padding-left: 2.75rem;
    font-weight: 400;
    color: #444;
}

.nav-sub-link.active {
    font-weight: 600;
    color: var(--color-black);
}

/* Footer */
.sidebar-footer {
    background: var(--color-white);
}

.nav-main-link--logout {
    color: #555;
}

.nav-main-link--logout:hover {
    background: #fff0f0;
    color: #c00;
}


/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    padding: 1.75rem;
    min-height: 100vh;
}

@media (max-width: 575px) {
    .main-content {
        padding: 1rem;
    }
}


/* ============================================================
   SECTION
   ============================================================ */
.content-section {
    background: var(--color-section-bg);
    border: 1px solid var(--color-border);
    padding: 1.75rem;
}

@media (max-width: 575px) {
    .content-section {
        padding: 1.1rem;
    }
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -.03em;
    margin-bottom: .2rem;
}

.section-subtitle {
    font-size: .8rem;
    color: var(--color-muted);
    margin: 0;
}

/* Section divider */
.sec-divider {
    position: relative;
    text-align: center;
    margin: 1.75rem 0;
    height: 1px;
    background: var(--color-border);
    border: none;
}

.sec-divider span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-bg);
    padding: 0 .9rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #999;
}


/* ============================================================
   DASHBOARD — STAT CARDS
   ============================================================ */
.stat-card {
    position: relative;
    overflow: hidden;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    padding: 1.1rem 1.1rem 1rem;
}

.stat-value {
    position: relative;
    z-index: 1;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -.05em;
    line-height: 1;
    color: var(--color-black);
    margin-bottom: .3rem;
    display: flex;
    align-items: center;
}

.stat-label {
    position: relative;
    z-index: 1;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted);
}

.stat-bg-icon {
    position: absolute;
    right: .9rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.8rem;
    color: #ebebeb;
    pointer-events: none;
    z-index: 0;
}

/* Klikatelná varianta */
.stat-card[data-section] {
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
}

.stat-card[data-section]:hover {
    border-color: var(--color-black);
    box-shadow: 3px 3px 0 var(--color-black);
}

/* Alert variant — ohraničení */
.stat-card--alert {
    border: 2px solid var(--color-black);
}

.stat-card--alert[data-section]:hover {
    box-shadow: 3px 3px 0 rgba(0, 0, 0, .35);
}

/* Invertovaná karta */
.stat-card--inverted {
    background: var(--color-black);
    border-color: var(--color-black);
}

.stat-card--inverted .stat-value,
.stat-card--inverted .stat-label {
    color: var(--color-white);
}

.stat-card--inverted .stat-bg-icon {
    color: #2a2a2a;
}


/* ============================================================
   DASHBOARD — INNER CARDS
   ============================================================ */
.inner-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
}

.inner-card-header {
    padding: .7rem 1rem;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
    background: #fafafa;
}

.inner-card-body {
    padding: 1rem;
    flex: 1;
}

/* Activity list */
.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-item {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: .82rem;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    flex-shrink: 0;
    font-size: .75rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
    min-width: 2.5rem;
}

.activity-text {
    color: #333;
}


/* ============================================================
   SEZNAM ZÁSILEK
   ============================================================ */

/* Search */
.search-wrap {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    pointer-events: none;
    z-index: 5;
}

.search-input {
    padding-left: 2.2rem;
    padding-right: 2rem;
    border-radius: 0;
    border-color: var(--color-border);
    font-size: .85rem;
}

.search-input:focus {
    border-color: var(--color-black);
    box-shadow: none;
}

.search-clear {
    position: absolute;
    right: .4rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: .2rem .35rem;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    font-size: .75rem;
    z-index: 5;
}

.search-clear:hover {
    color: #333;
}

/* Filter buttons */
.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    font-size: .78rem;
    font-weight: 600;
    border: 1px solid var(--color-border-dark);
    background: var(--color-white);
    color: #444;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}

.filter-btn:hover {
    background: var(--color-black);
    color: var(--color-white);
    border-color: var(--color-black);
}

.filter-btn--active,
.filter-btn.active {
    background: var(--color-black);
    color: var(--color-white);
    border-color: var(--color-black);
}

.filter-btn--alert {
    border-color: var(--color-black);
    font-style: italic;
}

.filter-count {
    display: inline-block;
    background: rgba(255, 255, 255, .25);
    padding: .05rem .35rem;
    font-size: .7rem;
    font-weight: 700;
}

.filter-btn:not(.filter-btn--active):not(.active) .filter-count {
    background: #eee;
    color: #555;
}

.filter-btn:not(.filter-btn--active):not(.active) .filter-count.filter-count--nonzero {
    background: var(--color-black);
    color: var(--color-white);
}

.filter-count:empty {
    display: none;
}

/* Table */
.table thead th {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    padding: .65rem .75rem;
}

.table tbody td {
    vertical-align: middle;
    padding: .6rem .75rem;
    border-color: var(--color-border);
    font-size: .84rem;
}

.table tbody tr:hover td {
    background: #fafafa;
}

/* Overdue row */
.row-overdue td {
    background: #f9f9f9;
}

.row-overdue td:first-child {
    border-left: 3px solid var(--color-black);
}

/* Issued row */
.row-issued td {
    background: #f6fdf6;
}

.row-issued td:first-child {
    border-left: 3px solid #198754;
}

/* Recently received row (prijem — 15min okno) */
.row-recently-received td {
    background: #f0fbf4;
    opacity: .9;
}

.row-recently-received td:first-child {
    border-left: 3px solid #198754;
}

/* Returning row */
.row-returning td:first-child {
    border-left: 3px solid #555;
}

/* Partial-returned row */
.row-partial-returned td:first-child {
    border-left: 3px solid #888;
}

/* Cancelled row */
.row-cancelled td {
    background: #fdf5f6;
    color: #9e3a3a;
}

.row-cancelled td:first-child {
    border-left: 3px solid #e8b4b8;
}

/* Klikatelný termín vyzvednutí v tabulce */
.deadline-extend-link {
    color: inherit;
}

.deadline-extend-link:hover span {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 2px;
}

.deadline-extend-icon {
    font-size: .7rem;
    margin-left: .3em;
    opacity: .35;
    vertical-align: middle;
    transition: opacity .15s;
}

.deadline-extend-link:hover .deadline-extend-icon {
    opacity: .75;
}

/* Order code */
.order-code {
    font-size: .8rem;
    font-weight: 600;
    background: #f0f0f0;
    color: #111;
    padding: .15em .4em;
}

/* Package badge */
.pkg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    background: var(--color-black);
    color: var(--color-white);
    font-size: .72rem;
    font-weight: 700;
    border-radius: 50%;
}
.pkg-badge--chill {
    background: #0d6efd;
}

/* Pagination */
.page-link {
    color: var(--color-black);
    border-color: var(--color-border);
    font-size: .8rem;
}

.page-item.active .page-link {
    background: var(--color-black);
    border-color: var(--color-black);
}

.page-link:hover {
    background: var(--color-hover-bg);
    color: var(--color-black);
}


/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    display: inline-block;
    padding: .25rem .6rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Odesláno na VM */
.s-sent {
    background: #f0f0f0;
    color: #555;
    border: 1px solid #ccc;
}

/* Přijato na VM */
.s-received {
    background: #e4e4e4;
    color: #111;
    border: 1px solid #aaa;
}

/* Vydáno zákazníkovi */
.s-issued {
    background: var(--color-black);
    color: var(--color-white);
}

/* Dobírka uhrazena */
.s-cod {
    background: var(--color-black);
    color: var(--color-white);
    outline: 2px solid var(--color-black);
    outline-offset: 1px;
}

/* Nevyzvednuto */
.s-overdue {
    background: var(--color-white);
    color: var(--color-black);
    border: 2px solid var(--color-black);
    font-style: italic;
}

/* Část. naskladněno */
.s-partial {
    background: #d6d6d6;
    color: #333;
    border: 1px solid #aaa;
}

/* Vrací se */
.s-returning {
    background: #555;
    color: var(--color-white);
}

/* Část. vráceno */
.s-partial-returned {
    background: #888;
    color: var(--color-white);
}

/* Vráceno odesílateli */
.s-returned {
    background: #e8e8e8;
    color: #666;
    border: 1px solid #ccc;
}

/* Zrušeno */
.s-cancelled {
    background: #f5e6e8;
    color: #9e3a3a;
    border: 1px solid #e8b4b8;
}


/* ============================================================
   DETAIL ZÁSILKY
   ============================================================ */
/* Detail zásilky — grid layout (historie je v DOMu poslední, na desktopu CSS grid ji vrátí doleva) */
.detail-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 992px) {
    .detail-layout {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        grid-template-areas:
            "customer  cod"
            "package   actions"
            "history   .";
        column-gap: 1.5rem;
        row-gap: 1rem;
    }

    .detail-layout__customer {
        grid-area: customer;
    }

    .detail-layout__package {
        grid-area: package;
    }

    .detail-layout__cod {
        grid-area: cod;
    }

    .detail-layout__actions {
        grid-area: actions;
    }

    .detail-layout__history {
        grid-area: history;
    }
}

.detail-block {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    padding: 1.25rem;
}

.detail-block-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    padding-bottom: .65rem;
    margin-bottom: .9rem;
    border-bottom: 1px solid var(--color-border);
}

.detail-field-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #aaa;
    margin-bottom: .15rem;
}

.detail-field-value {
    font-size: .88rem;
    font-weight: 500;
    color: #333;
}

/* Počet balíků — highlight */
.pkg-highlight {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    background: #111;
    color: var(--color-white);
    padding: .7rem 1rem;
    font-size: .9rem;
    font-weight: 600;
}

.pkg-highlight-note {
    font-size: .75rem;
    font-weight: 400;
    color: #999;
}

/* Seznam balíků pod highlight boxem */
.pkg-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .65rem 0 .1rem;
}

.pkg-list-item {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.pkg-barcode-badge {
    display: inline-flex;
    align-items: center;
    column-gap: .35rem;
    font-family: var(--bs-font-monospace, monospace);
    font-size: .78rem;
    font-weight: 500;
    background: #f2f2f2;
    color: #333;
    border: 1px solid #ddd;
    padding: .2rem .55rem;
    border-radius: 3px;
    letter-spacing: .02em;
}

.pkg-barcode-badge--chilled {
    background: #e8f7fb;
    border-color: #9de0ef;
    color: #0a7a94;
}

.pkg-barcode-badge--returned {
    background: #fdecea;
    border-color: #f1b0aa;
    color: #9e3a3a;
}

.pkg-loc-badge {
    font-family: var(--bs-body-font-family, sans-serif);
    font-size: .6rem;
    font-weight: 700;
    color: #fff;
    background: #6c757d;
    border: 1px solid #6c757d;
    padding: .15rem .4rem;
    border-radius: .375rem;
}

.pkg-loc-badge--returned {
    color: #fff;
    background: #7b1f1f;
    border-color: #7b1f1f;
}

.pkg-loc-badge--chilled {
    color: #fff;
    background: #0d6efd;
    border-color: #0d6efd;
}

.detail-link {
    color: #333;
}
.detail-link:hover {
    color: #000;
}

/* Dobírka */
.detail-block--cod {
    border: 1px solid var(--color-border-dark);
}

.detail-block--cod-active {
    border: 2px solid var(--color-black);
}

.cod-amount {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -.04em;
    color: #ccc;
    margin-bottom: .2rem;
    line-height: 1;
}

.cod-amount--active {
    color: var(--color-black);
}

/* Historie */
.history-line {
    position: relative;
    padding-left: 1.5rem;
}

.history-line::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--color-border);
}

.history-entry {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    margin-bottom: 1.1rem;
}

.history-entry:last-child {
    margin-bottom: 0;
}

.history-dot {
    position: absolute;
    left: -1.5rem;
    top: 5px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #d0d0d0;
    border: 2px solid var(--color-white);
    box-shadow: 0 0 0 1px #bbb;
    flex-shrink: 0;
}

.history-dot--filled {
    background: var(--color-black);
    box-shadow: 0 0 0 1px var(--color-black);
}


/* ============================================================
   ŽIVOTNÍ CYKLUS
   ============================================================ */

/* Hlavní track */
.lc-track {
    display: flex;
    align-items: center;
    overflow-x: auto;
    padding: 1.25rem 0 1.5rem;
    gap: 0;
}

.lc-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 90px;
    flex-shrink: 0;
}

.lc-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: #eee;
    color: #bbb;
    border: 2px solid #ddd;
    margin-bottom: .55rem;
    transition: background .2s, color .2s;
}

.lc-step--done .lc-icon {
    background: #e0e0e0;
    color: #444;
    border-color: #999;
}

.lc-step--active .lc-icon {
    background: var(--color-black);
    color: var(--color-white);
    border-color: var(--color-black);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .15);
}

.lc-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--color-black);
    line-height: 1.3;
    margin-bottom: .2rem;
}

.lc-sub {
    font-size: .65rem;
    color: var(--color-muted);
}

.lc-line {
    flex: 1;
    height: 2px;
    background: #e0e0e0;
    min-width: 28px;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.lc-line--done {
    background: #888;
}

/* Alt cards */
.lc-alt-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    padding: 1rem;
}

/* Action panel */
.lc-action-panel {
    background: #f8f8f8;
    border: 1px solid var(--color-border);
    padding: 1.1rem 1.25rem;
}

.lc-action-panel-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted);
    margin-bottom: .85rem;
}

/* COD confirm */
.cod-confirm-box {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    background: var(--color-white);
    border: 2px solid var(--color-black);
    padding: .45rem .9rem;
}


/* ============================================================
   BOOTSTRAP OVERRIDES
   ============================================================ */

/* Buttons */
.btn-dark {
    background: var(--color-black);
    border-color: var(--color-black);
    font-size: .84rem;
    font-weight: 600;
}

.btn-dark:hover {
    background: #222;
    border-color: #222;
}

.btn-outline-dark {
    border-color: var(--color-black);
    color: var(--color-black);
    font-size: .84rem;
    font-weight: 600;
}

.btn-outline-dark:hover {
    background: var(--color-black);
    color: var(--color-white);
}

.btn-outline-secondary {
    font-size: .84rem;
}

/* Table reset */
.table > :not(caption) > * > * {
    box-shadow: none;
}

/* Form control */
.form-control:focus {
    box-shadow: none;
    border-color: var(--color-black);
}


/* ============================================================
   SKENOVÁNÍ ZÁSILEK
   ============================================================ */
.scan-area {
    background: #f8f8f8;
    border: 2px solid var(--color-black);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.scan-input-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.scan-input-icon {
    position: absolute;
    left: 1rem;
    font-size: 1.4rem;
    color: #aaa;
    pointer-events: none;
    z-index: 5;
}

/* Větší tlačítko potvrzení vydání (bez dobírky) na desktopu */
@media (min-width: 768px) {
    .issue-confirm-btn--primary {
        padding-top: 1rem;
        padding-bottom: 1rem;
        font-size: 1.1rem;
    }
}

.scan-input {
    flex: 1;
    border: 2px solid var(--color-black);
    border-right: none;
    border-radius: 0;
    padding: .85rem 1rem .85rem 3rem;
    font-size: 1.1rem;
    font-weight: 500;
    outline: none;
    background: var(--color-white);
    color: var(--color-black);
    letter-spacing: .02em;
    min-width: 0;
    transition: background .12s;
}

.scan-input:focus {
    background: var(--color-white);
    border-color: var(--color-black);
    box-shadow: none;
}

.scan-input::placeholder {
    color: #bbb;
    font-weight: 400;
}

.scan-submit-btn {
    flex-shrink: 0;
    background: var(--color-black);
    color: var(--color-white);
    border: 2px solid var(--color-black);
    padding: .85rem 1.25rem;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s;
}

.scan-submit-btn:hover {
    background: #222;
    border-color: #222;
}

.scan-hint {
    margin-top: .6rem;
    font-size: .75rem;
    color: var(--color-muted);
}

/* Výsledkový panel */
.scan-result {
    border: 2px solid var(--color-black);
    background: var(--color-white);
    margin-bottom: 0;
}

.scan-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
    background: #f8f8f8;
}

.scan-result-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
}

.scan-result-body {
    padding: 1.1rem;
}

/* Chybový stav */
.scan-result--error {
    border-color: var(--color-black);
    background: #fafafa;
}

.scan-result--error .scan-result-header {
    background: var(--color-black);
}

.scan-result--error .scan-result-title {
    color: var(--color-white);
}

/* Zvýraznění počtu balíků ve výsledku */
.scan-pkg-count {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--color-black);
    color: var(--color-white);
    padding: .35rem .8rem;
    font-weight: 700;
    font-size: .95rem;
}

/* Log tabulka — animate-in pro nové řádky */
@keyframes rowIn {
    from {
        background: #e8e8e8;
    }
    to {
        background: transparent;
    }
}

.scan-log-new {
    animation: rowIn 1.5s ease-out forwards;
}

/* Scan result badges */
.scan-ok {
    color: #1a1a1a;
    font-weight: 700;
}

.scan-err {
    color: #555;
    font-weight: 600;
    font-style: italic;
}


/* ============================================================
   CONTROLLING DOBÍREK — platební badges + stavy
   ============================================================ */

/* Způsob platby */
.pay-badge {
    display: inline-block;
    padding: .2rem .55rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.pay-cash {
    background: var(--color-black);
    color: var(--color-white);
}

.pay-card {
    background: var(--color-white);
    color: var(--color-black);
    border: 1.5px solid var(--color-black);
}

/* COD status */
.cod-status {
    display: inline-block;
    padding: .2rem .55rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.cod-status--pending {
    background: #fff8e1;
    color: #555;
    border: 1px solid #d0c070;
    font-style: italic;
}

/* Čeká na převod — B&W varianta */
.cod-status--pending {
    background: #f5f5f5;
    color: #333;
    border: 1.5px solid var(--color-black);
    font-style: italic;
}

.cod-status--done {
    background: #f0f0f0;
    color: #666;
    border: 1px solid #ccc;
}


/* ============================================================
   FINANCE A VYÚČTOVÁNÍ
   ============================================================ */

/* Filtr období */
.period-filter {
    background: #f8f8f8;
    border: 1px solid var(--color-border);
    padding: .9rem 1.1rem;
}

.period-filter-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    margin-bottom: .5rem;
}


/* Bilanční panel */
.balance-panel {
    border: 2px solid var(--color-black);
    background: var(--color-white);
}

.balance-panel-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    padding: .7rem 1.1rem;
    background: #f8f8f8;
    border-bottom: 1px solid var(--color-border);
}

.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
}

.balance-row:last-child {
    border-bottom: none;
}

.balance-row-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    font-size: .88rem;
}

.bal-indicator {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted);
    flex-shrink: 0;
    min-width: 4.2rem;
}

.balance-row--result .bal-indicator {
    color: rgba(255, 255, 255, .55);
}

.balance-row-note {
    font-size: .75rem;
    color: var(--color-muted);
}

.balance-row-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-black);
    white-space: nowrap;
}

.balance-row--plus .balance-row-value {
    color: #1a1a1a;
}

.balance-row--minus .balance-row-value {
    color: #666;
}

.balance-divider {
    height: 2px;
    background: var(--color-black);
    margin: 0;
}

/* Výsledný řádek */
.balance-row--result {
    background: var(--color-black);
    color: var(--color-white);
    border-bottom: none;
}

.balance-row--result .balance-row-label {
    color: var(--color-white);
}

.balance-row--result .balance-row-note {
    color: #aaa;
}

.balance-row-value--result {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--color-white);
}

/* Finance — loading stav */
.finance-is-loading,
.controlling-is-loading {
    opacity: 0.35;
    pointer-events: none;
    transition: opacity .15s;
}

/* Směr převodu badge */
.balance-direction-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .3);
    color: #ddd;
    font-size: .72rem;
    font-weight: 600;
    padding: .15rem .55rem;
    letter-spacing: .04em;
}

/* Transaction type badges */
.tx-badge {
    display: inline-block;
    padding: .15rem .5rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.tx-cod {
    background: var(--color-black);
    color: var(--color-white);
}

.tx-commission {
    background: var(--color-white);
    color: #666;
    border: 1px solid #ccc;
}

/* Pokyn k převodu */
.transfer-notice {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: #f8f8f8;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-black);
    padding: 1rem 1.1rem;
}

.transfer-notice-icon {
    font-size: 1.5rem;
    color: #555;
    flex-shrink: 0;
    padding-top: .1rem;
}


/* ============================================================
   OTEVÍRACÍ DOBA — editor (oh-day / oh-slots)
   ============================================================ */

/* Sloty se zalamují pod checkbox místo krčení — basis = min. komfortní šířka slotu */
.oh-day .oh-slots {
    flex: 1 0 14rem;
    min-width: 0;
}


/* ============================================================
   MOBILNÍ RESPONZIVITA — 400px a méně
   ============================================================ */

/* ---- Administrace zásilek + Výdej — karta od < 1200px ---- */
@media (max-width: 1199px) {

    .admin-orders-wrap,
    .vydej-wrap {
        overflow-x: visible;
    }

    #adminOrdersTable,
    #ordersTable {
        min-width: 0;
        width: 100%;
    }

    #adminOrdersTable thead,
    #ordersTable thead {
        display: none;
    }

    #adminOrdersTable tbody tr,
    #ordersTable tbody tr {
        display: block;
        border: 1px solid var(--color-border);
        margin-bottom: .6rem;
        background: var(--color-white);
    }

    #adminOrdersTable tbody tr:last-child,
    #ordersTable tbody tr:last-child {
        margin-bottom: 0;
    }

    #adminOrdersTable tbody td,
    #ordersTable tbody td {
        display: flex !important;
        align-items: flex-start;
        gap: .4rem;
        padding: .42rem .7rem;
        border-bottom: 1px solid #f0f0f0;
        border-top: none !important;
        border-left: none !important;
        font-size: .84rem;
        text-align: left !important;
    }

    #adminOrdersTable tbody td:last-child,
    #ordersTable tbody td:last-child {
        border-bottom: none;
    }

    #adminOrdersTable td::before,
    #ordersTable td::before {
        content: attr(data-label);
        min-width: 5.5rem;
        flex-shrink: 0;
        font-size: .65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: #aaa;
        padding-top: .18rem;
        line-height: 1.4;
    }

    #adminOrdersTable td[data-label=""]::before,
    #ordersTable td[data-label=""]::before {
        display: none;
    }

    #adminOrdersTable tbody tr.row-overdue,
    #ordersTable tbody tr.row-overdue   { border-top: 3px solid var(--color-black); }
    #adminOrdersTable tbody tr.row-issued,
    #ordersTable tbody tr.row-issued    { border-top: 3px solid #198754; }
    #adminOrdersTable tbody tr.row-returning,
    #ordersTable tbody tr.row-returning { border-top: 3px solid #555; }
    #adminOrdersTable tbody tr.row-partial-returned,
    #ordersTable tbody tr.row-partial-returned { border-top: 3px solid #888; }
    #adminOrdersTable tbody tr.row-cancelled,
    #ordersTable tbody tr.row-cancelled { border-top: 3px solid #e8b4b8; background: #fdf5f6; }

    #adminOrdersTable td[data-label="Akce"] .flex-grow-1,
    #ordersTable td[data-label="Akce"] .flex-grow-1 {
        max-width: 150px;
    }

    /* ---- Lokace — vnitřní tabulky (grid i rows layout) ---- */
    #lokaceContent .table-mobile-cards { min-width: 0; width: 100%; }
    #lokaceContent .table-mobile-cards thead { display: none; }
    #lokaceContent .table-mobile-cards tbody tr {
        display: block;
        border: 1px solid var(--color-border);
        margin-bottom: .4rem;
    }
    #lokaceContent .table-mobile-cards tbody tr:last-child { margin-bottom: 0; }
    #lokaceContent .table-mobile-cards tbody td {
        display: flex !important;
        align-items: flex-start;
        gap: .4rem;
        padding: .42rem .7rem;
        border-bottom: 1px solid #f0f0f0;
        border-top: none !important;
        border-left: none !important;
        font-size: .84rem;
        text-align: left !important;
    }
    #lokaceContent .table-mobile-cards tbody td:last-child { border-bottom: none; }
    #lokaceContent .table-mobile-cards td::before {
        content: attr(data-label);
        min-width: 5.5rem;
        flex-shrink: 0;
        font-size: .65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: #aaa;
        padding-top: .18rem;
        line-height: 1.4;
    }
    #lokaceContent .table-mobile-cards td[data-label=""]::before { display: none; }
    #lokaceContent .table-mobile-cards td.lokace-action-cell > div {
        flex: 1;
        flex-direction: column;
        align-items: stretch;
        gap: .3rem;
    }
    #lokaceContent .table-mobile-cards td.lokace-action-cell .btn {
        width: 100%;
        padding: .375rem .75rem;
        font-size: .875rem;
        text-align: center;
        justify-content: center;
    }
    /* Zobraz text tlačítek (Bootstrap d-sm-none je skrývá při ≥576px) */
    #lokaceContent .table-mobile-cards .d-sm-none {
        display: inline !important;
    }
}

/* ---- Administrace zásilek + Výdej — 2 sloupce uvnitř karty (576–1199px) ---- */
@media (min-width: 576px) and (max-width: 1199px) {

    #adminOrdersTable tbody tr,
    #ordersTable tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    /* Poslední 2 buňky jsou na posledním řádku gridu — bez spodního borderu */
    #adminOrdersTable tbody td:nth-last-child(-n+2),
    #ordersTable tbody td:nth-last-child(-n+2) {
        border-bottom: none;
    }
}


/* ---- Karta místo tabulky na xs ---- */
@media (max-width: 575px) {

    /* Hlavička tabulky se skryje */
    .table-mobile-cards thead {
        display: none;
    }

    /* Každý tbody řádek = karta */
    .table-mobile-cards tbody tr {
        display: block;
        border: 1px solid var(--color-border);
        margin-bottom: .6rem;
        background: var(--color-white);
    }

    .table-mobile-cards tbody tr:last-child {
        margin-bottom: 0;
    }

    /* Každá buňka = flex řádek label | hodnota */
    .table-mobile-cards tbody td {
        display: flex !important; /* přepisuje Bootstrap d-none */
        align-items: flex-start;
        gap: .4rem;
        padding: .42rem .7rem;
        border-bottom: 1px solid #f0f0f0;
        border-top: none !important;
        border-left: none !important;
        font-size: .84rem;
        text-align: left !important;
    }

    .table-mobile-cards tbody td:last-child {
        border-bottom: none;
    }

    /* Štítek z data-label */
    .table-mobile-cards td::before {
        content: attr(data-label);
        min-width: 5.5rem;
        flex-shrink: 0;
        font-size: .65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: #aaa;
        padding-top: .18rem;
        line-height: 1.4;
    }

    .table-mobile-cards td[data-label=""]::before {
        display: none;
    }

    /* Overdue karta — horní border */
    .table-mobile-cards tbody tr.row-overdue {
        border-top: 3px solid var(--color-black);
    }

    /* Issued karta — horní zelený border */
    .table-mobile-cards tbody tr.row-issued {
        border-top: 3px solid #198754;
    }

    /* Recently received karta (prijem — 15min okno) */
    .table-mobile-cards tbody tr.row-recently-received {
        border-top: 3px solid #198754;
        background: #f0fbf4;
        opacity: .9;
    }

    /* Returning karta */
    .table-mobile-cards tbody tr.row-returning {
        border-top: 3px solid #555;
    }

    /* Partial-returned karta */
    .table-mobile-cards tbody tr.row-partial-returned {
        border-top: 3px solid #888;
    }

    /* Cancelled karta */
    .table-mobile-cards tbody tr.row-cancelled {
        border-top: 3px solid #e8b4b8;
        background: #fdf5f6;
    }

    /* tfoot — zůstane jako řádek přes celou šířku */
    .table-mobile-cards tfoot tr {
        display: flex;
        justify-content: space-between;
        padding: .5rem .7rem;
        background: var(--color-black);
    }

    .table-mobile-cards tfoot td {
        display: block !important;
        border: none !important;
        padding: 0 !important;
        font-size: .82rem;
        color: var(--color-white) !important;
        background: transparent !important;
    }

    /* Prázdné tfoot buňky (colspan zbytky) skryj */
    .table-mobile-cards tfoot td:empty {
        display: none !important;
    }

    /* Bez horizontálního scrollu, tabulka má plnou šířku */
    .table-responsive {
        overflow-x: visible;
    }

    .table-mobile-cards {
        min-width: 0;
        width: 100%;
    }

    #adminOrdersTable td[data-label="Akce"] .flex-grow-1 {
        max-width: 150px;
    }

    /* ---- Lokace — akční tlačítka pod sebou ---- */
    .table-mobile-cards td.lokace-action-cell > div {
        flex: 1;
        flex-direction: column;
        align-items: stretch;
        gap: .3rem;
    }
    .table-mobile-cards td.lokace-action-cell .btn {
        width: 100%;
        padding: .375rem .75rem;
        font-size: .875rem;
        text-align: center;
        justify-content: center;
    }

    /* ---- Vyúčtování — kompaktní karta layout ---- */
    #vyuctovaniTable thead { display: none; }
    #vyuctovaniTable { min-width: 0; width: 100%; }

    #vyuctovaniTable tbody tr,
    #vyuctovaniTable tfoot tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        border: 1px solid var(--color-border);
        margin-bottom: .5rem;
        padding: .5rem .6rem;
        gap: .35rem .8rem;
    }

    #vyuctovaniTable tbody tr { background: var(--color-white); }
    #vyuctovaniTable tfoot tr { margin-bottom: 0; }

    /* ---- tbody ---- */

    /* 1: Název VM — přes celou šířku */
    #vyuctovaniTable tbody td:nth-child(1) {
        grid-column: 1 / -1;
        padding-bottom: .3rem;
        border-bottom: 1px solid #f0f0f0;
    }

    /* 2: Adresa — skrytá (zobrazena přímo v td:nth-child(1)) */
    #vyuctovaniTable tbody td:nth-child(2) { display: none !important; }

    /* 3: Dobírky | 5: Provize */
    #vyuctovaniTable tbody td:nth-child(3),
    #vyuctovaniTable tbody td:nth-child(5) {
        display: flex;
        flex-direction: column;
        gap: .1rem;
        text-align: left !important;
        font-size: .84rem;
    }

    /* 4: Transakcí — skrytá (zobrazena jako badge v td:nth-child(1)) */
    #vyuctovaniTable tbody td:nth-child(4) { display: none !important; }

    /* 6: DPH | 7: Saldo — druhý řádek čísel */
    #vyuctovaniTable tbody td:nth-child(6),
    #vyuctovaniTable tbody td:nth-child(7) {
        display: flex;
        flex-direction: column;
        gap: .1rem;
        text-align: left !important;
        font-size: .84rem;
    }

    /* 8: Detail — přes celou šířku, vpravo */
    #vyuctovaniTable tbody td:nth-child(8) {
        grid-column: 1 / -1;
        text-align: right !important;
        padding-top: .3rem;
        border-top: 1px solid #f0f0f0;
    }

    /* Labely tbody */
    #vyuctovaniTable tbody td:nth-child(3)::before { content: "Dobírky"; }
    #vyuctovaniTable tbody td:nth-child(5)::before { content: "Provize"; }
    #vyuctovaniTable tbody td:nth-child(6)::before { content: "DPH"; }
    #vyuctovaniTable tbody td:nth-child(7)::before { content: "Saldo"; }

    #vyuctovaniTable tbody td:nth-child(3)::before,
    #vyuctovaniTable tbody td:nth-child(5)::before,
    #vyuctovaniTable tbody td:nth-child(6)::before,
    #vyuctovaniTable tbody td:nth-child(7)::before {
        font-size: .6rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: #aaa;
    }

    /* ---- tfoot ---- */

    /* 1: "Celkem" — přes celou šířku */
    #vyuctovaniTable tfoot td:nth-child(1) {
        grid-column: 1 / -1;
        padding-bottom: .3rem;
        border-bottom: 1px solid rgba(255,255,255,.15);
    }

    /* 2+3: Dobírky | Transakcí, override d-none na :nth-child(3) */
    #vyuctovaniTable tfoot td:nth-child(2),
    #vyuctovaniTable tfoot td:nth-child(3) {
        display: flex !important;
        flex-direction: column;
        gap: .1rem;
        text-align: left !important;
        font-size: .84rem;
    }

    /* 4+5: Provize | DPH */
    #vyuctovaniTable tfoot td:nth-child(4),
    #vyuctovaniTable tfoot td:nth-child(5) {
        display: flex;
        flex-direction: column;
        gap: .1rem;
        text-align: left !important;
        font-size: .84rem;
    }

    /* 6: Saldo — přes celou šířku */
    #vyuctovaniTable tfoot td:nth-child(6) {
        display: flex;
        flex-direction: column;
        gap: .1rem;
        grid-column: 1 / -1;
        text-align: left !important;
        font-size: .84rem;
        padding-top: .3rem;
        border-top: 1px solid rgba(255,255,255,.15);
    }

    /* 7: prázdná buňka — schovat */
    #vyuctovaniTable tfoot td:nth-child(7) { display: none !important; }

    /* Labely tfoot */
    #vyuctovaniTable tfoot td:nth-child(2)::before { content: "Dobírky"; }
    #vyuctovaniTable tfoot td:nth-child(3)::before { content: "Transakcí"; }
    #vyuctovaniTable tfoot td:nth-child(4)::before { content: "Provize"; }
    #vyuctovaniTable tfoot td:nth-child(5)::before { content: "DPH"; }
    #vyuctovaniTable tfoot td:nth-child(6)::before { content: "Saldo"; }

    #vyuctovaniTable tfoot td:nth-child(2)::before,
    #vyuctovaniTable tfoot td:nth-child(3)::before,
    #vyuctovaniTable tfoot td:nth-child(4)::before,
    #vyuctovaniTable tfoot td:nth-child(5)::before,
    #vyuctovaniTable tfoot td:nth-child(6)::before {
        font-size: .6rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        opacity: .6;
    }

    /* ---- VM Detail modal — mobilní úpravy ---- */

    #vmDetailModal .modal-body {
        padding: .75rem;
    }

    /* vmDetailTable tbody + tfoot — 2-sloupcový grid, K fakturaci nahoře vpravo */
    #vmDetailTable tbody tr,
    #vmDetailTable tfoot tr {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
    }

    #vmDetailTable tfoot tr {
        padding: .5rem .6rem;
        gap: .3rem .6rem;
        background: #212529;
    }

    /* Explicitní umístění všech buněk */
    #vmDetailTable tbody td:nth-child(1),
    #vmDetailTable tfoot td:nth-child(1) { grid-row: 1; grid-column: 1; }

    #vmDetailTable tbody td:nth-child(6),
    #vmDetailTable tfoot td:nth-child(6) { grid-row: 1; grid-column: 2; }

    #vmDetailTable tbody td:nth-child(2),
    #vmDetailTable tfoot td:nth-child(2) { grid-row: 2; grid-column: 1; }

    #vmDetailTable tbody td:nth-child(3),
    #vmDetailTable tfoot td:nth-child(3) { grid-row: 2; grid-column: 2; }

    #vmDetailTable tbody td:nth-child(4),
    #vmDetailTable tfoot td:nth-child(4) { grid-row: 3; grid-column: 1; }

    #vmDetailTable tbody td:nth-child(5),
    #vmDetailTable tfoot td:nth-child(5) { grid-row: 3; grid-column: 2; }

    /* Všechny buňky — label nahoře, hodnota dole */
    #vmDetailTable tbody td,
    #vmDetailTable tfoot td {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: .15rem !important;
    }

    /* K fakturaci (tbody) — výrazné tmavé políčko */
    #vmDetailTable tbody td:nth-child(6) {
        background: #212529;
        color: white;
        border-bottom-color: transparent !important;
    }

    #vmDetailTable tbody td:nth-child(6)::before {
        color: rgba(255,255,255,.55) !important;
    }

    /* tfoot — flex + reset paddingu */
    #vmDetailTable tfoot td {
        display: flex !important;
        text-align: left !important;
        padding: 0;
    }

    #vmDetailTable tfoot td[data-label]::before {
        content: attr(data-label);
        font-size: .6rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        opacity: .6;
    }
}


/* ---- Životní cyklus — vertikální layout na mobilu ---- */
@media (max-width: 575px) {

    .lc-track {
        flex-direction: column;
        align-items: flex-start;
        padding: .5rem 0;
        overflow-x: visible;
    }

    .lc-step {
        flex-direction: row;
        text-align: left;
        min-width: unset;
        width: 100%;
        align-items: center;
        gap: .85rem;
    }

    .lc-icon {
        margin-bottom: 0;
        flex-shrink: 0;
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .lc-label {
        font-size: .82rem;
    }

    .lc-sub {
        font-size: .7rem;
    }

    .lc-line {
        width: 2px;
        height: 20px;
        min-width: unset;
        margin-bottom: 0;
        margin-left: 20px; /* zarovnání se středem .lc-icon */
        flex-shrink: 0;
    }

    /* Alt karty pod sebou */
    .lc-alt-card {
        margin-bottom: .5rem;
    }

    /* Action panel — tlačítka pod sebou */
    .lc-action-panel .d-flex.flex-wrap {
        gap: .5rem;
    }

    .lc-action-panel .btn {
        width: 100%;
    }
}


/* ---- Filtr období — na mobilu pod sebou ---- */
@media (max-width: 575px) {

    .period-filter > .d-flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: .5rem !important;
    }

    .period-filter input[type="date"] {
        width: 100%;
    }

    /* Preset tlačítka jako grid */
    .period-filter .d-flex.gap-1 {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr;
        gap: .3rem !important;
        margin-left: 0 !important;
    }
}


/* ---- Scan area — mobilní úpravy ---- */
@media (max-width: 575px) {

    .scan-area {
        padding: 1rem;
    }

    .scan-input-wrap {
        flex-direction: column;
        gap: 0;
    }

    .scan-input {
        border-right: 2px solid var(--color-black);
        border-bottom: none;
        padding: .75rem 1rem .75rem 2.75rem;
        font-size: 1rem;
        width: 100%;
    }

    .scan-submit-btn {
        width: 100%;
        text-align: center;
        border-top: none;
        padding: .65rem;
    }

    .scan-input-icon {
        top: 1rem;
        transform: none;
    }

    /* inner-card-header s tlačítkem */
    .inner-card-header {
        display: flex;
        align-items: center;
    }
}


/* ---- Hlavní layout — sekce plnou šířkou ---- */
@media (max-width: 575px) {

    .main-content {
        padding: .75rem;
    }

    .content-section {
        padding: 1rem .9rem;
    }

    /* Bilanční panel — hodnota pod labelem */
    .balance-row {
        flex-direction: column;
        align-items: flex-start;
        gap: .35rem;
    }

    .balance-row--result .balance-row-value--result {
        font-size: 1.25rem;
    }

    /* Detail bloky */
    .detail-block {
        padding: 1rem .9rem;
    }

    /* Přehled stavů — wrap */
    .d-flex.flex-wrap.gap-2 {
        gap: .35rem !important;
    }

    /* Tlačítka exportu v sekci finance */
    .section-header .d-flex.gap-2 {
        flex-direction: column;
        width: 100%;
    }

    .section-header .d-flex.gap-2 .btn {
        width: 100%;
    }
}


/* ---- Stat karty — menší hodnoty na mobilu ---- */
@media (max-width: 575px) {

    .stat-value {
        font-size: 1.35rem;
        letter-spacing: -.03em;
    }

    .stat-bg-icon {
        font-size: 2rem;
        right: .6rem;
        color: #f0f0f0;
    }

    .stat-card--inverted .stat-bg-icon {
        color: #222;
    }
}


/* ---- Controlling — custom 2-row karta layout ---- */
@media (max-width: 575px) {
    #codTable tbody tr {
        display: grid !important;
        grid-template-columns: 5.5rem 1fr auto;
        gap: .25rem .6rem;
        padding: .6rem .7rem;
    }
    #codTable tbody td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        font-size: .82rem;
        text-align: left !important;
    }
    #codTable tbody td::before { display: none !important; }

    /* Řádek 1: datum | zákazník | zásilka */
    #codTable tbody td:nth-child(1) { grid-row: 1; grid-column: 1; }
    #codTable tbody td:nth-child(2) { grid-row: 1; grid-column: 2; text-align: center !important; }
    #codTable tbody td:nth-child(3) { grid-row: 1; grid-column: 3; text-align: right !important; }

    /* Řádek 2: "Platba [badge]" | částka */
    #codTable tbody td:nth-child(4) { grid-row: 2; grid-column: 1 / 3; display: flex !important; align-items: center; }
    #codTable tbody td:nth-child(4)::before {
        display: block !important;
        width: 5.5rem;
        flex-shrink: 0;
        content: "Platba";
        font-size: .65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: #aaa;
    }
    #codTable tbody td:nth-child(4) .pay-badge { margin: 0 auto; }
    #codTable tbody td:nth-child(5) {
        grid-row: 2;
        grid-column: 3;
        text-align: right !important;
        font-weight: 600;
    }
    #codTable tbody td[colspan] {
        grid-column: 1 / -1 !important;
        display: block !important;
        text-align: center !important;
        padding: 1rem .5rem !important;
    }
}


/* ============================================================
   ICON BUTTON TOOLTIP (okamžitý, CSS-only, přes data-tooltip)
   ============================================================ */

/* Desktop: text skrytý, viditelná jen ikona */
.btn-label {
    display: none;
}

/* Mobil (< 576px): text viditelný, tlačítka na celou šířku, tooltip vypnutý */
@media (max-width: 575.98px) {
    .btn-label {
        display: inline;
    }
    .misto-row .btn-icon-tooltip {
        width: auto;
        justify-content: center;
    }
    #mistaTable td[data-label="Akce"] {
        display: block !important;
    }
    #mistaTable td[data-label="Akce"]::before {
        display: none;
    }
    #mistaTable td[data-label="Akce"] .btn {
        width: 100px !important;
        flex-grow: 0 !important;
    }
    .btn-icon-tooltip.tip-visible::after {
        display: none !important;
    }
}
.btn-icon-tooltip::after {
    content: attr(data-tooltip);
    position: fixed;
    left: var(--_tip-x, -9999px);
    top: var(--_tip-y, -9999px);
    transform: translateX(-50%) translateY(calc(-100% - 6px));
    background: #fff;
    color: #111;
    border: 1px solid #bbb;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
    font-size: .72rem;
    font-weight: 500;
    white-space: nowrap;
    padding: .2rem .45rem;
    pointer-events: none;
    display: none;
    z-index: 9999;
}

.btn-icon-tooltip.tip-visible::after {
    display: block;
}


/* ============================================================
   VM MULTISELECT
   ============================================================ */
.vm-multiselect {
    position: relative;
    display: inline-block;
}

.vm-multiselect-trigger {
    display: flex;
    align-items: center;
    gap: 0;
}

.vm-multiselect-toggle {
    display: inline-flex;
    align-items: center;
    padding: .375rem .75rem;
    font-size: .8125rem;
    font-weight: 500;
    border: 1.5px solid var(--color-black);
    background: var(--color-white);
    color: var(--color-black);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.vm-multiselect-toggle:hover,
.vm-multiselect--open .vm-multiselect-toggle {
    background: var(--color-black);
    color: var(--color-white);
}

.vm-multiselect--active .vm-multiselect-toggle {
    background: var(--color-black);
    color: var(--color-white);
}

.vm-multiselect-chevron {
    font-size: .7rem;
    transition: transform .2s ease;
}

.vm-multiselect--open .vm-multiselect-chevron {
    transform: rotate(180deg);
}

.vm-multiselect-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    width: 2.25rem;
    padding: 0;
    border: 1.5px solid var(--color-black);
    border-left: none;
    background: var(--color-black);
    color: var(--color-white);
    cursor: pointer;
    font-size: .8rem;
    transition: opacity .15s;
}

.vm-multiselect-clear:hover {
    opacity: .75;
}

.vm-multiselect-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 1050;
    min-width: 260px;
    max-width: 360px;
    background: var(--color-white);
    border: 1.5px solid var(--color-black);
    box-shadow: 4px 4px 0 rgba(0,0,0,.12);
    display: none;
}

.vm-multiselect--open .vm-multiselect-dropdown {
    display: block;
    animation: vmDropdownIn .15s ease;
}

@keyframes vmDropdownIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.vm-multiselect-search-wrap {
    position: relative;
    padding: .5rem;
    border-bottom: 1px solid var(--color-border);
}

.vm-multiselect-search-icon {
    position: absolute;
    left: .875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    font-size: .8rem;
    pointer-events: none;
}

.vm-multiselect-search-input {
    width: 100%;
    padding: .3rem .5rem .3rem 1.75rem;
    font-size: .8rem;
    border: 1px solid var(--color-border);
    outline: none;
    background: var(--color-white);
}

.vm-multiselect-search-input:focus {
    border-color: var(--color-black);
}

.vm-multiselect-list {
    max-height: 240px;
    overflow-y: auto;
    padding: .25rem 0;
}

.vm-multiselect-loading {
    padding: .75rem;
    text-align: center;
    color: var(--color-muted);
}

.vm-multiselect-item {
    display: flex;
    align-items: stretch;
    gap: .5rem;
    padding: 0 .75rem;
    font-size: .8125rem;
    cursor: pointer;
    user-select: none;
    transition: background .1s;
}

.vm-multiselect-item:hover {
    background: var(--color-hover-bg);
}

.vm-multiselect-item input[type="checkbox"] {
    flex-shrink: 0;
    align-self: center;
    accent-color: var(--color-black);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.vm-multiselect-item label {
    flex: 1;
    cursor: pointer;
    margin: 0;
    padding: .35rem 0;
    line-height: 1.3;
    display: flex;
    align-items: center;
}

.vm-multiselect-empty {
    padding: .6rem .75rem;
    font-size: .8rem;
    color: var(--color-muted);
    font-style: italic;
}

/* ============================================================
   LOKACE — Drag & Drop overlay
   ============================================================ */

#lokaceOverlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
    overflow-y: auto;
    user-select: none;
    -webkit-user-select: none;
}

#lokaceOverlayInner {
    width: 100%;
    max-width: 880px;
}

.lob-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.lob-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.82rem;
    margin-bottom: 18px;
}

.lokace-overlay-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.lokace-overlay-box {
    background: #fff;
    border: 2px solid #dee2e6;
    padding: 10px 14px;
    min-width: 108px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, transform 0.08s;
}

.lokace-overlay-stay  { border-color: #6c757d; background: #f1f3f5; }
.lob-chlazena         { border-color: #0d6efd; }
.lob-bezlokace        { border-color: #ffc107; background: #fffdf0; }

.lokace-overlay-box.lob-hover {
    border-color: #000;
    background: #e8f0fe;
    transform: scale(1.06);
}
.lokace-overlay-stay.lob-hover {
    background: #dee2e6;
    border-color: #495057;
    transform: scale(1.04);
}
.lob-bezlokace.lob-hover {
    background: #fff3cd;
    border-color: #fd7e14;
}

.lob-code  { font-family: monospace; font-size: 0.98rem; font-weight: 700; line-height: 1.2; }
.lob-count { font-size: 0.72rem; color: #555; display: block; margin-top: 3px; }
.lob-empty { font-size: 0.7rem; color: #aaa; display: block; margin-top: 3px; font-style: italic; }
.lob-sub   { font-size: 0.72rem; color: #888; margin-top: 2px; }
.lob-snow  { color: #0d6efd; font-size: 0.8rem; }

.lob-chill-warn {
    color: #c0392b;
    font-size: 0.68rem;
    font-weight: 600;
    margin-top: 5px;
    line-height: 1.2;
}

/* Drag handle — tlačítko pro zahájení přesunu */
.lokace-drag-handle { cursor: grab; }
.lokace-drag-handle:active { cursor: grabbing; }

/* Ghost — plovoucí štítek sledující kurzor */
#lokaceDragGhost {
    position: fixed;
    z-index: 1600;
    background: #212529;
    color: #fff;
    padding: 5px 11px;
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    opacity: 0.92;
}

/* ============================================================
   Schvalování změn — diff tabulky
   ============================================================ */
.schv-card { border: 1px solid var(--color-border); margin-bottom: 1.5rem; }
.schv-card-header { background: #f8f9fa; padding: .75rem 1rem; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.schv-card-body { padding: 1rem; }
.schv-section-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; margin: 1.1rem 0 .35rem; }
.schv-section-title:first-child { margin-top: 0; }
.schv-diff-table { width: 100%; border-collapse: collapse; font-size: .875rem; table-layout: fixed; margin-bottom: .25rem; }
.schv-diff-table td { padding: .28rem .5rem; vertical-align: middle; overflow-wrap: break-word; }
.schv-col-label { width: 9rem; }
.schv-col-old   { width: 38%; }
.schv-col-arrow { width: 1.8rem; }
.schv-label { color: #6c757d; }
.schv-old { color: #dc3545; text-decoration: line-through; }
.schv-arrow { color: #adb5bd; text-align: center; }
.schv-new { color: #198754; font-weight: 500; }
.schv-dash { color: #adb5bd; }
.schv-unchanged-val { color: #212529; }
.schv-note { color: #adb5bd; font-size: .78em; font-style: italic; margin-left: .4rem; }
.schv-row-unchanged td { opacity: .6; }
.schv-row-warn { background: #fff8e1; }
.schv-row-warn .schv-label { color: #5d4037 !important; font-weight: 600; }
.schv-no-snapshot { color: #6c757d; font-size: .85rem; }
@media (max-width: 575px) {
    .schv-diff-table, .schv-diff-table tbody { display: block; }
    .schv-col-label, .schv-col-old, .schv-col-arrow, .schv-col-new { width: auto; }
    .schv-diff-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .3rem; padding: .25rem 0; border-bottom: 1px dotted #dee2e6; }
    .schv-diff-table td { padding: .1rem .2rem; overflow-wrap: anywhere; }
    .schv-label { flex: 0 0 100%; font-weight: 500; color: #495057 !important; opacity: 1 !important; }
    .schv-old, .schv-arrow, .schv-new, .schv-dash { flex: 0 1 auto; }
    .schv-unchanged-val { flex: 1 1 auto; }
    .schv-row-unchanged td { opacity: .7; }
}


/* ============================================================
   LOKACE — sticky card header + thead
   ============================================================ */
#lokaceContent .card-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Pod lg breakpointem je nahoře mobile-header (50px) */
@media (max-width: 991.98px) {
    #lokaceContent .card-header {
        top: 50px;
    }
}

/* Desktop: thead se přilepí těsně pod card-header
   card-header výška ≈ py-2 (1rem) + fs-5 text (1.875rem) = 2.875rem */
@media (min-width: 1200px) {
    #lokaceContent .table-mobile-cards thead {
        position: sticky;
        top: 2.875rem;
        z-index: 9;
    }
}

