/* ==========================================================================
   Megaprojects Container Tracking
   White background · black + orange text
   Orange matches the Megaprojects logo (approx. #E0610D)
   ========================================================================== */

:root {
    --mp-orange:       #E0610D;
    --mp-orange-dark:  #B94C00;
    --mp-orange-soft:  #FFF1E4;

    --mp-black:        #111111;
    --mp-ink:          #1a1a1a;
    --mp-muted:        #666666;
    --mp-line:         #e5e5e5;
    --mp-line-strong:  #cfcfcf;

    --mp-bg:           #ffffff;
    --mp-bg-soft:      #fafafa;

    --mp-ok:           #1f7a3a;
    --mp-warn:         #a26a00;
    --mp-err:          #b00020;

    --radius:          10px;
    --radius-sm:       6px;
    --shadow-sm:       0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
    --shadow-md:       0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);

    --font:            -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                       "Helvetica Neue", Arial,
                       "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
                       "Noto Sans CJK SC", "WenQuanYi Micro Hei",
                       sans-serif;
    --font-mono:       "SFMono-Regular", ui-monospace, "Menlo", Consolas,
                       "Microsoft YaHei", "PingFang SC", monospace;
}

* { box-sizing: border-box; }

html {
    /* Always reserve space for the vertical scrollbar so the centered
       header and main area don't shift when a page is long enough to
       introduce one. */
    scrollbar-gutter: stable;
    overflow-y: scroll;
    /* Prevent Safari from automatically rescaling text/viewport when an
       AutoFill suggestion popover appears on focus. We control sizing. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
html, body {
    margin: 0;
    padding: 0;
    background: var(--mp-bg);
    color: var(--mp-black);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--mp-orange); text-decoration: none; }
a:hover { color: var(--mp-orange-dark); text-decoration: underline; }

h1, h2, h3 { color: var(--mp-black); margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.0rem; }

code { font-family: var(--font-mono); font-size: 0.92em; background: #f3f3f3; padding: 1px 4px; border-radius: 4px; }

.muted { color: var(--mp-muted); }
.small { font-size: 0.85rem; }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
    background: #ffffff;
    border-bottom: 3px solid var(--mp-orange);
    box-shadow: var(--shadow-sm);
    position: sticky; top: 0; z-index: 10;
}
.header-inner {
    max-width: 1100px; margin: 0 auto;
    padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 24px; color: var(--mp-black); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 80px; width: auto; display: block; }
/* Default (desktop): show long prefix + long labels, hide short variants */
.session-prefix-short { display: none; }
.role-short { display: none; }
.wh-stat-short { display: none; }

.brand-title {
    font-size: 1.5rem; font-weight: 800;
    color: var(--mp-black);
    letter-spacing: .02em;
    line-height: 1;
    text-transform: uppercase;
    min-height: 80px;
    display: flex;
    align-items: center;
}

.site-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.site-nav a { color: var(--mp-black); font-weight: 500; font-size: 1.05rem; }
.site-nav a:hover { color: var(--mp-orange); text-decoration: none; }
.session { color: var(--mp-black); font-size: 1.1rem; }
.session strong { color: var(--mp-orange); }

.badge {
    display: inline-block; margin-left: 6px;
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    padding: 2px 8px; border-radius: 999px; letter-spacing: .04em;
    border: 1px solid transparent;
}
.badge-internal { background: var(--mp-black); color: #fff; }
.badge-customer { background: var(--mp-black); color: #fff; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.site-main {
    max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px;
}

/* Wide layout — used on pages that need full browser width (e.g. warehouse hall) */
body.layout-wide .header-inner { max-width: none; padding: 14px 32px; }
body.layout-wide .site-main { max-width: none; padding: 24px 32px 48px; }
.container-wrap { display: block; }
.page-head { margin-bottom: 16px; }
.section-title {
    margin-top: 28px; margin-bottom: 10px;
    padding-bottom: 6px; border-bottom: 1px solid var(--mp-line);
}

.breadcrumb { margin: 0 0 8px; font-size: 1.15em; font-weight: 700; }
.breadcrumb a { font-weight: 700; }
.breadcrumb a .bc-arrow { font-size: 1.6em; font-weight: 900; line-height: 1; vertical-align: -2px; margin-right: 4px; }

.site-footer {
    border-top: 1px solid var(--mp-line);
    background: #ffffff;
    color: var(--mp-muted);
    font-size: .85rem;
    margin-top: 32px;
}
.footer-inner {
    max-width: 1100px; margin: 0 auto; padding: 14px 16px;
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Buttons / alerts / forms
   -------------------------------------------------------------------------- */
.btn {
    display: inline-block; border: 1px solid transparent;
    padding: 8px 14px; border-radius: var(--radius-sm);
    font-weight: 600; cursor: pointer; font-size: .95rem;
    text-decoration: none; line-height: 1.2;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--mp-orange); color: #fff; }
.btn-primary:hover { background: var(--mp-orange-dark); color: #fff; }
.btn:disabled,
.btn[disabled] {
    background: #c9c9c9 !important;
    color: #666 !important;
    border-color: #c9c9c9 !important;
    cursor: not-allowed;
    opacity: 1;
}
.btn:disabled:hover,
.btn[disabled]:hover { background: #c9c9c9 !important; color: #666 !important; }
.btn-ghost { background: transparent; color: var(--mp-black); border-color: var(--mp-line-strong); }
.btn-ghost:hover { color: var(--mp-orange); border-color: var(--mp-orange); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }

.alert {
    padding: 10px 14px; border-radius: var(--radius-sm);
    margin: 12px 0; border: 1px solid transparent;
}
.alert-error { background: #fff4f4; border-color: #f3c2c2; color: var(--mp-err); }
.alert-ok    { background: #f1faf2; border-color: #c7e7cf; color: var(--mp-ok); }
.alert-info  { background: var(--mp-orange-soft); border-color: var(--mp-orange); color: var(--mp-black); }

form label { display: block; margin: 10px 0 4px; font-weight: 600; }
form input[type=text],
form input[type=password],
form input[type=file],
form input[type=email],
form input[type=tel],
form textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--mp-line-strong); border-radius: var(--radius-sm);
    /* Lock font-family + font-size explicitly so the input does not change
       its computed size when focus moves away (Safari on desktop falls back
       to its native autofill/system font otherwise, which is visibly larger).
       Font-size must be >= 16px on mobile to prevent iOS Safari/Chrome from
       auto-zooming the viewport on focus. */
    font-family: var(--font-sans), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px !important;
    line-height: 1.4;
    background: #fff; color: var(--mp-black);
    -webkit-text-fill-color: var(--mp-black);
    vertical-align: top;
    -webkit-appearance: none;
    appearance: none;
}
/* Suppress Safari/Chrome autofill style override which changes font + bg */
form input:-webkit-autofill,
form input:-webkit-autofill:hover,
form input:-webkit-autofill:focus,
form input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--mp-black);
    -webkit-box-shadow: 0 0 0 1000px #fff inset;
    font-size: 16px !important;
    font-family: var(--font-sans), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    transition: background-color 9999s ease-in-out 0s;
}
form textarea { font-family: var(--font-mono); font-size: .88rem; }
form input:focus, form textarea:focus {
    outline: none; border-color: var(--mp-orange);
    box-shadow: 0 0 0 3px rgba(224,97,13,.15);
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
.login-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--mp-bg);
    padding: 20px;
}
.login-card {
    background: #fff;
    width: 100%; max-width: 420px;
    padding: 28px 26px;
    border: 1px solid var(--mp-line);
    border-top: 4px solid var(--mp-orange);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    text-align: center;
    /* Prevent Safari AutoFill from rescaling the viewport when the suggestion
       popover does not fit next to the focused input. By giving the card a
       comfortable width AND locking text-size-adjust we tell Safari that we
       handle our own layout — no auto-zoom needed. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
.login-logo {
    max-width: 120px; height: auto; margin: 4px auto 16px; display: block;
}
.login-card h1 { color: var(--mp-black); margin-bottom: 4px; font-size: 1.5rem; }
.login-card p.muted { margin-top: 0; }
.login-card form { text-align: left; margin-top: 14px; }
.login-card .btn { margin-top: 16px; }

/* --------------------------------------------------------------------------
   Container list cards (inspired by VesselFinder layout)
   -------------------------------------------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}
.ct-card {
    background: #fff;
    border: 1px solid var(--mp-line);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--mp-black);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s, transform .05s;
    display: block;
}
.ct-card:hover {
    border-color: var(--mp-orange);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}
.ct-card:active { transform: translateY(1px); }
.ct-card-head { text-align: center; }
.ct-card-number {
    font-size: 1.15rem; font-weight: 800; letter-spacing: .04em;
    color: var(--mp-black);
}
.ct-card-note { color: var(--mp-orange-dark); font-size: .92rem; margin-top: 2px; }
.ct-card-vessel {
    font-size: .85rem; color: var(--mp-muted); margin-top: 2px;
    display: inline-flex; align-items: center; gap: 6px;
}
.ct-card-vessel .flag { font-size: 1rem; line-height: 1; }
.ct-card-vessel strong { color: var(--mp-black); font-weight: 700; }

.ct-card-route {
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--mp-line);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px; align-items: center;
}
.ct-endpoint { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.ct-endpoint-right { align-items: flex-end; text-align: right; }
.ct-endpoint .flag { font-size: 1.3rem; line-height: 1; }
.ct-endpoint .place { font-weight: 600; color: var(--mp-black); }
.ct-endpoint .date { font-size: .85rem; color: var(--mp-muted); }
.ct-arrow { color: var(--mp-orange); font-size: 2.2rem; font-weight: 700; line-height: 1; }
.ct-arrow-col {
    display: flex; flex-direction: column; align-items: center; gap: 0;
    min-width: 70px;
}
.ct-arrow-col .ct-card-badge { margin-top: 6px; margin-bottom: -2px; }
.ct-arrow-col .ct-arrow { line-height: 1; }

/* Tracked shipments counter, shown directly below the last card. */
.ct-tracked-count {
    margin: 14px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--mp-line);
    text-align: right;
    font-size: .9rem;
    color: var(--mp-muted);
    letter-spacing: .02em;
}
.ct-tracked-count-num {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--mp-bg-soft);
    color: var(--mp-black);
    font-weight: 700;
}

/* Container overview footer buttons (ISF Filings + Archived Containers).
   Desktop: ISF on the left (absolute), Archived centered. Mobile: stack
   left-aligned with a gap so the buttons can never overlap. */
.ct-archive-link {
    margin: 24px 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: 12px;
    flex-wrap: wrap;
}
.ct-archive-link__isf { position: absolute; left: 0; }
@media (max-width: 720px) {
    .ct-archive-link { justify-content: flex-start; }
    .ct-archive-link__isf { position: static; }
}

/* View toggle (tile / list) */
.view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-right: 10px;
    background: #fff;
    border: 1px solid var(--mp-line);
    border-radius: var(--radius);
    padding: 2px;
    vertical-align: middle;
}
.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 30px;
    background: transparent;
    border: 0;
    border-radius: 4px;
    color: var(--mp-muted);
    cursor: pointer;
    padding: 0;
    transition: background-color .12s, color .12s;
}
.view-toggle-btn:hover { color: var(--mp-black); background: var(--mp-bg-soft); }
.view-toggle-btn.is-active {
    background: var(--mp-orange);
    color: #fff;
}
.view-toggle-btn.is-active:hover { background: var(--mp-orange); color: #fff; }

/* List-view layout: reuse .ct-card markup but stretch each card to a single row. */
.card-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.card-grid.view-list .ct-card-wrap { width: 100%; }
.card-grid.view-list .ct-card {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 2fr) auto;
    align-items: center;
    gap: 14px;
    padding: 8px 14px;
}
.card-grid.view-list .ct-card-head {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.card-grid.view-list .ct-card-number { font-size: 1rem; }
.card-grid.view-list .ct-card-note { margin-top: 0; font-size: .82rem; }
.card-grid.view-list .ct-card-route {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    grid-column: 2 / 3;
    gap: 6px;
}
.card-grid.view-list .ct-endpoint .place { font-size: .92rem; font-weight: 600; }
.card-grid.view-list .ct-endpoint .date { font-size: .78rem; }
.card-grid.view-list .ct-endpoint .flag { font-size: 1.05rem; }
.card-grid.view-list .ct-arrow-col { min-width: 0; flex-direction: row; gap: 6px; }
.card-grid.view-list .ct-arrow-col .ct-card-badge { margin: 0; }
.card-grid.view-list .ct-arrow-col .ct-arrow { font-size: 1.4rem; }
.card-grid.view-list .ct-card-nodata-tag,
.card-grid.view-list .ct-card-waiting-tag {
    position: static;
    grid-column: 3 / 4;
    justify-self: end;
}
.card-grid.view-list .ct-card-archive-actions {
    margin-left: 0;
    display: inline-flex;
    gap: 4px;
}
@media (max-width: 720px) {
    .card-grid.view-list .ct-card {
        grid-template-columns: 1fr;
    }
    .card-grid.view-list .ct-card-route {
        grid-column: 1 / -1;
        border-top: 1px solid var(--mp-line);
        padding-top: 6px;
        margin-top: 4px;
    }
}

/* Warehouse cards in list-mode: align stats column-wise across cards.
   Layout: head (fixed) | stats (fixed 4 columns, right-aligned). */
.card-grid.view-list .wh-card {
    grid-template-columns: 220px 1fr;
    gap: 16px;
    padding: 12px 16px;
}
.card-grid.view-list .wh-card .wh-stats {
    padding: 0;
    grid-template-columns: repeat(4, 90px);
    gap: 8px;
    justify-content: end;
    margin-top: 0;
    border-top: 0;
}
.card-grid.view-list .wh-card .wh-stat {
    padding: 8px 4px !important;
}
.card-grid.view-list .wh-card .wh-stat-num {
    font-size: 18px;
}
@media (max-width: 720px) {
    .card-grid.view-list .wh-card {
        grid-template-columns: 1fr;
    }
    .card-grid.view-list .wh-card .wh-stats {
        grid-template-columns: repeat(4, 1fr);
        justify-content: stretch;
    }
}

.empty {
    border: 1px dashed var(--mp-line-strong);
    padding: 28px; text-align: center; border-radius: var(--radius);
    background: var(--mp-bg-soft);
}

/* --------------------------------------------------------------------------
   Container detail
   -------------------------------------------------------------------------- */
.ct-summary {
    background: #fff;
    border: 1px solid var(--mp-line);
    border-top: 4px solid var(--mp-orange);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.ct-summary-top { text-align: center; margin-bottom: 10px; }
.ct-summary-number {
    font-size: 1.5rem; font-weight: 800; letter-spacing: .04em;
    color: var(--mp-black);
}
.ct-summary-note { color: var(--mp-muted); margin-top: 4px; }
.ct-summary-equipment { color: var(--mp-muted); margin-top: 2px; font-size: .92rem; }
.ct-summary-vessel {
    margin-top: 4px; color: var(--mp-muted);
    display: inline-flex; align-items: center; gap: 8px;
    justify-content: center;
}
.ct-summary-vessel .flag { font-size: 1.15rem; line-height: 1; }
.ct-summary-vessel strong { color: var(--mp-orange); font-weight: 700; font-size: 1.2rem; }
.ct-summary-note-wrap { margin-top: 4px; }
.ct-summary-note-wrap .ct-summary-note {
    display: inline-flex; align-items: center; gap: 8px;
    justify-content: center;
}
.ct-summary-note-wrap [hidden] { display: none !important; }
.ct-summary-note-wrap .ct-note-edit-btn { padding: 2px 8px; font-size: .8rem; }
.ct-summary-note-edit {
    display: inline-flex; align-items: center; gap: 6px;
    justify-content: center;
    margin-top: 4px; flex-wrap: wrap;
}
.ct-summary-note-edit input[name="note"] {
    min-width: 280px;
    padding: 4px 8px;
    border: 1px solid var(--mp-line);
    border-radius: 4px;
    font: inherit;
}

/* Equipment-line edit (mirrors note-edit) */
.ct-summary-equipment-wrap { margin-top: 2px; }
.ct-summary-equipment-wrap .ct-summary-equipment {
    display: inline-flex; align-items: center; gap: 8px;
    justify-content: center;
}
.ct-summary-equipment-wrap [hidden] { display: none !important; }
.ct-summary-equipment-wrap .ct-eq-edit-btn { padding: 2px 8px; font-size: .8rem; }
.ct-summary-equipment-edit {
    display: inline-flex; align-items: center; gap: 6px;
    justify-content: center;
    margin-top: 4px; flex-wrap: wrap;
}
.ct-summary-equipment-edit input[type="text"] {
    width: auto;
    padding: 4px 8px;
    border: 1px solid var(--mp-line);
    border-radius: 4px;
    font: inherit;
    background: #fff;
}

/* Uppercase the VALUE only — placeholders remain in their original case. */
.input-upper { text-transform: uppercase; }
.input-upper::placeholder { text-transform: none; }

.ct-route {
    margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--mp-line);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center; gap: 12px;
}
.flag-big { font-size: 2rem; line-height: 1; }

/* flag-icons SVG rendering: give the .fi span real box dimensions and
   vertically align it with adjacent text. */
.fi {
    display: inline-block;
    vertical-align: -0.125em;
    width: 1.333em;
    height: 1em;
    background-size: cover;
    background-position: 50%;
    background-repeat: no-repeat;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,.06) inset;
}
.fi.flag-unknown {
    background: repeating-linear-gradient(45deg, #e5e5e5 0 6px, #f5f5f5 6px 12px);
}
.place-big { font-weight: 700; color: var(--mp-black); font-size: 1.05rem; margin-top: 2px; }
.ct-arrow-big { color: var(--mp-orange); font-size: 2.2rem; font-weight: 700; line-height: 1; }

.progress-wrap {
    margin-top: 14px;
    background: #f1f1f1;
    border-radius: 999px;
    height: 20px; overflow: hidden;
    border: 1px solid var(--mp-line-strong);
}
.progress-bar {
    background: var(--mp-orange);
    height: 100%;
    color: #fff; font-size: .78rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    min-width: 2em;
    transition: width .3s ease;
}

.ct-meta {
    display: flex; gap: 12px; flex-wrap: wrap;
    margin-top: 12px; color: var(--mp-muted); font-size: .85rem;
    align-items: center;
}

.ct-current { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--mp-line); }
.ct-current h3 { color: var(--mp-orange); margin-bottom: 6px; }

/* --------------------------------------------------------------------------
   Timeline
   -------------------------------------------------------------------------- */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.tl-stop {
    background: #fff;
    border: 1px solid var(--mp-line);
    border-left: 4px solid var(--mp-orange);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
}
.tl-stop-head {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding-bottom: 8px; margin-bottom: 8px;
    border-bottom: 1px solid var(--mp-line);
}
.tl-stop-head .flag { font-size: 1.3rem; }
.tl-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tl-events li {
    display: grid;
    grid-template-columns: 100px auto 1fr auto auto;
    align-items: baseline; gap: 8px;
    padding: 4px 0;
    font-size: .93rem;
}
.tl-events .evt-tag { grid-column: 5; justify-self: end; }
.tl-events .evt-date { font-family: var(--font-mono); font-weight: 700; }
.tl-events .evt-sep { color: var(--mp-muted); }
.evt-actual    .evt-date { color: var(--mp-ok); }
.evt-estimated .evt-date { color: var(--mp-orange-dark); }
.evt-desc { color: var(--mp-black); }
.evt-vessel { color: var(--mp-black); }
.evt-tag {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    padding: 1px 6px; border-radius: 999px; letter-spacing: .05em;
    border: 1px solid transparent;
}
.evt-actual    .evt-tag { background: #eef8ef; color: var(--mp-ok);          border-color: #c7e7cf; }
.evt-estimated .evt-tag { background: var(--mp-orange-soft); color: var(--mp-orange-dark); border-color: var(--mp-orange); }

.subscription-line { margin: 10px 0 0; text-align: right; line-height: 1.35; }
.page-head-actions { text-align: right; display: inline-flex; align-items: center; gap: 0; }

/* --------------------------------------------------------------------------
   Route map (self-hosted basemap + SVG overlay)
   -------------------------------------------------------------------------- */
.route-map {
    position: relative;
    width: 100%;
    aspect-ratio: 1280 / 640;
    border: 1px solid var(--mp-line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: #0d1218;
    margin-bottom: 24px;
}
.route-map-img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    display: block; user-select: none; pointer-events: none;
    filter: brightness(1.35) saturate(0.9);
}
.route-map-svg {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
}
.rm-route-done { stroke: #ff7a1a; stroke-width: 2.6; fill: none; }
.rm-route-pend { stroke: #ff7a1a; stroke-width: 2.2; fill: none; stroke-dasharray: 6 4; stroke-linecap: round; }
.rm-port       { fill: #ff7a1a; stroke: #fff; stroke-width: 1.5; }
.rm-port-lbl   { fill: #fff; font: 600 12px system-ui, sans-serif; paint-order: stroke; stroke: #000; stroke-width: 3px; stroke-linejoin: round; }
.rm-vessel     { fill: #ffd400; stroke: #000; stroke-width: 1.5; }
.rm-vessel-lbl { fill: #ffd400; font: 600 11px system-ui, sans-serif; paint-order: stroke; stroke: #000; stroke-width: 3px; }
.rm-pulse      { animation: rm-pulse 2s ease-out infinite; }
@keyframes rm-pulse { 0% { r: 10; opacity: .9; } 70% { r: 28; opacity: 0; } 100% { r: 28; opacity: 0; } }

/* --------------------------------------------------------------------------
   Attachments
   -------------------------------------------------------------------------- */
.attachments {
    margin-top: 8px;
}
.attachments h2.section-title { margin-top: 24px; }
.attachments-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
}
.attachments-head h2.section-title { margin-top: 0; }
.att-list {
    list-style: none; padding: 0; margin: 0 0 12px;
    display: grid; gap: 8px;
}
.att-list li {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--mp-line);
    border-left: 4px solid var(--mp-orange);
    border-radius: var(--radius);
}
.att-kind {
    font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    font-size: .8rem; color: var(--mp-orange-dark);
    min-width: 110px;
}
.att-name { font-weight: 600; color: var(--mp-black); word-break: break-all; }
.att-meta { color: var(--mp-muted); font-size: .85rem; margin-left: auto; }
.att-actions { display: flex; gap: 8px; }
.att-empty { color: var(--mp-muted); font-style: italic; }

.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 8px;
}
.upload-card {
    background: var(--mp-bg-soft);
    border: 1px dashed var(--mp-line-strong);
    border-radius: var(--radius);
    padding: 14px;
}
.upload-card h3 { margin: 0 0 8px; font-size: 1rem; }
.upload-card form { display: flex; flex-direction: column; gap: 8px; }
.upload-card input[type=file] { font-size: .9rem; }

/* Dashed orange separator between upload-list groups
   (main docs boven, supplier docs eronder). */
.upload-list-sep {
    border: 0;
    border-top: 3px dashed var(--mp-orange);
    margin: 14px 0;
    height: 0;
}

/* Compact upload rows: one row per kind, 2 columns.
   Columns inside each row: [label] [filename] [DELETE][ATTACH]
   Filename turns green when a file is attached. No separate doc list above. */
.upload-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 14px;
    margin-top: 8px;
}
.upload-row {
    display: grid;
    grid-template-columns: 128px 1fr auto;
    align-items: center;
    gap: 8px;
    background: var(--mp-bg-soft);
    border: 1px dashed var(--mp-line-strong);
    border-radius: var(--radius);
    padding: 6px 10px;
    min-height: 38px;
}
.upload-row-label {
    font-weight: 600;
    color: var(--mp-black);
    font-size: .9rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-row-file-name {
    min-width: 0; /* allow the truncation inside grid */
    font-size: .85rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-row-file-name .att-name-link {
    color: var(--mp-ok);
    font-weight: 600;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: 100%;
    vertical-align: bottom;
}
.upload-row-file-name .att-name-link:hover { text-decoration: underline; }

.upload-row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.upload-row-actions form { margin: 0; }

/* Wrapper form must be a positioning context, otherwise the absolutely
 * positioned hidden input escapes upward and gets laid out against the
 * body, causing horizontal page overflow and a visual left shift. */
form.upload-row-up { position: relative; }

/* Hidden native file input — triggered by the <label> styled as a button. */
.upload-row-file {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    max-width: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.upload-row-btn {
    cursor: pointer;
    white-space: nowrap;
    margin: 0;
}

/* Force DELETE and ATTACH to identical width so they line up pixel-exact. */
.upload-row-actions .btn.btn-sm {
    width: 68px;
    text-align: center;
    padding-left: 0;
    padding-right: 0;
}

/* Black-and-white DELETE button. */
.btn-dark {
    background: var(--mp-black);
    color: #fff;
    border: 1px solid var(--mp-black);
}
.btn-dark:hover { background: #000; }

@media (max-width: 720px) {
    .upload-list { grid-template-columns: 1fr; }
    .upload-row { grid-template-columns: 110px 1fr auto; }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .header-inner { padding: 8px 12px; }
    /* brand-title kept visible on mobile (centered) — see <=900px block */
    .site-main { padding: 16px 12px 32px; }
    .tl-events li { grid-template-columns: 90px auto 1fr; }
    .tl-events .evt-vessel { grid-column: 1 / -1; padding-left: 98px; }
    /* Pill-tag: full-row but shrink to text width (was stretching full-width). */
    .tl-events .evt-tag {
        grid-column: 1 / -1;
        justify-self: start;
        margin-left: 98px;
        display: inline-block;
        width: auto;
    }
    .ct-summary-number { font-size: 1.25rem; }

    /* On mobile, the action block wraps below the title — stretch it full-width
       so the Add Container button (and the subscription line) right-align. */
    .page-head-flex .page-head-actions {
        width: 100%;
        text-align: right;
    }
    .page-head-flex .page-head-actions .btn { display: inline-block; }
}

/* --------------------------------------------------------------------------
   v11 additions: Add Container button, REMOVE button, badges, transit-day gap
   -------------------------------------------------------------------------- */
.page-head-flex {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.page-head-flex h1 { margin: 0; }
.page-head-flex .page-head-actions { margin-top: 2px; }

/* Card wrapper so the REMOVE button sits outside the clickable card link. */
.ct-card-wrap { position: relative; display: flex; flex-direction: column; }
.ct-card-wrap .ct-card { flex: 1; }

.ct-card-remove {
    position: absolute; top: 8px; right: 8px;
    margin: 0; z-index: 2;
}
.btn-remove {
    background: #fff; color: var(--mp-err, #b23a3a);
    border-color: #e0b9b9;
}
.btn-remove:hover {
    background: #fff4f4; color: #8a1f1f; border-color: #b23a3a;
}

/* Archive page — Restore / Delete actions under each card. */
.ct-card-archive-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 8px 0 0 0;
}
.ct-card-archive-actions form { margin: 0; }
.ct-card-wrap-archived .ct-card { opacity: .85; }
.ct-card-wrap-archived .ct-card:hover { opacity: 1; }

/* Language toggle — shared between Email settings page and the Notify popup. */
.email-tpl-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 10px;
}
.email-tpl-langs,
.ct-notify-langs {
    display: inline-flex; border: 1px solid #d6d6d6; border-radius: 6px;
    overflow: hidden; background: #f7f7f7;
}
.email-tpl-lang,
.ct-notify-lang {
    appearance: none; border: 0; background: transparent;
    padding: 6px 12px; font: inherit; color: #333; cursor: pointer;
    border-right: 1px solid #d6d6d6;
}
.email-tpl-langs .email-tpl-lang:last-child,
.ct-notify-langs .ct-notify-lang:last-child { border-right: 0; }
.email-tpl-lang.is-active,
.ct-notify-lang.is-active {
    background: #1f5ea8; color: #fff;
}
.email-tpl-lang:focus-visible,
.ct-notify-lang:focus-visible { outline: 2px solid #1f5ea8; outline-offset: 2px; }
.ct-notify-lang-row {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
}

/* Completion / arrival badges on the list card. */
.ct-card-badge {
    display: inline-block; margin-top: 6px;
    font-size: .7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em;
    padding: 2px 8px; border-radius: 999px;
    border: 1px solid transparent;
}
.ct-card-badge-arrived {
    background: #eef8ef; color: var(--mp-ok, #2d7a3a); border-color: #c7e7cf;
}
.ct-card-badge-delivered {
    background: #eef8ef; color: var(--mp-ok, #2d7a3a); border-color: #c7e7cf;
}
.ct-card-badge-completed {
    background: #eceff3; color: #505a6b; border-color: #c9d0da;
}
.ct-card-badge-eta {
    background: #eef4fb; color: #2656a1; border-color: #c6d6ec;
}
.ct-card-wrap-completed .ct-card { opacity: .92; }
.ct-card-wrap-completed .ct-card-route { border-top-style: dashed; }

/* Parcel status badges (17TRACK). Same visual family as container badges. */
.ct-parcel-status-delivered {
    background: #eef8ef; color: var(--mp-ok, #2d7a3a); border-color: #c7e7cf;
}
.ct-parcel-status-transit {
    background: #eef4fb; color: #2656a1; border-color: #c6d6ec;
}
.ct-parcel-status-pickup {
    background: #fff7e6; color: #9a6100; border-color: #f1d08a;
}
.ct-parcel-status-warn {
    background: #fee2e2; color: #991b1b; border-color: #fca5a5;
}
.ct-parcel-status-pending {
    background: #eceff3; color: #505a6b; border-color: #c9d0da;
}
.ct-card-transit { margin-top: 6px; }

/* Empty-returned banner on the detail page. */
.alert-completed {
    background: #eef2f7; border-color: #c9d4e2; color: #2d3a4d;
}

/* Transit-day gap marker between consecutive timeline stops. */
.tl-gap {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    margin: -4px 0; padding: 4px 0;
}
.tl-gap-arrow {
    color: var(--mp-muted, #7a7a7a); font-size: 1.2rem; line-height: 1;
    font-weight: 700;
}
.tl-gap-days {
    color: var(--mp-black); font-weight: 700; font-size: .8rem;
    letter-spacing: .04em;
    background: #fff; border: 1px solid var(--mp-line-strong);
    border-radius: 999px; padding: 1px 10px;
}

/* Add container form. */
.add-wrap { max-width: 560px; }
.add-wrap.bl-wide { max-width: 1400px; }
.add-form label { display: block; margin: 14px 0 4px; font-weight: 600; }
.add-form .form-label { display: block; margin-bottom: 4px; }
.add-form .form-hint {
    display: block; margin-top: 4px;
    color: var(--mp-muted); font-size: .82rem; font-weight: 400;
}
.add-form .form-hint code {
    background: var(--mp-bg-soft); padding: 1px 5px; border-radius: 4px;
    font-size: .78rem;
}
.add-form .form-actions {
    display: flex; gap: 10px; margin-top: 20px;
}

/* ------------------------------------------------------------------ */
/* Users management page                                              */
/* ------------------------------------------------------------------ */
.users-add-card {
    background: var(--mp-bg-soft, #f7f7f7);
    border: 1px solid var(--mp-line);
    border-radius: 8px;
    padding: 16px 18px;
    margin: 14px 0 24px;
}
.users-add-card h2 { margin: 0 0 10px; font-size: 1.1rem; }
.users-grid {
    display: grid;
    /* 12-col track so Role and Note filter can be half-width (1 col each)
       while every other field spans 2 cols. All fields fit on one row. */
    grid-template-columns: repeat(12, 1fr);
    gap: 12px 14px;
    align-items: stretch;
}
/* Default: every field spans 2 cols. */
.users-grid > label { grid-column: span 2; }
/* Narrow fields (Role, Note filter) — half width of a normal field. */
.users-grid > label.users-col-narrow { grid-column: span 1; }
/* Extra breathing room on the left of Notify TO / CC / Password fields. */
.users-grid > label.users-gap-left { margin-left: 10px; }
/* On narrower viewports, fall back to a flexible auto-fit grid so
   labels don't get squished into unreadable widths. */
@media (max-width: 1100px) {
    .users-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
    .users-grid > label,
    .users-grid > label.users-col-narrow { grid-column: auto; }
}
/* Each label is its own 3-row grid: title / input / hint. When every label
   shares the same template, the inputs in a row always sit on the same
   baseline even if only some columns have a hint. */
.users-grid label {
    display: grid;
    grid-template-rows: auto 1fr auto;
    row-gap: 4px;
}
.users-grid .form-label { font-size: .85rem; font-weight: 600; color: var(--mp-black); }
.users-grid input, .users-grid select {
    padding: 6px 8px;
    border: 1px solid var(--mp-line);
    border-radius: 4px;
    font: inherit;
}
.users-grid .form-hint { font-size: .75rem; color: var(--mp-muted); }
.users-grid-action { align-self: end; }
.users-grid-full {
    grid-column: 1 / -1;
    display: flex; flex-direction: column; gap: 6px;
}
.users-checklist {
    display: flex; flex-wrap: wrap; gap: 8px 14px;
    padding: 6px 10px;
    border: 1px solid var(--mp-line);
    border-radius: 6px;
    background: var(--mp-bg-soft, #fafafa);
}
.users-check {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .9rem; color: var(--mp-black);
    cursor: pointer;
}
.users-check input { accent-color: var(--mp-orange, #e6642e); }

/* Page head row with action button on the right */
.page-head-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.page-head-row h1 { margin: 0 0 4px; }
.page-head-row .page-head-actions { flex: 0 0 auto; }

/* Attachment checklist that spans full width below the user fields grid */
.users-attach-block {
    display: flex; flex-direction: column; gap: 6px;
    margin-top: 14px;
}
.users-actions-row {
    margin-top: 14px; text-align: right;
}

.users-edit-card {
    background: var(--mp-white, #fff);
    border: 1px solid var(--mp-line);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0;
    box-shadow: var(--shadow-sm, none);
}
.users-edit-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; gap: 10px; flex-wrap: wrap;
}
.users-edit-title { font-size: 1rem; display: inline-flex; align-items: center; gap: 8px; }
.users-edit-title code {
    background: var(--mp-bg-soft, #f0f0f0);
    padding: 2px 6px; border-radius: 4px; font-size: .92rem;
    font-weight: 700;
}
.users-edit-actions { display: inline-flex; gap: 8px; }

.users-list-title { margin: 10px 0 8px; font-size: 1.1rem; }
.users-table-wrap { overflow-x: auto; }
.users-table {
    width: 100%; border-collapse: collapse; font-size: .92rem;
    background: var(--mp-white, #fff);
    border: 1px solid var(--mp-line);
    border-radius: 6px;
    overflow: hidden;
}
.users-table th, .users-table td {
    padding: 8px 10px; border-bottom: 1px solid var(--mp-line);
    vertical-align: middle; text-align: left;
}
.users-table thead th {
    background: var(--mp-bg-soft, #f7f7f7);
    font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
}
.users-table tbody tr:last-child td { border-bottom: 0; }
.users-table input[type="text"], .users-table select {
    width: 100%; padding: 5px 7px;
    border: 1px solid var(--mp-line); border-radius: 4px;
    font: inherit;
}
.users-username code {
    background: var(--mp-bg-soft, #f0f0f0);
    padding: 2px 6px; border-radius: 4px; font-size: .88rem;
}
.users-username .badge { margin-left: 6px; }
.users-col-actions { white-space: nowrap; text-align: right; }
.users-col-actions .btn { margin-left: 4px; }
.btn-danger {
    color: #b00020;
    border-color: #e0bcc2 !important;
}
.btn-danger:hover { background: #fff4f5; }

/* --------------------------------------------------------------------------
   Route-map markers (numbered pins + vessel arrow)
   -------------------------------------------------------------------------- */
.rm-pin-wrap, .rm-ship-wrap { background: transparent; border: 0; }
.rm-pin {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: .82rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
    border: 2px solid #fff;
}
.rm-ship {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    transform-origin: 50% 50%;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}
/* Leaflet attribution legibility */
.leaflet-container a { color: var(--mp-orange); }

/* Transit duration chip under the big arrow on the detail page */
.ct-arrow-col .ct-transit {
    margin-top: -2px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--mp-muted, #7a7a7a);
    letter-spacing: .02em;
}

/* --------------------------------------------------------------------------
   Notification feature (SEND NOTIFICATION button, modal, green check)
   -------------------------------------------------------------------------- */

/* Attachments head: button group on right */
.attachments-head-actions {
    display: inline-flex; gap: 8px; align-items: center;
}

/* Flash message shown inline next to "Documents" title instead of above the page */
.attachments-head-flash {
    flex: 1 1 auto;
    margin: 0;
    padding: 6px 12px;
    font-size: .9rem;
    line-height: 1.3;
}

/* SEND NOTIFICATION button — flex-centered so text sits optically in the
   middle. Padding + line-height match .btn-sm (.btn) so its overall height
   lines up exactly with the DOWNLOAD ALL button next to it. */
.ct-notify-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* SEND NOTIFICATION button states */
.ct-notify-btn-blue {
    background: #1f6feb; color: #fff; border: 1px solid #1f6feb;
}
.ct-notify-btn-blue:hover { background: #1a5fd1; border-color: #1a5fd1; }
.ct-notify-btn-green {
    background: #2ea44f; color: #fff; border: 1px solid #2ea44f;
    cursor: default; opacity: .9;
}
.ct-notify-btn-green[disabled] { pointer-events: none; }

/* SENT ! pill shown left of DELETE; matches DELETE button height & font */
.upload-row-sent-tag {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #2ea44f;
    border: 1px solid #2ea44f;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: .82rem;
    line-height: 1.2;
    letter-spacing: 0.03em;
    padding: 4px 10px;
    white-space: nowrap;
    cursor: help;
    vertical-align: middle;
}

/* Modal */
.ct-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px;
}
.ct-modal[hidden] { display: none; }
.ct-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.5);
}
.ct-modal-panel {
    position: relative;
    background: #fff; border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    width: 100%; max-width: 720px; max-height: calc(100vh - 80px);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.ct-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--mp-line);
}
.ct-modal-head h3 { margin: 0; font-size: 1.05rem; }
.ct-modal-close {
    background: none; border: none; font-size: 1.4rem; line-height: 1;
    cursor: pointer; color: var(--mp-muted); padding: 0 4px;
}
.ct-modal-body {
    padding: 18px; overflow: auto;
}
.ct-modal-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 18px; border-top: 1px solid var(--mp-line);
    background: #fafafa;
}

.ct-notify-row { margin-bottom: 14px; }
.ct-notify-row input[type="text"],
.ct-notify-row textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--mp-line); border-radius: var(--radius-sm);
    font: inherit;
}

.ct-notify-recipients { display: flex; flex-direction: column; gap: 10px; }
.ct-notify-alwayscc {
    border: 1px solid var(--mp-line); border-radius: var(--radius-sm);
    padding: 8px 12px; background: #f3f6fb;
    font-size: .9rem;
}
.ct-notify-rec {
    border: 1px solid var(--mp-line); border-radius: var(--radius-sm);
    padding: 10px 12px; background: #fafafa;
}
.ct-notify-rec-head { margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.ct-notify-atts {
    margin: 6px 0 0 18px; padding: 0;
    font-size: .9rem;
}
.ct-notify-atts li { margin: 2px 0; }
.ct-notify-warn {
    display: inline-block; margin-top: 4px;
    color: #b35000; font-size: .85rem; font-weight: 600;
}
.ct-notify-user-toggle { cursor: pointer; margin-right: 4px; }
.ct-notify-rec-off { opacity: .45; }
.ct-notify-rec-off .ct-notify-atts input[type="checkbox"] { pointer-events: none; }

/* Email settings 2-column grid */
.email-settings-grid {
    display: grid; gap: 16px;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
}
.email-settings-grid .users-add-card {
    max-width: none;
    /* Stretch both columns to the same height so the Notification
       template card matches the Mail provider card on the left. */
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}
.email-col-title {
    margin: 0 0 12px 0; font-size: 1rem;
    color: var(--mp-black);
}
@media (max-width: 900px) {
    .email-settings-grid { grid-template-columns: 1fr; }
}

/* Chip (used in notify modal for role) */
.chip {
    display: inline-block; padding: 1px 8px;
    background: var(--mp-black); color: #fff;
    border-radius: 999px;
    font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
}

/* Email settings host / port / encryption row */
.email-host-row {
    display: flex; gap: 8px; margin-bottom: 10px;
}
.email-host-row label { display: block; }
.email-host-row input, .email-host-row select {
    width: 100%; padding: 6px 8px;
    border: 1px solid var(--mp-line); border-radius: var(--radius-sm);
    font: inherit; background: #fff;
}

/* ---------- B/L upload on ADD CONTAINER page ---------- */
.bl-tabs {
    display: flex; gap: 2px; margin: 20px 0 0 0;
    border-bottom: 1px solid var(--mp-line);
}
.bl-tab {
    background: none; border: none;
    padding: 10px 16px; font: inherit;
    color: var(--mp-muted); cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.bl-tab.is-active {
    color: var(--mp-black); border-bottom-color: var(--mp-black);
    font-weight: 600;
}
.bl-panel { padding-top: 20px; }

.bl-dropzone {
    border: 2px dashed var(--mp-line); border-radius: var(--radius);
    padding: 32px; text-align: center; background: #fafafa;
    transition: background .15s, border-color .15s;
    cursor: pointer;
}
.bl-dropzone.is-dragover { background: #f1f5f9; border-color: var(--mp-black); }
.bl-dz-title { margin: 0 0 4px 0; font-weight: 600; }
.bl-file-name { margin-top: 10px; }

.bl-status {
    margin: 14px 0; padding: 10px 14px;
    border-radius: var(--radius-sm); font-size: .92rem;
}
.bl-status-info { background: #eef6ff; color: #0a4c85; }
.bl-status-err  { background: #fdecea; color: #8a1c14; }
.bl-status-ok   { background: #e8f6ea; color: #17532a; }

/* Add Movement — origin/destination row */
.mv-od-block { margin: 16px 0 8px 0; }
.mv-od-row {
    display: flex; align-items: flex-end; gap: 16px;
    margin: 0 0 4px 0; flex-wrap: wrap;
}
.mv-od-field {
    display: flex; flex-direction: column; gap: 6px;
    min-width: 240px; flex: 1 1 240px;
}
.mv-od-label {
    font-size: .8rem; color: var(--mp-muted); font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase;
}
.mv-od-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--mp-line-strong);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    background: #fff;
    color: var(--mp-black);
    min-height: 46px;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23555' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}
.mv-od-input:focus {
    outline: none; border-color: var(--mp-orange);
    box-shadow: 0 0 0 3px rgba(224,97,13,.15);
}
.mv-od-arrow {
    font-size: 2rem; color: var(--mp-orange); font-weight: 700;
    padding-bottom: 6px; user-select: none;
    line-height: 1;
}
.mv-od-hint { margin: 8px 0 12px 0; }
.mv-od-hint-err { color: #8a1c14; }
@media (max-width: 640px) {
    .mv-od-arrow { display: none; }
}

/* Add Movement — desktop wide layout.
   The page section itself is normally constrained to 560px (.add-wrap).
   On desktop we lift that cap so children can fill the standard 1100px
   site-main column. Page-head, tabs, dropzone, FROM/TO and the manual
   table stay at 560px (left-aligned). Sheet/column selectors and the
   preview table expand to 100% so all spreadsheet columns and many
   movement lines can be reviewed without horizontal scrolling. */
@media (min-width: 1200px) {
    .mv-page.add-wrap { max-width: none; }
    .mv-page .page-head,
    .mv-page .alert,
    .mv-page .bl-tabs,
    .mv-page .bl-dropzone,
    .mv-page #mv-status,
    .mv-page .mv-od-block {
        max-width: 560px;
    }
    .mv-page .bl-panel[data-panel="manual"] > div {
        max-width: 560px;
    }
    .mv-page .mv-selectors,
    .mv-page .bl-preview {
        max-width: none;
        width: 100%;
    }
    .mv-page .bl-preview .bl-containers { width: 100%; }
}

/* Add Movement — row validation states.
   Rows are tagged after the /warehouse/movement/validate response so the
   user immediately sees which lines need their attention before clicking
   CONTINUE. mv-row-missing = SKU absent from DB (red), mv-row-insufficient
   = stock < requested (yellow), mv-row-duplicate = SKU appears more than
   once in the input table (red underline on the SKU input itself). */
.mv-table tbody tr.mv-row-ok td             { background: #e8f6ea; }
.mv-table tbody tr.mv-row-missing td        { background: #fdecea; }
.mv-table tbody tr.mv-row-insufficient td   { background: #fff8e0; }
.mv-table tbody tr.mv-row-ok .mv-row-stat,
.mv-table tbody tr.mv-row-ok .mv-m-stat     { color: #17532a; font-weight: 600; }
.mv-table tbody tr.mv-row-missing      .mv-row-stat,
.mv-table tbody tr.mv-row-missing      .mv-m-stat { color: #8a1c14; font-weight: 600; }
.mv-table tbody tr.mv-row-insufficient .mv-row-stat,
.mv-table tbody tr.mv-row-insufficient .mv-m-stat { color: #8a5a00; font-weight: 600; }
.mv-table tbody td.mv-row-stat,
.mv-table tbody td.mv-m-stat { font-size: .85rem; letter-spacing: .03em; text-transform: uppercase; padding-left: 28px; }
.mv-table thead th.mv-th-stat { padding-left: 28px; }
/* Right-align Quantity & Available so the last digit lines up with the
   last character of the header text. Both header and cell are aligned
   right; the Quantity input itself also gets right-aligned text. The
   shared padding-right shifts both columns ~2cm to the left. */
.mv-table thead th.mv-th-qty,
.mv-table thead th.mv-th-avail { text-align: right; padding-right: 76px; }
.mv-table tbody td.mv-row-qty,
.mv-table tbody td.mv-m-qty,
.mv-table tbody td.mv-row-avail,
.mv-table tbody td.mv-m-avail  { text-align: right; font-variant-numeric: tabular-nums; padding-right: 76px; }
.mv-table tbody input.mv-row-qty,
.mv-table tbody input.mv-m-qty { text-align: right; font-variant-numeric: tabular-nums; }
.mv-sku-dup {
    text-decoration: underline;
    text-decoration-color: #c0392b;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}
.mv-legend {
    display: flex; flex-wrap: wrap; gap: 12px;
    font-size: .8rem; margin: 6px 0 10px 0;
}
.mv-legend-item {
    padding: 3px 10px; border-radius: 999px;
    border: 1px solid var(--mp-line-strong);
}
.mv-legend-item.mv-legend-ok           { background: #e8f6ea; border-color: #a6d4ad; color: #17532a; }
.mv-legend-item.mv-legend-missing      { background: #fdecea; border-color: #f5c6c0; color: #8a1c14; }
.mv-legend-item.mv-legend-insufficient { background: #fff8e0; border-color: #f0d98a; color: #8a5a00; }
.mv-legend-item.mv-legend-duplicate    {
    text-decoration: underline; text-decoration-color: #c0392b;
    text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.mv-manual-wrap {
    display: flex; flex-direction: column; gap: 16px;
}
@media (min-width: 1200px) {
    .mv-manual-wrap { max-width: 1100px; }
}

/* Add Movement — sheet/column selectors */
.mv-selectors {
    margin: 16px 0; padding: 14px;
    background: var(--mp-bg-soft);
    border: 1px solid var(--mp-line); border-radius: var(--radius);
}
.mv-sel-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.mv-sel { display: flex; flex-direction: column; gap: 4px; }
.mv-sel-label {
    font-size: .78rem; color: var(--mp-muted); font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase;
}
.mv-rawpreview { margin-top: 12px; }
.mv-rawpreview summary {
    cursor: pointer; color: var(--mp-muted);
    font-size: .88rem; padding: 4px 0;
}
.mv-raw-wrap {
    margin-top: 8px; max-height: 280px; overflow: auto;
    border: 1px solid var(--mp-line); border-radius: var(--radius-sm);
    background: #fff;
}
.mv-raw-table {
    border-collapse: collapse; width: max-content; min-width: 100%;
    font-size: .82rem;
}
.mv-raw-table th, .mv-raw-table td {
    border-bottom: 1px solid var(--mp-line);
    border-right: 1px solid var(--mp-line);
    padding: 4px 8px; white-space: nowrap;
    vertical-align: top;
}
.mv-raw-table th {
    background: var(--mp-bg-soft); position: sticky; top: 0;
    text-align: left; font-weight: 600;
}
.mv-raw-table tbody tr:nth-child(odd) td { background: #fafafa; }

.bl-preview h2 {
    margin: 24px 0 8px 0; font-size: 1rem;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--mp-muted); font-weight: 600;
}
.bl-shipment { width: 100%; border-collapse: collapse; }
.bl-shipment th {
    text-align: left; padding: 6px 12px 6px 0;
    width: 160px; color: var(--mp-muted);
    font-weight: 500; vertical-align: middle;
}
.bl-shipment td { padding: 4px 0; }
.bl-ship-input {
    width: 100%; padding: 6px 8px;
    border: 1px solid var(--mp-line); border-radius: var(--radius-sm);
    font: inherit; background: #fff;
}

.bl-containers {
    width: 100%; border-collapse: collapse;
    font-size: .92rem;
}
.bl-containers th {
    text-align: left; padding: 8px 6px;
    border-bottom: 2px solid var(--mp-line);
    font-weight: 600; color: var(--mp-black);
    background: #fafafa;
}
.bl-containers td {
    padding: 6px; border-bottom: 1px solid var(--mp-line);
    vertical-align: middle;
}
.bl-containers input[type="text"],
.bl-containers input[type="number"] {
    width: 100%; padding: 4px 6px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    font: inherit; background: transparent;
}
.bl-containers input:focus {
    border-color: var(--mp-line); background: #fff; outline: none;
}
.bl-containers tr.is-dup { background: #fff5e6; }
.bl-containers tr.is-dup input { color: var(--mp-muted); }
.bl-dup-tag {
    display: inline-block; margin-left: 8px;
    padding: 1px 6px; border-radius: 999px;
    background: #f3b55c; color: #5a3a00;
    font-size: .7rem; text-transform: uppercase;
    letter-spacing: .04em;
}
.bl-cell-check { width: 36px; }
.bl-cell-container { min-width: 140px; }
.bl-cell-seal_number { min-width: 200px; }
.bl-cell-equipment_type { min-width: 90px; }
.bl-cell-packages { min-width: 110px; }
.bl-cell-gross_weight_kg { min-width: 130px; }
.bl-cell-volume_cbm { min-width: 100px; }
.bl-cell-note { min-width: 320px; }
.bl-note-input { min-width: 320px; }
.bl-containers { table-layout: auto; }
.bl-containers tr.is-revive { background: #eefbe8; }
.bl-revive-tag {
    background: #7cc27a !important; color: #1d4d1a !important;
}

/* ---------- Settings page: top-level tab nav ---------- */
.settings-tabs {
    display: flex; gap: 2px; margin: 16px 0 24px 0;
    border-bottom: 1px solid var(--mp-line);
}
.settings-tab {
    text-decoration: none;
    padding: 10px 16px; font: inherit;
    color: var(--mp-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
}
.settings-tab:hover { color: var(--mp-black); }
.settings-tab.is-active {
    color: var(--mp-black); border-bottom-color: var(--mp-black);
    font-weight: 600;
}

/* ======================================================================
   ISF Filings
   ====================================================================== */

/* Status chips */
.isf-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
    margin-left: 6px;
}
.isf-status.isf-st-ok    { background: #e8f5e9; color: #1b5e20; }
.isf-status.isf-st-draft { background: #fff3cd; color: #856404; }

/* Index table */
.isf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.isf-table th,
.isf-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e7e7e7;
    text-align: left;
    vertical-align: middle;
}
.isf-table th { background: #fafafa; font-weight: 600; }
.isf-table td.n, .isf-table th.n { text-align: right; font-variant-numeric: tabular-nums; }
.isf-table td.c, .isf-table th.c { text-align: center; font-variant-numeric: tabular-nums; }

.isf-container-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}
.isf-container-table th,
.isf-container-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

/* ISF block on ADD CONTAINER and ISF EDIT pages */
.isf-block {
    margin-top: 20px;
    padding: 16px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}
.isf-block h2 { margin: 0 0 4px; font-size: 18px; }

.isf-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    margin-top: 12px;
}
.isf-field { display: flex; flex-direction: column; gap: 4px; }
.isf-field-full { grid-column: 1 / -1; }
.isf-field .form-label { font-size: 12px; color: #555; font-weight: 500; }

.isf-input,
.isf-textarea {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid #c8c8c8;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
}
.isf-textarea { min-height: 82px; resize: vertical; }
.isf-input:focus,
.isf-textarea:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.15);
}
.isf-input.is-missing,
.isf-textarea.is-missing {
    border-color: #e57373;
    background: #fff8f7;
}

.isf-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* ISF summary card on the container detail page */
.isf-linked-card {
    background: #fdf7e3;
    border: 1px solid #f0d866;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 12px 0 18px;
}
.isf-linked-head { display: flex; align-items: center; gap: 10px; }
.isf-linked-body { margin: 6px 0; font-size: 13px; color: #555; }
.isf-linked-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Small button variant reuse */
.btn.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Narrow screens: stack the ISF grid */
@media (max-width: 760px) {
    .isf-grid { grid-template-columns: 1fr; }
    .isf-field-full { grid-column: 1; }
}

/* Delivery status card on the container detail page.
   Shown when container is ARRIVED (button: MARK DELIVERED) or
   DELIVERED (button: ARCHIVE CONTAINER). Uses the same green as the
   ARRIVED badge. */
.ct-delivery-card {
    background: #eef8ef;
    border: 1px solid #c7e7cf;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 12px 0 18px;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.ct-delivery-body { flex: 1 1 320px; font-size: 13px; color: #2d7a3a; }
.ct-delivery-body strong { color: #1f5a29; display: block; margin-bottom: 2px; }
.ct-delivery-actions { flex: 0 0 auto; }
.ct-delivery-actions form { margin: 0; }
.btn.ct-btn-delivery {
    background: #2d7a3a;
    color: #fff;
    border: 1px solid #1f5a29;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.btn.ct-btn-delivery:hover {
    background: #256530;
    border-color: #18421f;
    color: #fff;
}

/* ------------------------------------------------------------------
   Module tab bar (Container Tracking / Parcel Tracking / Warehouse)
   Rendered INLINE at H1 size in the page-head. Active tab is black,
   inactive tabs are grey with a hover -> black transition.
   ------------------------------------------------------------------ */
h1.module-tabs {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--mp-black);
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0;
}
/* Ensure the ADD button stays visible on the same row as the tab bar
   by letting the left block (tabs) shrink and never pushing the action
   column onto a new line unnecessarily. */
.page-head-flex > div:first-child { min-width: 0; flex: 1 1 auto; }
.page-head-flex .page-head-actions { flex: 0 0 auto; white-space: nowrap; }
.module-tab {
    color: #9ca3af;
    text-decoration: none;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: normal;
    transition: color .12s ease;
    white-space: nowrap;
}
.module-tab:hover {
    color: #111827;
    text-decoration: none;
}
.module-tab.is-active {
    color: #111827;
    cursor: default;
}
.module-tab.is-active:hover { color: #111827; }
.module-tab-disabled {
    color: #d1d5db;
    cursor: not-allowed;
}
.module-tab-disabled:hover { color: #d1d5db; }
.module-tab-sep {
    color: #d1d5db;
    margin: 0 14px;
    font-weight: 400;
    user-select: none;
}

/* ------------------------------------------------------------------
   Parcel cards: "No tracking data" state
   Shown when 17TRACK accepted the number but the carrier has no data
   (NotFound / Exception / null status). Card is dimmed and tagged so
   the user sees at a glance why nothing is showing.
   ------------------------------------------------------------------ */
.ct-card-wrap.ct-card-nodata .ct-card { opacity: 0.55; filter: grayscale(40%); }
.ct-card-wrap.ct-card-nodata .ct-card:hover { opacity: 0.85; filter: grayscale(0); }
.ct-card-nodata-tag {
    position: absolute;
    top: 8px; right: 12px;
    z-index: 2;
    background: #fff3f3;
    color: #b42318;
    border: 1px solid #fda29b;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Lifecycle card variant for the no-data state on the detail page. */
.ct-delivery-card.ct-delivery-nodata {
    border-color: #fda29b;
    background: #fff7f6;
}
.ct-delivery-card.ct-delivery-nodata .ct-delivery-body strong {
    color: #b42318;
}

/* ------------------------------------------------------------------
   "Waiting for carrier data" state
   Shown during the 5–30 min window after a parcel is added and
   17TRACK is still contacting the carrier (api_status=pending).
   Amber/yellow to distinguish from the red NO TRACKING DATA state.
   ------------------------------------------------------------------ */
.ct-card-wrap.ct-card-waiting .ct-card { opacity: 0.85; }
.ct-card-wrap.ct-card-waiting .ct-card:hover { opacity: 1; }
.ct-card-waiting-tag {
    position: absolute;
    top: 8px; right: 12px;
    z-index: 2;
    background: #fff8e6;
    color: #93570b;
    border: 1px solid #f5c77a;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.ct-delivery-card.ct-delivery-waiting {
    border-color: #f5c77a;
    background: #fffaee;
}
.ct-delivery-card.ct-delivery-waiting .ct-delivery-body strong {
    color: #93570b;
}

/* ==================================================================
   Warehouse module (Fase 1) — dashboard cards + placeholder grid.
   ================================================================== */
.wh-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.card-grid:not(.view-list) .wh-card .wh-stats { flex: 1; }
.card-grid:not(.view-list) .wh-card { min-height: 158px; }
.wh-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px 0 0;
    margin-top: 10px;
    border-top: 1px solid var(--mp-line);
}
/* Placeholder external warehouses (China) show only 2 stats: SKUs + TOTAL.
   Keep the same 4-column grid as the regular tiles (so box size and
   tile height stay identical across the row) but place the 2 stats in
   the middle 2 columns. This centers them visually without breaking the
   .wh-stats { display:grid } base layout. */
.wh-stats-2col {
    /* inherit 4-col grid from .wh-stats */
}
.wh-stats-2col > .wh-stat:nth-child(1) { grid-column: 2; }
.wh-stats-2col > .wh-stat:nth-child(2) { grid-column: 3; }
.wh-stat {
    /* Grid layout: fixed num-row + fixed label-row so all stat blocks within
       a row align exactly — numbers on one baseline, labels on one baseline,
       regardless of whether the label is 1 or 2 lines. Total inner height
       matches the original ~62px footprint so .wh-card stays at 158px. */
    display: grid;
    grid-template-rows: 24px 24px;
    row-gap: 2px;
    align-items: end;
    justify-items: center;
    padding: 8px 4px;
    background: #f7f7f7;
    border-radius: 4px;
    /* Hard-cap: forces every stat block to the same outer height regardless
       of label line count. Overflow from .wh-stat-sub is hidden. */
    height: 66px;
    box-sizing: border-box;
    overflow: hidden;
}
.wh-stat-num {
    font-size: 22px;
    font-weight: 700;
    color: #111;
    line-height: 1;
    align-self: end;
}
.wh-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #666;
    letter-spacing: 0.4px;
    margin-top: 0;
    padding-top: 5px;
    white-space: nowrap;
    text-align: center;
    line-height: 1.05;
    align-self: start;
}
.wh-stat-label .wh-stat-sub {
    display: block;
    font-size: 9px;
    font-weight: 500;
    color: #888;
    letter-spacing: 0.3px;
    margin-top: 1px;
    line-height: 1;
}
.wh-card-foot {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px 12px;
    border-top: 1px solid #eee;
}

/* Per-hall page */
.wh-hall-title {
    margin: 8px 0 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #333;
}
.wh-stats-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}
.wh-stat-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    background: #f0f0f0;
    border-radius: 12px;
    color: #444;
    letter-spacing: 0.3px;
}

/* Placeholder grid table for Fase 1 — replaced by SVG floorplan later */
.wh-floorplan-wrap-grid { margin-top: 16px; overflow-x: auto; }
.wh-grid-table {
    border-collapse: collapse;
    font-size: 10px;
    font-family: monospace;
}
.wh-grid-table td {
    width: 28px; height: 22px;
    text-align: center;
    border: 1px solid #ddd;
    vertical-align: middle;
}
.wh-slot-free     { background: #ffffff; }
.wh-slot-occupied { background: #d1e8ff; color: #1a4b8c; font-weight: 600; }
.wh-slot-blocked  { background: #333; color: #fff; }
.wh-slot-num      { font-size: 9px; }
.wh-slot-mark     { font-weight: 700; }

/* -----  SVG floorplan (Fase 1)  ----- */
.wh-floorplan-wrap {
    position: relative;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-top: 16px;
}
.wh-floorplan {
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 0 0 auto;
    max-width: 100%;
    height: auto;
}
.wh-cell { cursor: default; }
.wh-cell-rect {
    stroke: #cbd5e1;
    stroke-width: 1;
    fill: #ffffff;
}
.wh-cell-free .wh-cell-rect { fill: #ffffff; }
.wh-cell-occupied {
    cursor: pointer;
}
.wh-cell-occupied .wh-cell-rect { fill: #dbeafe; stroke: #93c5fd; }
.wh-cell-blocked .wh-cell-rect { fill: #374151; stroke: #111827; }
.wh-cell-none .wh-cell-rect { fill: transparent; stroke: transparent; }
.wh-cell.is-hover .wh-cell-rect {
    fill: #fde68a;
    stroke: #f59e0b;
    stroke-width: 2;
}

/* Corner markers on a pallet cell.
   Note corner (top-right): orange = pallet has a note.
   Attach corner (top-left): dark blue = pallet has an attachment. */
.wh-note-corner {
    fill: #f97316;
    stroke: none;
    pointer-events: none;
}
.wh-attach-corner {
    fill: #1e40af;
    stroke: none;
    pointer-events: none;
}

/* Edit mode — cells become clickable, none-cells become visible/dashed */
.wh-editing .wh-cell-rect { cursor: pointer; }
.wh-editing .wh-cell-occupied .wh-cell-rect { cursor: not-allowed; }
.wh-editing .wh-cell-none .wh-cell-rect {
    fill: #f8fafc;
    stroke: #cbd5e1;
    stroke-dasharray: 3 3;
}
.wh-editing .wh-cell.is-hover .wh-cell-rect {
    fill: #fef3c7;
    stroke: #f59e0b;
    stroke-width: 2;
    stroke-dasharray: 0;
}
.wh-cell-pending .wh-cell-rect { opacity: 0.5; }
.wh-edit-toggle {
    background: #ffffff;
    color: var(--mp-black);
    border: 1px solid var(--mp-black);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 8px;
}
.wh-edit-toggle:hover { background: #f1f5f9; }
.wh-edit-toggle.is-active {
    background: var(--mp-orange);
    color: #ffffff;
    border-color: var(--mp-orange);
}
.wh-edit-toggle.is-active:hover {
    background: var(--mp-orange-dark);
    border-color: var(--mp-orange-dark);
}

/* Row containing the EDIT FLOORPLAN MODE / EDIT PALLET MODE buttons.
   Lives below the page-head so it's a separate visual row. Mobile rules
   in @media (max-width: 900px) further tighten the layout. */
.wh-edit-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 12px 0;
}
.wh-edit-buttons-row .wh-edit-toggle { margin-left: 0; }

/* EDIT-mode buttons inline next to HAL title (desktop only). */
.wh-edit-buttons-inline {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 8px;
}
.wh-edit-buttons-inline .wh-edit-toggle { margin-left: 0; }

/* Separate mobile row (HAL detail page): hidden on desktop, shown on mobile. */
.wh-edit-buttons-row-mobile { display: none; }

/* HAL hall page header: align stat chips + EDIT button with the HAL title.
   Make the actions row sticky so the pills + EDIT MODE stay pinned at the
   top of the viewport while the user scrolls the long floorplan. */
.wh-hall-head { align-items: center; position: relative; }
.wh-hall-head .wh-hall-title { margin: 0; }
.wh-hall-head .wh-hall-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.wh-hall-head .page-head-actions {
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    top: 160px;
    right: calc((100vw - 1100px) / 2 + 16px);
    z-index: 6;
    background: #ffffff;
    padding: 6px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
@media (max-width: 1200px) {
    .wh-hall-head .page-head-actions { right: 16px; }
}

/* Toggle slider — reused for Settings > Warehouse > Enable Edit Mode */
.wh-toggle { display:inline-flex; align-items:center; gap:10px; cursor:pointer; user-select:none; }
.wh-toggle input { position:absolute; opacity:0; width:0; height:0; pointer-events:none; }
.wh-toggle-track {
    position:relative; display:inline-block; width:44px; height:24px;
    background:#cbd5e1; border-radius:999px; transition:background .15s;
}
.wh-toggle-thumb {
    position:absolute; top:2px; left:2px; width:20px; height:20px;
    background:#ffffff; border-radius:50%; box-shadow:0 1px 3px rgba(0,0,0,0.2);
    transition:left .15s;
}
.wh-toggle input:checked + .wh-toggle-track { background: var(--mp-orange-dark); }
.wh-toggle input:checked + .wh-toggle-track .wh-toggle-thumb { left:22px; }
.wh-toggle-label { font-weight:600; }

/* Edit-mode click popup */
.wh-edit-popup {
    position: absolute;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    padding: 6px;
    z-index: 50;
    min-width: 160px;
    font-size: 13px;
}
.wh-edit-popup-title {
    font-size: 11px; font-weight: 700; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 4px 10px 6px; border-bottom: 1px solid #e5e7eb; margin-bottom: 4px;
}
.wh-edit-popup button {
    display: block; width: 100%; text-align: left;
    padding: 7px 10px; border: 0; background: transparent; cursor: pointer;
    border-radius: 4px; font-size: 13px; font-weight: 500;
}
.wh-edit-popup button:hover { background: #f1f5f9; }
.wh-edit-popup button.is-current { background: #f8fafc; color: #6b7280; cursor: default; }
.wh-edit-popup button.is-current:hover { background: #f8fafc; }
.wh-edit-popup .wh-edit-popup-cancel { color: #6b7280; border-top: 1px solid #e5e7eb; margin-top: 4px; padding-top: 7px; border-radius: 0; }
.wh-cell-num {
    font-size: 14px;
    font-family: 'SF Mono', 'Roboto Mono', Menlo, monospace;
    font-weight: 600;
    fill: #1e3a8a;
    pointer-events: none;
    user-select: none;
}

/* Floorplan column contains just the SVG so the flex row has two items */
.wh-floorplan-col { flex: 0 0 auto; }

/* Combined view: two halls side by side inside the same floorplan column.
   The container width is capped so HAL B never extends underneath the
   fixed info-box (420px + 16px gutter) at the top-right of the viewport.
   Horizontal scroll appears if the two halls don't fit. */
.wh-floorplan-combined {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: calc(100vw - 460px);
    overflow-x: auto;
}
@media (max-width: 900px) {
    .wh-floorplan-combined { max-width: 100%; overflow-x: auto; }
}
.wh-floorplan-block { display: flex; flex-direction: column; gap: 6px; }
.wh-floorplan-sublabel {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--mp-black);
    text-transform: uppercase;
}
.wh-cell-num-sm {
    font-size: 9px;
}

/* Info box stays pinned in the top-right corner of the viewport while the
   user scrolls the long floorplan. Positioned relative to the viewport so
   it's never clipped by the parent's height. */
/* Edit-mode legend pinned directly under the OCCUPIED/AVAILABLE/BLOCKED pills.
   The hover info-box sits below it, also fixed. Both stay in view while scrolling. */
.wh-edit-legend {
    position: fixed;
    top: 207px;
    right: calc((100vw - 1100px) / 2 + 16px);
    width: 420px;
    max-width: 420px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 6;
}
.wh-edit-legend[hidden] { display: none; }
.wh-edit-legend-head {
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #9a3412;
    border-bottom: 1px solid #fdba74;
    padding-bottom: 6px;
    margin-bottom: 6px;
    font-size: 14px;
}
.wh-edit-legend-body { color: #7c2d12; line-height: 1.5; }
.wh-edit-legend-body strong { color: #431407; }

.wh-info-box {
    position: fixed;
    top: 207px;          /* default: aligned with the top of the floorplan SVG */
    right: calc((100vw - 1100px) / 2 + 16px);
    width: 420px;
    max-width: 420px;
    max-height: calc(100vh - 223px - 64px); /* reserve room for fixed export bar */
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 14px 16px;
    font-size: 17px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 5;
}
/* When the edit legend is visible, push the info box down so they stack.
   The exact offset is set via the --wh-info-top CSS variable (computed in JS
   from the actual legend height), so floorplan mode (taller legend) and
   pallet mode (shorter legend) keep the same visual spacing under the box. */
.wh-editing-floorplan .wh-info-box,
.wh-editing-pallet    .wh-info-box,
.wh-editing           .wh-info-box {
    top: var(--wh-info-top, 380px);
    max-height: calc(100vh - var(--wh-info-top, 380px) - 16px - 64px);
}

/* Export bar — sits directly under the hover info-box, fixed in viewport.
   Mirrors the info-box width and right-edge alignment so it lines up. */
.wh-export-bar {
    position: fixed;
    right: calc((100vw - 1100px) / 2 + 16px);
    width: 420px;
    max-width: 420px;
    bottom: 16px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    z-index: 5;
}
.wh-export-bar .btn { margin: 0; }
@media (max-width: 1200px) {
    .wh-export-bar { right: 16px; }
}
/* When viewport is narrower than 1100 + margins, pin to the right edge */
@media (max-width: 1200px) {
    .wh-edit-legend { right: 16px; }
    .wh-info-box { right: 16px; }
}

/* Wide-layout pages (combined HAL A+B view): the page chrome shrinks to
   32px gutters, so the fixed info-box / export-bar / edit-legend should
   anchor relative to the wide chrome, not the 1100px wrapper. */
body.layout-wide .wh-info-box,
body.layout-wide .wh-export-bar,
body.layout-wide .wh-edit-legend {
    right: 48px; /* 32px page gutter + 16px breathing room */
}
@media (max-width: 1200px) {
    body.layout-wide .wh-info-box,
    body.layout-wide .wh-export-bar,
    body.layout-wide .wh-edit-legend { right: 16px; }
}

/* Combined view (wide layout): same constrained width as the single
   HAL detail view — capped so HAL B never extends underneath the fixed
   info-box (420px + gutter) at the top-right of the viewport. The
   floorplan keeps its natural intrinsic width; horizontal scroll appears
   if both halls don't fit. */
body.layout-wide .wh-floorplan-combined {
    max-width: calc(100vw - 460px);
}
.wh-info-empty { color: #9ca3af; font-style: normal; }
.wh-info-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 6px;
    margin-bottom: 8px;
}
.wh-info-number {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #111;
}
.wh-info-height { font-size: 15px; color: #666; font-weight: 600; }
.wh-info-origin { margin-bottom: 4px; }
.wh-info-note {
    background: #fff7ed;
    border-left: 3px solid #f59e0b;
    padding: 6px 8px;
    margin: 6px 0;
    font-size: 15px;
    color: #92400e;
}
.wh-info-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}
.wh-info-table th {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    letter-spacing: 0.2px;
    padding: 5px 4px;
    border-bottom: 1px solid #e5e7eb;
    text-transform: uppercase;
    white-space: nowrap;
}
.wh-info-table td {
    padding: 5px 4px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 15px;
    vertical-align: top;
}
.wh-info-table th:not(:first-child),
.wh-info-table td:not(:first-child) {
    width: 1%;
    white-space: nowrap;
}
.wh-info-table th:first-child,
.wh-info-table td:first-child {
    width: auto;
    padding-left: 0;
    padding-right: 6px;
}
.wh-info-sku { word-break: break-all; font-size: 13px; }
.wh-info-table tfoot td {
    border-top: 2px solid #d1d5db;
    border-bottom: none;
    padding-top: 6px;
}
.wh-info-sku {
    font-family: 'SF Mono', 'Roboto Mono', Menlo, monospace;
    color: #111;
}
.wh-info-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.wh-stat-occ { background: #dbeafe; color: #1e3a8a; }
.wh-stat-fre { background: #f3f4f6; color: #374151; }
.wh-stat-blk { background: #374151; color: #fff; }

/* -------------------------------------------------------------------------
   Mobile (<= 900px): brand title centered, floorplan full-width, info-box
   and edit-legend become bottom-fixed mini panels with close buttons.
   ------------------------------------------------------------------------- */
@media (max-width: 900px) {
    /* Header: not sticky on mobile so stats pills are not covered.
       Logo left at full size, title right and vertically centered, filling
       the remaining row width. */
    .site-header { position: static; }
    .header-inner { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 12px; }
    .brand, .brand-static {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        width: 100%;
    }
    .brand-logo { height: 80px; flex: 0 0 auto; }
    .brand-title {
        display: flex !important;
        flex: 1 1 auto;
        min-width: 0;
        min-height: 80px;
        align-items: center;
        justify-content: center;
        text-align: center;
        /* Fluid size: scales with viewport but capped so it never overflows.
           Reduced 20% from previous (clamp 1.1rem / 7.5vw / 2.4rem). */
        font-size: clamp(0.88rem, 6vw, 1.92rem);
        letter-spacing: .04em;
        line-height: 1.05;
        white-space: nowrap;
    }
    .site-nav { width: 100%; justify-content: center; flex-wrap: nowrap; gap: 10px; font-size: 13px; }
    .site-nav > * { white-space: nowrap; }
    .site-nav .role-pill { font-size: 11px; }
    .site-nav .btn-ghost { padding: 3px 9px; font-size: 12px; }
    /* Session label: hide "Logged in as", show "Login:" prefix.
       Role pill is kept (abbreviated via .role-short rule below). */
    .session-prefix-long { display: none; }
    .session-prefix-short { display: inline; }

    /* Page head: keep title and stats on the SAME row on mobile.
       Title left, abbreviated stat-pills right. */
    .page-head-flex {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: nowrap;
    }
    .page-head-flex .wh-hall-title-wrap { flex: 0 0 auto; }
    .page-head-flex .wh-hall-title { font-size: 1.4rem; }
    .page-head-flex .page-head-actions { width: auto; text-align: right; flex: 0 1 auto; }
    .wh-stats-inline { flex-wrap: nowrap; gap: 4px; justify-content: flex-end; }
    .wh-stat-chip { padding: 2px 8px; font-size: 11px; letter-spacing: .04em; }
    .wh-stat-long { display: none; }
    .wh-stat-short { display: inline; }
    /* Show abbreviated role pill on mobile */
    .role-long { display: none; }
    .role-short { display: inline; }
    /* Override desktop fix-pinned stats on mobile */
    .wh-hall-head .page-head-actions {
        position: static !important;
        right: auto;
        top: auto;
        background: transparent;
        box-shadow: none;
        padding: 0;
    }

    /* Hide tile/list view-toggle on mobile — tile is forced via JS */
    .view-toggle { display: none !important; }

    /* Module tabs (Container Tracking / Parcel Tracking / Warehouse):
       stack vertically, all left-aligned. Hide the middot separators. */
    h1.module-tabs {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        font-size: 1.4rem;
    }
    .module-tab {
        font-size: 1.4rem;
        text-align: left;
        white-space: nowrap;
    }
    .module-tab-sep { display: none; }

    /* Edit-mode buttons row sits below HAL title + stats row on mobile.
       Two equal-width buttons side-by-side. */
    .wh-edit-buttons-row {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        margin: 8px 0 6px 0;
        width: 100%;
    }
    .wh-edit-buttons-row .wh-edit-toggle {
        flex: 1 1 50%;
        margin-left: 0;
        font-size: 11px;
        padding: 6px 8px;
        white-space: nowrap;
    }

    /* Hide the inline edit buttons on mobile — use the separate row below stats. */
    .wh-edit-buttons-inline { display: none !important; }
    .wh-edit-buttons-row-mobile { display: flex !important; }

    /* Floorplan layout: stack vertically and use full width */
    .wh-floorplan-wrap { flex-direction: column; }
    .wh-floorplan-combined { max-width: 100%; overflow-x: auto; }
    body.layout-wide .wh-floorplan-combined { max-width: 100%; }

    /* Reserve space at the bottom for the fixed info-box + legend
       so they don't permanently cover the floorplan. */
    body.has-warehouse-mobile { padding-bottom: 220px; }

    /* Info box: fixed mini panel at the bottom of the viewport */
    .wh-info-box,
    body.layout-wide .wh-info-box {
        position: fixed !important;
        left: 8px;
        right: 8px;
        bottom: 8px;
        top: auto !important;
        width: auto;
        max-width: none;
        max-height: 38vh;
        overflow-y: auto;
        font-size: 13px;
        padding: 8px 10px;
        background: #fff;
        border: 1px solid #e5e7eb;
        box-shadow: 0 -4px 14px rgba(0,0,0,0.12);
        z-index: 50;
    }
    /* In edit modes the info-box keeps its bottom-fixed position too. */
    .wh-editing-floorplan .wh-info-box,
    .wh-editing-pallet    .wh-info-box,
    .wh-editing           .wh-info-box {
        top: auto !important;
        max-height: 38vh;
    }
    .wh-info-box .wh-info-number { font-size: 15px; }
    .wh-info-box .wh-info-height { font-size: 12px; }
    .wh-info-box .wh-info-table th,
    .wh-info-box .wh-info-table td { font-size: 12px; padding: 3px 3px; }
    .wh-info-box .wh-info-sku { font-size: 11px; }

    /* Edit legend: fixed mini panel. In PALLET edit mode it sits ABOVE the
       bottom-fixed info-box (which is up to 38vh tall) so they don't overlap.
       In FLOORPLAN edit mode the info-box is hidden, so the legend can sit
       at the very bottom. */
    .wh-edit-legend,
    body.layout-wide .wh-edit-legend {
        position: fixed !important;
        left: 8px;
        right: 8px;
        top: auto;
        bottom: 8px; /* default — used in floorplan edit mode (info-box hidden) */
        width: auto;
        max-width: none;
        max-height: 30vh;
        overflow-y: auto;
        font-size: 12px;
        padding: 8px 28px 8px 10px;
        z-index: 51;
    }
    /* In PALLET edit mode the info-box (with FIND PALLET search) is
       bottom-fixed and up to 38vh tall — push legend above it. */
    .wh-editing-pallet .wh-edit-legend,
    body.layout-wide .wh-editing-pallet .wh-edit-legend {
        bottom: calc(38vh + 16px);
    }
    .wh-edit-legend-head { font-size: 12px; padding-bottom: 4px; margin-bottom: 4px; }
    .wh-edit-legend-body { font-size: 12px; line-height: 1.4; }

    /* Close button — only shown on mobile */
    .wh-edit-legend-close {
        display: block;
        position: absolute;
        top: 4px; right: 6px;
        width: 22px; height: 22px;
        border: none;
        background: transparent;
        font-size: 18px;
        line-height: 1;
        color: #9a3412;
        cursor: pointer;
        padding: 0;
    }
    .wh-edit-legend-close:hover { color: #431407; }

    /* Export bar: static under the floorplan, opaque white background */
    .wh-export-bar,
    body.layout-wide .wh-export-bar {
        position: static !important;
        right: auto;
        bottom: auto;
        width: 100%;
        max-width: 100%;
        background: #fff;
        padding: 8px 0;
        margin-top: 12px;
        justify-content: flex-end;
        z-index: auto;
    }
}

/* Legend close button — visible on all viewports. Desktop users can
   dismiss the legend to give the info-box (FIND PALLET) more room.
   Re-enabling the edit mode resets the dismissal (handled in JS). */
@media (min-width: 901px) {
    .wh-edit-legend-close {
        display: block;
        position: absolute;
        top: 6px; right: 8px;
        width: 24px; height: 24px;
        border: none;
        background: transparent;
        font-size: 20px;
        line-height: 1;
        color: #9a3412;
        cursor: pointer;
        padding: 0;
    }
    .wh-edit-legend-close:hover { color: #431407; }
    .wh-edit-legend { padding-right: 32px; }
}

/* In FLOORPLAN edit mode the hover/search functionality is disabled —
   the only purpose of that mode is grid editing. Hide the info-box
   (which contains both the hover content and the search form) so the
   user is not distracted, and so it cannot overlap with the legend. */
.wh-hall.wh-editing-floorplan .wh-info-box,
.wh-hall-combined.wh-editing-floorplan .wh-info-box { display: none !important; }
/* Suppress the search-hit highlight while in floorplan edit mode */
.wh-hall.wh-editing-floorplan g.wh-cell.is-search-hit > rect.wh-cell-rect,
.wh-hall.wh-editing-floorplan g.wh-cell.is-hover > rect.wh-cell-rect { fill: inherit; stroke: inherit; }

/* Mobile only: in PALLET edit mode, hide the legend on small screens — it
   covers most of the floorplan and would make pallet placement impossible.
   The info-box (FIND PALLET form) stays visible on the per-hall location
   detail page so users can search/scan at any time, even while editing.
   In the combined view the info-box is still hidden on mobile to free up
   space. Desktop keeps everything visible. */
@media (max-width: 900px) {
    .wh-hall.wh-editing-pallet .wh-edit-legend,
    .wh-hall-combined.wh-editing-pallet .wh-edit-legend,
    body.layout-wide .wh-hall.wh-editing-pallet .wh-edit-legend,
    body.layout-wide .wh-hall-combined.wh-editing-pallet .wh-edit-legend { display: none !important; }
    .wh-hall-combined.wh-editing-pallet .wh-info-box,
    body.layout-wide .wh-hall-combined.wh-editing-pallet .wh-info-box { display: none !important; }
    /* Suppress the search-hit highlight while in pallet edit mode on mobile.
       NOTE: do NOT use `fill: inherit` here — on an SVG <rect> that resolves
       to the parent <g>'s fill, which defaults to BLACK, painting random
       cells solid black. Instead restore the cell-state fills explicitly. */
    .wh-hall.wh-editing-pallet g.wh-cell.is-search-hit.wh-cell-free      > rect.wh-cell-rect,
    .wh-hall.wh-editing-pallet g.wh-cell.is-hover.wh-cell-free           > rect.wh-cell-rect { fill: #ffffff; stroke: #cbd5e1; }
    .wh-hall.wh-editing-pallet g.wh-cell.is-search-hit.wh-cell-occupied  > rect.wh-cell-rect,
    .wh-hall.wh-editing-pallet g.wh-cell.is-hover.wh-cell-occupied       > rect.wh-cell-rect { fill: #dbeafe; stroke: #93c5fd; }
    .wh-hall.wh-editing-pallet g.wh-cell.is-search-hit.wh-cell-blocked   > rect.wh-cell-rect,
    .wh-hall.wh-editing-pallet g.wh-cell.is-hover.wh-cell-blocked        > rect.wh-cell-rect { fill: #374151; stroke: #111827; }
    .wh-hall.wh-editing-pallet g.wh-cell.is-search-hit.wh-cell-none      > rect.wh-cell-rect,
    .wh-hall.wh-editing-pallet g.wh-cell.is-hover.wh-cell-none           > rect.wh-cell-rect { fill: transparent; stroke: transparent; }
}

/* -------------------------------------------------------------------------
   Pallet detail modal (Fase 2)
   ------------------------------------------------------------------------- */
.wh-pallet-modal .ct-modal-panel { max-width: 880px; }
.wh-pallet-body { padding: 18px 22px; }
.wh-pallet-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px;
    margin-bottom: 16px;
}
.wh-pallet-meta-row { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.wh-pallet-meta-row.wh-pallet-meta-note { grid-column: 1 / -1; }
.wh-pallet-meta-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
    color: var(--mp-muted); min-width: 78px;
}
.wh-pallet-meta-value { font-size: 14px; color: var(--mp-black); }
.wh-pallet-meta-value.muted { color: var(--mp-muted); }

.wh-pallet-section { margin-top: 10px; }
.wh-pallet-section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.wh-pallet-section-head h4 {
    margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.6px;
    color: var(--mp-muted);
}

/* ---------- Pallet attachment section in pallet modal ---------- */
.wh-pallet-attach-section { margin-top: 14px; }
.wh-pallet-attach-wrap {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 10px; border: 1px solid #e5e7eb; border-radius: 6px;
    background: #f9fafb;
}
.wh-pallet-attach-thumb-link {
    display: block; flex: 0 0 auto;
    border: 1px solid #d1d5db; border-radius: 4px; overflow: hidden;
    background: #fff; line-height: 0;
}
.wh-pallet-attach-thumb {
    display: block; width: 360px; max-width: 100%; height: auto;
    object-fit: contain;
}
.wh-pallet-attach-meta {
    flex: 1 1 auto; min-width: 0;
    display: flex; flex-direction: column; gap: 8px;
}
.wh-pallet-attach-name {
    font-size: 13px; color: #374151; word-break: break-word;
}
.wh-pallet-attach-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wh-btn-attach-download {
    background: var(--mp-orange); color: #fff; border-color: var(--mp-orange);
    text-decoration: none;
}
.wh-btn-attach-download:hover {
    background: var(--mp-orange-dark); border-color: var(--mp-orange-dark);
    color: #fff; text-decoration: none;
}
.wh-btn-attach-remove {
    background: #fff; color: #b91c1c; border: 1px solid #b91c1c;
}
.wh-btn-attach-remove:hover { background: #fef2f2; }

@media (max-width: 900px) {
    .wh-pallet-attach-wrap { flex-direction: column; }
    .wh-pallet-attach-thumb { width: 100%; max-height: 240px; }
}

.wh-pallet-table-wrap { overflow-x: auto; }
.wh-pallet-table {
    width: 100%; border-collapse: collapse; font-size: 14px;
}
.wh-pallet-table th, .wh-pallet-table td {
    border-bottom: 1px solid var(--mp-line);
    padding: 6px 8px; text-align: left; vertical-align: middle;
}
.wh-pallet-table th {
    font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
    color: var(--mp-muted); border-bottom: 2px solid var(--mp-line-strong);
    text-transform: uppercase;
}
.wh-pallet-table .wh-col-num { text-align: right; white-space: nowrap; }
.wh-pallet-table .wh-col-act { width: 32px; }
.wh-pallet-table tfoot td { border-bottom: none; padding-top: 8px; }
.wh-pallet-table tfoot .wh-col-num strong { font-size: 15px; }

.wh-pallet-input {
    width: 100%; padding: 4px 6px; font: inherit;
    border: 1px solid var(--mp-line); border-radius: var(--radius-sm);
    background: #fff;
}
.wh-pallet-input-sm { max-width: 90px; }
.wh-pallet-input.wh-col-num,
td.wh-col-num .wh-pallet-input { text-align: right; }
.wh-row-remove {
    background: none; border: 1px solid var(--mp-line);
    color: var(--mp-muted); cursor: pointer;
    width: 26px; height: 26px; border-radius: 4px; line-height: 1;
    font-size: 16px; padding: 0;
}
.wh-row-remove:hover { color: #b91c1c; border-color: #b91c1c; }

/* Edit-mode toggling */
.wh-pallet-modal .wh-pallet-edit-show { display: none; }
.wh-pallet-modal.is-edit .wh-pallet-edit-show { display: inline-flex; align-items: center; gap: 6px; }
.wh-pallet-modal.is-edit .wh-pallet-edit-hide { display: none; }
.wh-pallet-modal.is-edit .wh-pallet-meta { background: #fff7ed; border-radius: 6px; padding: 10px 12px; }
.wh-pallet-modal.is-edit .wh-pallet-section-head h4::after {
    content: " — EDIT MODE"; color: var(--mp-orange); font-weight: 700;
}

/* Confirm-step kleur swap (per the original spec): when the user has unsaved
   changes the SAVE button turns green to confirm. */
.wh-pallet-modal.is-dirty .wh-pallet-confirm,
.wh-pallet-modal.is-dirty button.wh-pallet-confirm.btn.btn-primary {
    background: #16a34a !important;
    border-color: #16a34a !important;
    color: #fff !important;
}
.wh-pallet-modal.is-dirty .wh-pallet-confirm:hover { background: #15803d !important; }

.wh-pallet-message {
    margin-top: 12px; padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 13px;
}
.wh-pallet-message.is-error { background: #fee2e2; color: #991b1b; }
.wh-pallet-message.is-ok    { background: #dcfce7; color: #166534; }

/* Pallet cell hover affordance: pointer cursor */
.wh-cell-occupied { cursor: pointer; }

/* Flash green on a cell briefly after a successful edit */
@keyframes wh-flash-success {
    0%   { fill: #bbf7d0; }
    50%  { fill: #86efac; }
    100% { fill: var(--mp-orange, #f97316); }
}
.wh-cell.wh-cell-flash > rect.wh-cell-rect { animation: wh-flash-success 1.1s ease-out; }

/* ============================================================
   Pallet drag-and-drop — visual feedback.
   ============================================================ */

/* Cursor on draggable (occupied) cells. */
svg.wh-floorplan g.wh-cell.wh-cell-occupied { cursor: grab; }
body.wh-dragging-pallet svg.wh-floorplan g.wh-cell.wh-cell-occupied { cursor: grabbing; }

/* Source cell becomes translucent while dragging. */
body.wh-dragging-pallet svg.wh-floorplan g.wh-cell.wh-cell-occupied.is-hover { cursor: grabbing; }

/* Drop-target highlight — orange outline and subtle fill over any valid target. */
svg.wh-floorplan g.wh-cell.wh-cell-drop-target > rect.wh-cell-rect {
    stroke: #f97316;
    stroke-width: 2.5;
    fill-opacity: 0.85;
}
svg.wh-floorplan g.wh-cell.wh-cell-drop-target.wh-cell-free > rect.wh-cell-rect  { fill: #fed7aa; }
svg.wh-floorplan g.wh-cell.wh-cell-drop-target.wh-cell-occupied > rect.wh-cell-rect { fill: #fdba74; }

/* Blocked / none cells explicitly not-drop-allowed during drag. */
body.wh-dragging-pallet svg.wh-floorplan g.wh-cell.wh-cell-blocked,
body.wh-dragging-pallet svg.wh-floorplan g.wh-cell.wh-cell-none {
    cursor: not-allowed;
}

/* Hide the floating side overlays during a drag so the user can drop on the
   cells underneath them. The overlays are restored as soon as the pointer
   is released. The legend / info-box / export-bar / drag-hint all sit at the
   right edge of the viewport — in the combined HAL A+B view they cover
   real cells. */
body.wh-dragging-pallet .wh-edit-legend,
body.wh-dragging-pallet .wh-info-box,
body.wh-dragging-pallet .wh-export-bar {
    opacity: 0;
    pointer-events: none;
    transition: opacity 80ms linear;
}

/* Floating hint shown during drag / after drop. */
.wh-drag-hint {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 9000;
    padding: 10px 16px;
    border-radius: 8px;
    background: #0f172a;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    pointer-events: none;
    max-width: 420px;
}
.wh-drag-hint[data-kind="ok"]    { background: #15803d; }
.wh-drag-hint[data-kind="error"] { background: #b91c1c; }

/* Floating ghost preview that follows cursor while dragging a pallet.
   Uses transform translate for cheap GPU-accelerated motion. The element
   is anchored at top-left 0,0 and moved entirely by translate(). */
.wh-drag-ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 11000;
    pointer-events: none;
    min-width: 56px;
    height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fed7aa;
    color: #7c2d12;
    border: 1.5px solid #fb923c;
    border-radius: 4px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.04em;
    box-shadow: 0 8px 18px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.4) inset;
    opacity: 0.92;
    transform: translate(-9999px, -9999px); /* offscreen until first move */
    will-change: transform;
    user-select: none;
}
.wh-drag-ghost.is-ok {
    background: #bbf7d0;
    color: #14532d;
    border-color: #16a34a;
}
.wh-drag-ghost.is-warn {
    background: #fef08a;
    color: #713f12;
    border-color: #eab308;
}
.wh-drag-ghost.is-bad {
    background: #fecaca;
    color: #7f1d1d;
    border-color: #dc2626;
}

/* ============================================================
   Right-click ARCHIVE contextmenu for pallets.
   ============================================================ */
.wh-ctx-menu {
    position: fixed;
    z-index: 99999;
    pointer-events: auto;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}
.wh-ctx-menu button {
    pointer-events: auto;
    position: relative;
    z-index: 1;
}
.wh-ctx-title {
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #0f172a;
    padding: 2px 2px 6px;
    border-bottom: 1px solid #e2e8f0;
}
.wh-ctx-menu button {
    cursor: pointer;
    border-radius: 6px;
    padding: 8px 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: left;
    border: 1px solid transparent;
    font-size: 13px;
}
.wh-ctx-archive {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}
.wh-ctx-archive:hover { background: #e2e8f0; }
.wh-ctx-archive.is-warn {
    background: #fed7aa;
    color: #9a3412;
    border-color: #fb923c;
}
.wh-ctx-archive.is-warn:hover { background: #fdba74; }
.wh-ctx-archive.is-danger {
    background: #dc2626;
    color: #ffffff;
    border-color: #991b1b;
}
.wh-ctx-archive:disabled { cursor: default; opacity: 0.9; }
.wh-ctx-cancel {
    background: transparent;
    color: #64748b;
    border-color: transparent;
    text-align: center;
    font-weight: 500;
}
.wh-ctx-cancel:hover { background: #f1f5f9; color: #0f172a; }

/* Right-click on AVAILABLE cell: ADD PALLET button (positive accent) */
.wh-ctx-add {
    background: #ecfdf5;
    color: #065f46;
    border-color: #6ee7b7;
}
.wh-ctx-add:hover { background: #d1fae5; }

/* Event log: RESTORE button (2-step confirm) */
.wh-restore-btn {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 10px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    color: #0f172a;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.wh-restore-btn:hover { background: #e2e8f0; }
.wh-restore-btn.is-warn {
    background: #fdba74;
    color: #7c2d12;
    border-color: #fb923c;
}
.wh-restore-btn.is-warn:hover { background: #fb923c; }
.wh-restore-btn.is-commit {
    background: #16a34a;
    color: #fff;
    border-color: #15803d;
}
.wh-restore-btn:disabled { cursor: default; opacity: 0.9; }

/* === RESTORE PALLET button in context menu (cyan/blue accent) === */
.wh-ctx-restore {
    background: #ecfeff;
    color: #155e75;
    border-color: #67e8f9;
}
.wh-ctx-restore:hover { background: #cffafe; }

/* === RESTORE PALLET dialog (modal) === */
.wh-pallet-restore-modal {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: none;
    align-items: flex-start;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    padding: 60px 16px 24px;
    overflow-y: auto;
}
.wh-pallet-restore-modal.is-open { display: flex; }
.wh-pallet-restore-modal .wh-restore-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.30);
    width: min(720px, 100%);
    max-height: calc(100vh - 96px);
    display: flex;
    flex-direction: column;
}
.wh-pallet-restore-modal .wh-restore-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}
.wh-pallet-restore-modal .wh-restore-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #0f172a;
    text-transform: uppercase;
}
.wh-pallet-restore-modal .wh-restore-target {
    font-size: 12px;
    color: #475569;
    margin-top: 4px;
    letter-spacing: 0.04em;
}
.wh-pallet-restore-modal .wh-restore-close {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.wh-pallet-restore-modal .wh-restore-close:hover { background: #f1f5f9; color: #0f172a; }
.wh-pallet-restore-modal .wh-restore-body {
    padding: 12px 20px 20px;
    overflow-y: auto;
}
.wh-pallet-restore-modal .wh-restore-empty {
    padding: 24px 8px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}
.wh-pallet-restore-modal .wh-restore-loading {
    padding: 24px 8px;
    text-align: center;
    color: #64748b;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* List table inside RESTORE modal */
.wh-restore-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.wh-restore-table thead th {
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #475569;
    text-transform: uppercase;
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    position: sticky;
    top: 0;
}
.wh-restore-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    color: #0f172a;
    vertical-align: middle;
}
.wh-restore-table tbody tr:hover { background: #f8fafc; }
.wh-restore-table .wh-rt-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.wh-restore-table .wh-rt-prev { color: #64748b; font-size: 11px; font-variant-numeric: tabular-nums; }
.wh-restore-table .wh-rt-when { color: #64748b; font-size: 11px; }
.wh-restore-table .wh-rt-action { text-align: right; white-space: nowrap; }
.wh-restore-table .wh-rt-btn {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid #15803d;
    background: #16a34a;
    color: #ffffff;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    text-transform: uppercase;
}
.wh-restore-table .wh-rt-btn:hover { background: #15803d; }
.wh-restore-table .wh-rt-btn:disabled { opacity: 0.6; cursor: default; }

/* =====================================================================
   In-app confirmation / alert modal — replaces native window.confirm()
   and window.alert() in the warehouse and pallet flows.

   API (JS):  window.mp.confirm({title, body, kind, confirmLabel, cancelLabel}).then(ok => ...)
              window.mp.alert({title, body, kind, confirmLabel}).then(() => ...)

   Markup is built on the fly by the helper. Kept visually consistent with
   the existing wh-pallet-restore modal and the wh-ctx ARCHIVE popover.
   ===================================================================== */
.mp-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    padding: 60px 16px 24px;
    overflow-y: auto;
    animation: mpConfirmFadeIn 120ms ease-out;
}
@keyframes mpConfirmFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.mp-confirm-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.30);
    width: min(440px, 100%);
    max-height: calc(100vh - 96px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: mpConfirmSlide 140ms ease-out;
}
@keyframes mpConfirmSlide {
    from { transform: translateY(-12px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.mp-confirm-head {
    padding: 14px 18px 10px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 10px;
}
.mp-confirm-icon {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    line-height: 1;
}
.mp-confirm-icon.is-info    { background: #dbeafe; color: #1e3a8a; }
.mp-confirm-icon.is-warn    { background: #fef3c7; color: #92400e; }
.mp-confirm-icon.is-danger  { background: #fee2e2; color: #b91c1c; }
.mp-confirm-icon.is-success { background: #dcfce7; color: #166534; }
.mp-confirm-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.01em;
}
.mp-confirm-body {
    padding: 14px 18px 18px;
    color: #1f2937;
    font-size: 0.94rem;
    line-height: 1.45;
    white-space: pre-line;
}
.mp-confirm-foot {
    padding: 12px 18px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.mp-confirm-btn {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1f2937;
    border-radius: 6px;
    padding: 7px 16px;
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 100ms ease, border-color 100ms ease;
}
.mp-confirm-btn:hover { background: #f3f4f6; }
.mp-confirm-btn:focus { outline: 2px solid #93c5fd; outline-offset: 1px; }
.mp-confirm-btn.is-primary {
    background: #1e3a8a;
    border-color: #1e3a8a;
    color: #fff;
}
.mp-confirm-btn.is-primary:hover { background: #1e40af; }
.mp-confirm-btn.is-danger {
    background: #dc2626;
    border-color: #b91c1c;
    color: #fff;
}
.mp-confirm-btn.is-danger:hover { background: #b91c1c; }
.mp-confirm-btn.is-warn {
    background: #d97706;
    border-color: #b45309;
    color: #fff;
}
.mp-confirm-btn.is-warn:hover { background: #b45309; }
.mp-confirm-btn.is-success {
    background: #15803d;
    border-color: #166534;
    color: #fff;
}
.mp-confirm-btn.is-success:hover { background: #166534; }

/* -------------------------------------------------------------------------
   Mobile EDIT MODE — pallet redesign + floorplan popup positioning
   ------------------------------------------------------------------------- */

/* Default desktop: hide mobile-only buttons */
.wh-mobile-only { display: none !important; }

/* Move banner (top of viewport) — used when MOVE is armed on mobile */
.wh-mobile-move-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: #1e3a8a;
    color: #fff;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    z-index: 1200;
}
.wh-mobile-move-bar[hidden] { display: none !important; }
.wh-mobile-move-bar button {
    background: #fff;
    color: #1e3a8a;
    border: 0;
    border-radius: 4px;
    padding: 6px 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
.wh-mobile-move-bar button:hover { background: #e5e7eb; }

/* Empty-cell popup (mobile only) — same look & feel as ctx menu */
.wh-mobile-empty-pop {
    position: fixed;
    left: 8px; right: 8px;
    bottom: 8px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 -4px 18px rgba(0,0,0,0.18);
    padding: 8px;
    z-index: 1100;
    font-size: 14px;
}
.wh-mobile-empty-pop[hidden] { display: none !important; }
.wh-mobile-empty-pop-title {
    font-size: 11px; font-weight: 700; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 6px 10px 8px; border-bottom: 1px solid #e5e7eb; margin-bottom: 4px;
}
.wh-mobile-empty-pop button {
    display: block; width: 100%; text-align: left;
    padding: 12px 14px; border: 0; background: transparent; cursor: pointer;
    border-radius: 6px; font-size: 15px; font-weight: 600;
    color: var(--mp-black);
}
.wh-mobile-empty-pop button:hover { background: #f1f5f9; }
.wh-mobile-empty-pop .wh-mobile-empty-pop-cancel {
    color: #6b7280; border-top: 1px solid #e5e7eb;
    margin-top: 4px; padding-top: 12px; border-radius: 0;
    font-weight: 500;
}

/* By default the mobile-only header variants are hidden — desktop wins.
   The @media (max-width: 900px) block flips this. Applies to BOTH the
   pallet edit-modal table (.wh-pallet-table) AND the hover info-box
   table (.wh-info-table) used on hall pages. */
.wh-pallet-table .wh-col-mobile,
.wh-info-table   .wh-col-mobile  { display: none; }
.wh-pallet-table .wh-col-desktop,
.wh-info-table   .wh-col-desktop { display: inline-block; }

@media (max-width: 900px) {
    /* Show mobile-only buttons in pallet modal */
    .wh-mobile-only { display: inline-block !important; }

    /* Hide desktop-only meta rows (LOCATION/STATUS/ORIGIN) and DESCRIPTION column */
    .wh-meta-mobile-hide { display: none !important; }
    .wh-col-mobile-hide { display: none !important; }

    /* Compact column headers on mobile so all numeric columns fit without
       horizontal scrolling. Desktop labels are hidden, short variants shown. */
    .wh-pallet-table .wh-col-desktop,
    .wh-info-table   .wh-col-desktop { display: none !important; }
    .wh-pallet-table .wh-col-mobile,
    .wh-info-table   .wh-col-mobile  { display: inline-block; }
    .wh-pallet-table .wh-col-mobile.wh-col-stack,
    .wh-info-table   .wh-col-mobile.wh-col-stack {
        line-height: 1.05;
        font-size: inherit;
    }
    .wh-pallet-table th.wh-col-num {
        padding-left: 4px;
        padding-right: 4px;
    }
    /* Tight padding on the info-box table headers too (no .wh-col-num class
       in info-table, so target plain <th>). */
    .wh-info-table th { padding-left: 4px; padding-right: 4px; }

    /* Pallet meta becomes single-column on mobile (only HEIGHT + NOTE remain) */
    .wh-pallet-meta { grid-template-columns: 1fr; gap: 6px; }

    /* Floorplan EDIT popup on mobile: fixed at bottom of viewport.
       --wh-legend-top is set by JS when legend visible (= top of legend in
       viewport coords) so popup sits directly above legend with 8px gap.
       When legend dismissed, --wh-legend-top is removed and popup falls
       back to bottom: 8px (pinned to viewport bottom). */
    .wh-edit-popup {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: calc(100vh - var(--wh-legend-top, 100vh) + 8px);
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        z-index: 60;
        max-height: 50vh;
        overflow-y: auto;
        box-shadow: 0 -6px 18px rgba(0,0,0,0.18);
    }
    .wh-edit-popup button { padding: 12px 14px; font-size: 15px; }
}

/* =============================================================================
   ATTACH button + paperclip icon (modal foot)
   ============================================================================= */
.wh-pallet-foot-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
}
.wh-pallet-foot-edit {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    width: 100%;
}
/* Archive button: red (all viewports) */
.wh-btn-archive {
    background: #dc2626;
    border-color: #b91c1c;
    color: #fff;
}
.wh-btn-archive:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

/* MOVE button: blue accent (all viewports) */
.wh-btn-move {
    background: #1e3a8a;
    border-color: #1e3a8a;
    color: #fff;
}
.wh-btn-move:hover {
    background: #172554;
    border-color: #172554;
    color: #fff;
}

.wh-btn-attach {
    background: var(--mp-orange);
    border: 1px solid var(--mp-orange);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.wh-btn-attach:hover {
    background: var(--mp-orange-dark);
    border-color: var(--mp-orange-dark);
    color: #fff;
}
.wh-attach-icon { display: inline-flex; align-items: center; justify-content: center; }
.wh-attach-icon svg { display: block; }
.wh-attach-text { font-weight: 600; letter-spacing: 0.4px; }

/* Desktop / mobile visibility helpers used in modal foot.
   wh-mobile-only is already defined elsewhere; pair with wh-desktop-only. */
.wh-desktop-only { display: inline-flex; }

/* Tablet+mobile-only (≤ 1199px) — used for ARCHIVE / MOVE buttons that
   should NOT appear on the desktop modal (desktop uses drag/right-click). */
.wh-tablet-mobile-only { display: none !important; }
@media (max-width: 1199px) {
    .wh-tablet-mobile-only { display: inline-flex !important; }
}
@media (max-width: 900px) {
    .wh-desktop-only { display: none !important; }
}

/* =============================================================================
   ATTACH-corner indicator on cells (top-left dark blue triangle)
   ============================================================================= */
.wh-attach-corner {
    fill: #1e3a8a;
    pointer-events: none;
}

/* =============================================================================
   Floorplan grid border labels (in EDIT FLOORPLAN MODE on PC, or
   when the 'Grid labels: Always visible' setting is on — desktop only)
   ============================================================================= */
.wh-grid-labels { display: none; }
.wh-hall.wh-editing-floorplan .wh-grid-labels,
.wh-hall.wh-grid-labels-always .wh-grid-labels,
.mv-plan-page.wh-grid-labels-always .wh-grid-labels { display: block; }
@media (max-width: 900px) {
    /* Hide labels entirely on mobile — too small to be useful */
    .wh-hall.wh-editing-floorplan .wh-grid-labels,
    .wh-hall.wh-grid-labels-always .wh-grid-labels,
    .mv-plan-page.wh-grid-labels-always .wh-grid-labels { display: none; }
}
.wh-grid-label {
    fill: #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0;
    pointer-events: none;
    user-select: none;
}
.wh-grid-label-row { font-size: 9px; }
.wh-grid-label-col { font-size: 9px; letter-spacing: 0.3px; }

/* =============================================================================
   Search-hit highlight (matches hover style)
   ============================================================================= */
g.wh-cell.is-search-hit > rect.wh-cell-rect {
    fill: #fde68a !important;
    stroke: #b45309 !important;
    stroke-width: 2;
}

/* =============================================================================
   Info-box pallet search (empty state)
   ============================================================================= */
.wh-info-search {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
    display: flex; flex-direction: column; gap: 6px;
}
.wh-info-search-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #64748b;
}
.wh-info-search-row {
    display: flex; gap: 6px; align-items: center;
}
.wh-info-search-input {
    flex: 1 1 auto;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.wh-info-search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.wh-info-search-btn {
    flex: 0 0 auto;
}
.wh-info-search-msg {
    font-size: 12px;
    line-height: 1.4;
    padding: 4px 0;
    white-space: pre-line;
}
.wh-info-search-msg.is-ok    { color: #047857; }
.wh-info-search-msg.is-error { color: #b91c1c; }

/* SCAN button — sits to the LEFT of the FIND input. Visible only while
   EDIT PALLET MODE is active on touch / small screens (max-width:1024px or
   no hover capability). On desktop the SCAN button stays hidden because
   editing is mouse-driven there. */
.wh-info-search-scan {
    display: none;                /* hidden by default — see media queries */
    flex: 0 0 auto;
    background: #E6642E;          /* MEGAPROJECTS brand orange */
    border-color: #E6642E;
    color: #ffffff;
    font-weight: 700;
}
.wh-info-search-scan:hover,
.wh-info-search-scan:focus {
    background: #cf5524;
    border-color: #cf5524;
    color: #ffffff;
}
/* Show the SCAN button only when EDIT PALLET MODE is active AND the
   device is touch / mobile / tablet (no hover or narrow viewport). */
@media (hover: none), (max-width: 1024px) {
    .wh-hall.wh-editing-pallet           .wh-info-search-scan,
    .wh-hall-combined.wh-editing-pallet  .wh-info-search-scan,
    body.layout-wide .wh-hall.wh-editing-pallet          .wh-info-search-scan,
    body.layout-wide .wh-hall-combined.wh-editing-pallet .wh-info-search-scan {
        display: inline-flex;
        align-items: center;
    }
}

/* "Hover a pallet to see its contents" — hide on touch / tablet / mobile.
   Hover doesn't exist there so the message is misleading. The hint stays
   visible on desktop (mouse-driven hover works). */
@media (hover: none), (max-width: 1024px) {
    .wh-info-empty-hover { display: none !important; }

    /* When the "Hover..." hint is gone, the FIND PALLET row sits at the top
       of the bottom card on its own. The separator line + padding above it
       only makes sense as a divider BELOW pallet content (which never shows
       on touch). Drop it on mobile/tablet so the row hugs the card top. */
    .wh-info-search {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }
}

/* =============================================================================
   SCAN PALLET overlay (camera-based barcode/QR scanner)
   ============================================================================= */
.wh-scan-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.92);
    z-index: 4000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.wh-scan-overlay[hidden] { display: none !important; }
.wh-scan-panel {
    width: 100%;
    max-width: 480px;
    background: #0b1220;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    display: flex; flex-direction: column;
}
.wh-scan-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: #1f2937;
    color: #fff;
}
.wh-scan-title {
    font-size: 13px; font-weight: 700; letter-spacing: 1px;
}
.wh-scan-close {
    background: transparent; border: 0; color: #fff;
    font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.wh-scan-body {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    overflow: hidden;
}
.wh-scan-video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.wh-scan-frame {
    position: absolute;
    top: 50%; left: 50%;
    width: min(70%, 260px);
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    border: 3px solid #E6642E;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
    pointer-events: none;
}
.wh-scan-status {
    padding: 10px 14px;
    background: #111827;
    color: #cbd5e1;
    font-size: 12px;
    text-align: center;
    min-height: 36px;
}

/* Retry state: any tap on the panel restarts the scanner. */
.wh-scan-overlay.wh-scan-retry .wh-scan-panel { cursor: pointer; }
.wh-scan-overlay.wh-scan-retry .wh-scan-body  { background: #1f2937; }
.wh-scan-overlay.wh-scan-retry .wh-scan-frame {
    border-color: #E6642E;
    border-style: dashed;
    opacity: 0.45;
}
.wh-scan-overlay.wh-scan-retry .wh-scan-status {
    background: #E6642E;
    color: #fff;
    font-weight: 600;
}

/* =============================================================================
   RESTORE PALLET dialog — PC redesign (cleaner typography & spacing)
   ============================================================================= */
.wh-pallet-restore-modal .ct-modal-panel,
.wh-pallet-restore-modal .wh-pallet-panel {
    max-width: 720px;
    width: 100%;
}
.wh-pallet-restore-modal .wh-pallet-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px 12px;
    border-bottom: 1px solid #e2e8f0;
}
.wh-pallet-restore-modal .wh-pallet-modal-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #0f172a;
}
.wh-pallet-restore-modal .wh-pallet-modal-close {
    width: 28px; height: 28px;
    border: none; background: transparent;
    font-size: 22px; line-height: 1;
    color: #64748b; cursor: pointer;
    border-radius: 4px;
}
.wh-pallet-restore-modal .wh-pallet-modal-close:hover {
    background: #f1f5f9; color: #0f172a;
}
.wh-pallet-restore-modal .wh-pallet-modal-body {
    padding: 14px 22px 18px;
    max-height: 60vh;
    overflow-y: auto;
}
.wh-pallet-restore-modal #wh-restore-target-info {
    margin: 0 0 12px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-left: 3px solid #2563eb;
    border-radius: 3px;
    font-size: 13px;
    color: #1e293b;
}
.wh-pallet-restore-modal .wh-restore-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.wh-pallet-restore-modal .wh-restore-table thead th {
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #64748b;
    padding: 6px 10px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 1;
}
.wh-pallet-restore-modal .wh-restore-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.wh-pallet-restore-modal .wh-restore-table tbody tr:hover {
    background: #f8fafc;
}
.wh-pallet-restore-modal .wh-restore-table tbody td:first-child {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
}
.wh-pallet-restore-modal .wh-restore-table tbody td:nth-child(2) {
    color: #475569;
    font-variant-numeric: tabular-nums;
}
.wh-pallet-restore-modal .wh-restore-table tbody td:nth-child(3) {
    color: #94a3b8;
    font-size: 11px;
}
.wh-pallet-restore-modal .wh-restore-row-btn {
    background: #16a34a;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    cursor: pointer;
}
.wh-pallet-restore-modal .wh-restore-row-btn:hover { background: #15803d; }
.wh-pallet-restore-modal .wh-restore-row-btn:disabled { opacity: 0.6; cursor: default; }
.wh-pallet-restore-modal .wh-pallet-modal-foot {
    display: flex;
    justify-content: flex-end;
    padding: 12px 22px;
    border-top: 1px solid #e2e8f0;
    background: #fafafa;
}
.wh-pallet-restore-modal #wh-restore-loading,
.wh-pallet-restore-modal #wh-restore-empty {
    padding: 16px 8px;
    text-align: center;
    color: #94a3b8;
}


/* === Movement Proposal page (/warehouse/movement/plan) === */

.mv-plan-page {
    /* Match the drag/drop ghost colours from edit-pallet mode
       (.wh-drag-ghost.is-ok / .is-warn) so green = FULL pick and
       yellow = PARTIAL pick share the same visual language. */
    --mv-grn:    #16a34a;   /* drag-ghost is-ok border */
    --mv-grnbg:  #bbf7d0;   /* drag-ghost is-ok background */
    --mv-grnbd:  #86efac;
    --mv-grntxt: #14532d;   /* drag-ghost is-ok text */
    --mv-yel:    #eab308;   /* drag-ghost is-warn border */
    --mv-yelbg:  #fef08a;   /* drag-ghost is-warn background */
    --mv-yelbd:  #facc15;
    --mv-yeltxt: #713f12;   /* drag-ghost is-warn text */
    --mv-blu:    #2563eb;
    --mv-blubg:  #e7efff;
    --mv-blubd:  #b9cdff;
}
.mv-plan-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.mv-plan-head h2 { margin: 0; }
.mv-plan-sub { margin: 0; color: #64748b; font-size: .9rem; }
.mv-plan-arrow { color: #f59e0b; padding: 0 6px; font-weight: 700; }
.mv-plan-meta { color: #475569; }
.mv-plan-loading { padding: 24px; text-align: center; color: #64748b; }

.mv-plan-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 1100px) {
    .mv-plan-grid {
        grid-template-columns: minmax(0, 1fr) 320px;
        align-items: start;
    }
}
.mv-plan-halls {
    display: flex; flex-direction: column; gap: 16px;
    min-width: 0;
}
.mv-plan-hall {
    background: #fff;
    border: 1px solid var(--mp-line);
    border-radius: 8px;
    padding: 10px 12px;
}
.mv-plan-hall-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.mv-plan-hall-head h3 { margin: 0; font-size: 1rem; letter-spacing: .04em; }
.mv-plan-hall-stat .mv-mark-pill { margin-left: 6px; }
.mv-plan-svg-wrap {
    overflow: auto;
    max-height: 60vh;
    border-top: 1px dashed var(--mp-line);
    padding-top: 8px;
}
.mv-plan-floorplan { display: block; }

/* Mark colours on the cloned hall SVG. Inherit hall-detail base styling
   (wh-cell-free / wh-cell-occupied / wh-cell-blocked) from the global rules,
   only override for FULL/PARTIAL pick markers below. */
.mv-plan-floorplan g.wh-cell.mv-mark.mv-mark-full .wh-cell-rect {
    fill: var(--mv-grnbg);
    stroke: var(--mv-grn);
    stroke-width: 1.5;
}
.mv-plan-floorplan g.wh-cell.mv-mark.mv-mark-partial .wh-cell-rect {
    fill: var(--mv-yelbg);
    stroke: var(--mv-yel);
    stroke-width: 1.5;
}
.mv-plan-floorplan g.wh-cell.mv-mark { cursor: help; }
/* Inherit hall-detail .wh-cell-num styling (14px monospace blue #1e3a8a)
   so pallet numbers render the same way as on the location detail page. */

/* Pills used for FULL/PARTIAL counts and tooltips. */
.mv-mark-pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    border: 1px solid transparent;
    letter-spacing: .04em;
}
.mv-mark-pill.mv-mark-full     { background: var(--mv-grnbg); border-color: var(--mv-grnbd); color: var(--mv-grntxt); }
.mv-mark-pill.mv-mark-partial  { background: var(--mv-yelbg); border-color: var(--mv-yelbd); color: var(--mv-yeltxt); }
.mv-mark-pill.mv-mark-short    { background: #f3e8ff; border-color: #d6b8ff; color: #6b21a8; }

/* TRANSIT panel — sticky on desktop, full-width below halls on mobile. */
.mv-plan-transit {
    background: var(--mv-blubg);
    border: 1px solid var(--mv-blubd);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex; flex-direction: column;
    gap: 8px;
    min-width: 0;
}
@media (min-width: 1100px) {
    .mv-plan-transit {
        position: sticky;
        top: 88px;
        max-height: calc(100vh - 110px);
        overflow: auto;
    }
}
.mv-plan-transit-head {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px dashed var(--mv-blubd);
    padding-bottom: 6px;
}
.mv-plan-transit-head h3 { margin: 0; color: var(--mv-blu); letter-spacing: .04em; }
.mv-plan-transit-target { color: var(--mv-blu); font-weight: 600; }

/* SORT bar above the transit list. */
.mv-plan-transit-sortbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0 10px;
    flex-wrap: wrap;
}
.mv-plan-transit-sortlabel {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    color: #64748b;
    margin-right: 2px;
}
.mv-plan-transit-sortbtn {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    padding: 4px 9px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 80ms, border-color 80ms, color 80ms;
}
.mv-plan-transit-sortbtn:hover {
    border-color: var(--mp-orange, #E0610D);
    color: var(--mp-orange, #E0610D);
}
.mv-plan-transit-sortbtn.is-active {
    background: var(--mp-orange, #E0610D);
    border-color: var(--mp-orange, #E0610D);
    color: #fff;
}
.mv-plan-transit-sortbtn.is-active:hover {
    background: var(--mp-orange-dark, #B94C00);
    border-color: var(--mp-orange-dark, #B94C00);
    color: #fff;
}

.mv-plan-transit-list { display: flex; flex-direction: column; gap: 8px; }
.mv-plan-transit-empty { color: #475569; padding: 12px; text-align: center; }
.mv-transit-group {
    background: #fff;
    border: 1px solid var(--mv-blubd);
    border-radius: 6px;
    padding: 8px 10px;
}
.mv-transit-sku {
    font-weight: 600;
    font-size: .92rem;
    margin-bottom: 4px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.mv-transit-qty { color: #475569; font-weight: 500; }
.mv-transit-pallet {
    display: flex; flex-wrap: wrap; gap: 6px;
    align-items: center;
    border-left: 3px solid transparent;
    padding: 3px 6px;
    margin-top: 2px;
    font-size: .85rem;
}
/* Green bar uses the medium tone (--mv-grnbd). Yellow bar uses the
   lighter floorplan-fill tone (--mv-yelbg) to match the marked cells.
   Bar width is 6px so both colours stay clearly visible. */
.mv-transit-pallet { border-left-width: 6px; }
.mv-transit-pallet.mv-mark-full    { border-left-color: var(--mv-grnbd); background: #f6fef9; }
.mv-transit-pallet.mv-mark-partial { border-left-color: var(--mv-yelbg); background: #fffdf3; }
/* Pallet-no label — "PALLET 619" — sized to match (and matched by) the
   PICK LIST h3 in the same panel: 1.25rem (25% larger than legacy .95rem)
   and bold blue. !important wins over the legacy
   .mv-transit-group-pallet ... .pallet-no specific rule. */
.mv-transit-pallet-no {
    font-weight: 800 !important;
    color: var(--mv-blu) !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.25rem !important;
    line-height: 1.2;
}
/* Match PICK LIST heading to the new pallet-no size so the two visually
   align ("PALLET 619" is the same prominence as "PICK LIST"). */
.mv-plan-transit-head h3 { font-size: 1.25rem !important; }
.mv-transit-pallet-meta { color: #475569; }
.mv-transit-pallet-newno { color: var(--mv-blu); font-weight: 600; }
/* Pallet-level pick ratio (picked units / total units on the pallet,
   across ALL SKUs). Black bold, hard right-aligned. */
/* Pallet-level pick ratio — ALWAYS flush against the right edge of the
   pallet header row, regardless of sort mode. !important wins over the
   default flex-wrap on .mv-transit-group-pallet .mv-transit-pallet-head.
   Negative margin-right cancels the 6px right-padding on the parent
   .mv-transit-pallet / .mv-transit-pallet-head so the % truly sits at
   the visual right edge of the card. */
.mv-transit-pallet-ratio {
    margin-left: auto !important;
    margin-right: -6px !important;
    padding-right: 6px;
    text-align: right;
    color: #000;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
    white-space: nowrap;
}
/* Force the pallet-head row to keep ratio on the same baseline as the
   pallet-no, never wrapping. The meta-text in the middle shrinks. */
.mv-transit-group-pallet .mv-transit-pallet-head,
.mv-transit-pallet {
    flex-wrap: nowrap !important;
}
.mv-transit-group-pallet .mv-transit-pallet-head .mv-transit-pallet-meta,
.mv-transit-pallet .mv-transit-pallet-meta {
    flex: 1 1 auto !important;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Strong arrow next to the PICK LIST target label. Use a heavier glyph
   and -webkit-text-stroke so the arrow looks visibly bolder regardless
   of the loaded system font (→ only has limited weights in most UI
   fonts). */
.mv-plan-transit-target { font-weight: 700; }
.mv-plan-transit-arrow {
    font-weight: 900;
    -webkit-text-stroke: 1px currentColor;
    margin-right: 1px;
}
/* ESTIMATED FULL PALLETS — KPI strip directly below the PICK LIST header.
   Label left, big bold value right. Mirrors the look of the SORT bar so
   the panel reads top-to-bottom: header → KPI → sort → list → footer. */
/* ESTIMATED FULL PALLETS — KPI strip. Force flex with !important so it
   never collapses to inline content (panel parent is also flex). */
.mv-plan-transit-estimate {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: baseline !important;
    gap: 8px;
    padding: 6px 10px;
    margin: 4px 0 6px;
    border-top: 1px solid var(--mv-blubd);
    border-bottom: 1px solid var(--mv-blubd);
    background: #f8fafc;
    width: 100%;
    box-sizing: border-box;
}
.mv-plan-transit-estimate-label {
    color: var(--mv-blu);
    font-weight: 800 !important;
    letter-spacing: .04em;
    font-size: .92rem;
    text-transform: uppercase;
    flex: 0 0 auto;
}
.mv-plan-transit-estimate-value {
    margin-left: auto !important;
    text-align: right;
    color: #000;
    font-weight: 800 !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.25rem;
    flex: 0 0 auto;
}

/* PALLET sort mode — each group is one pallet with its SKUs underneath. */
.mv-transit-group-pallet {
    border-left-width: 6px;
    border-left-style: solid;
    padding: 6px 8px 6px 10px;
}
.mv-transit-group-pallet.mv-mark-full {
    border-left-color: var(--mv-grnbd);
    background: #f6fef9;
}
.mv-transit-group-pallet.mv-mark-partial {
    border-left-color: var(--mv-yelbg);
    background: #fffdf3;
}
.mv-transit-group-pallet .mv-transit-pallet-head {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--mv-blubd);
}
.mv-transit-group-pallet .mv-transit-pallet-head .mv-transit-pallet-no {
    color: var(--mv-blu);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .95rem;
    font-weight: 700;
}
.mv-transit-group-pallet .mv-transit-pallet-head .mv-transit-pallet-meta {
    color: #475569;
    font-size: .82rem;
}
.mv-transit-pallet-line {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 8px;
    padding: 2px 4px;
    font-size: .85rem;
}
.mv-transit-pallet-line + .mv-transit-pallet-line {
    border-top: 1px dotted #e5e7eb;
}
.mv-transit-line-sku {
    color: #1f2937;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
}
.mv-transit-line-qty {
    color: #475569;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: normal;
    flex: 0 0 auto;
}
/* TEKORT/SHORT badge inside a pick line: always on its own line below
   the qty annotation, right-aligned with it, and constrained to the
   pallet card width (no overflow outside the yellow/green frame). */
.mv-transit-pallet-line { flex-wrap: wrap !important; }
.mv-transit-line-qty .mv-loose-short {
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 2px 0 0 auto;
    text-align: center;
}
.mv-plan-transit-foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    border-top: 1px dashed var(--mv-blubd);
    padding-top: 8px;
}
.mv-plan-transit-foot .btn { width: 100%; }
.mv-plan-transit-foot #mv-plan-confirm { grid-column: 1 / -1; }
.mv-plan-transit-foot .btn-white {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #d1d5db;
}
.mv-plan-transit-foot .btn-white:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Hover tooltip — fixed-position, follows cursor. */
.mv-plan-tip {
    position: fixed;
    z-index: 9999;
    background: #1f2937;
    color: #fff;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: .85rem;
    max-width: 280px;
    pointer-events: none;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.mv-plan-tip-head {
    font-weight: 600;
    border-bottom: 1px solid #374151;
    padding-bottom: 4px;
    margin-bottom: 4px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.mv-plan-tip-head .mv-mark-pill { color: #1f2937; }
.mv-plan-tip-body div { padding: 1px 0; }

/* ============================================================
   LABELS modal — pallet label PDF generator
   Triggered by the LABELS button in the warehouse hall export-bar.
   ============================================================ */
.wh-labels-btn { /* sits left of EXPORT EXCEL */ }

.wh-labels-modal {
    position: fixed; inset: 0;
    z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
}
.wh-labels-modal[hidden] { display: none; }
.wh-labels-modal__backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1;
}
.wh-labels-modal__panel {
    position: relative; z-index: 2;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    width: min(960px, 100%);
    max-width: 960px;
    display: flex; flex-direction: column;
    margin-top: 24px; margin-bottom: 24px;
    /* Static viewport-height so size doesn't jump between select-mode and
       preview-mode. Body scrolls internally when content overflows. */
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    overflow: hidden;
}
.wh-labels-modal__panel .wh-labels-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.wh-labels-modal__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.wh-labels-modal__header h2 {
    margin: 0; font-size: 18px; font-weight: 700;
    color: #1f2937; letter-spacing: 0.5px;
}
.wh-labels-modal__close {
    background: transparent; border: 0; cursor: pointer;
    font-size: 26px; line-height: 1; color: #6b7280;
    padding: 4px 8px;
}
.wh-labels-modal__close:hover { color: #1f2937; }

.wh-labels-modal__body {
    padding: 16px 20px;
    display: flex; flex-direction: column; gap: 12px;
}
.wh-labels-modal__controls {
    display: flex; flex-direction: column; gap: 8px;
}
.wh-labels-controls__row {
    display: flex; align-items: flex-end; gap: 8px;
}
.wh-labels-controls__row--actions { align-items: center; }
.wh-labels-controls__field {
    flex: 1 1 auto;
    display: flex; flex-direction: column;
    font-size: 12px; color: #4b5563; gap: 4px;
}
.wh-labels-controls__field input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}
.wh-labels-controls__field input:focus {
    outline: none; border-color: #E6642E;
    box-shadow: 0 0 0 2px rgba(230, 100, 46, 0.15);
}
.wh-labels-controls__btn {
    flex: 0 0 auto;
    height: 36px;
}
.wh-labels-counter {
    font-size: 13px; color: #6b7280;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}
.wh-labels-msg {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
    background: #f3f4f6;
    color: #374151;
}
.wh-labels-msg[hidden] { display: none; }
.wh-labels-msg.is-ok { background: #ecfdf5; color: #065f46; }
.wh-labels-msg.is-warn { background: #fef3c7; color: #92400e; }

.wh-labels-modal__list {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    background: #fafafa;
}
.wh-labels-row {
    display: grid;
    grid-template-columns: 24px 110px 1fr;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-bottom: 1px solid #eef0f2;
    font-size: 13px;
    cursor: pointer;
}
.wh-labels-row:nth-child(even) { background: #f3f4f6; }
.wh-labels-row:hover { background: #fff7f2; }
.wh-labels-row__num { font-weight: 600; color: #1f2937; }
.wh-labels-row__skus { color: #6b7280; font-size: 12px; }
.wh-labels-empty {
    padding: 24px; text-align: center; color: #9ca3af; font-size: 13px;
}

.wh-labels-modal__preview {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    display: flex; flex-direction: column;
}
.wh-labels-modal__preview[hidden] { display: none; }
.wh-labels-preview__bar {
    display: flex; align-items: center; justify-content: flex-start;
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}
.wh-labels-preview__title {
    font-size: 12px; color: #4b5563; letter-spacing: 0.5px;
    text-transform: uppercase;
}
#wh-labels-iframe,
#wh-pallet-label-iframe {
    width: 100%; height: 520px;
    border: 0; background: #525659;
}
/* In preview-mode (desktop): iframe fills remaining vertical space so the
   modal stays inside the viewport and CLOSE/PRINT footer is always visible. */
.wh-labels-modal__panel[data-mode="preview"] #wh-labels-iframe,
.wh-labels-modal__panel[data-mode="preview"] #wh-pallet-label-iframe {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
}
/* Stacked client-rendered canvases (PDF.js) used on touch devices where the
   native iframe PDF viewer only renders the first page. */
.wh-labels-canvases {
    display: flex; flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: #525659;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}
.wh-labels-canvases[hidden] { display: none; }
.wh-labels-canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Preview-mode: hide selection controls/list, only show preview + footer. */
.wh-labels-modal__panel[data-mode="preview"] .wh-labels-modal__controls,
.wh-labels-modal__panel[data-mode="preview"] .wh-labels-modal__list {
    display: none;
}
.wh-labels-modal__panel[data-mode="preview"] .wh-labels-modal__preview {
    flex: 1 1 auto;
    min-height: 0;
    display: flex; flex-direction: column;
}
/* Desktop preview-mode: body becomes flex-column without padding so the
   iframe fills the entire body. */
@media (hover: hover) and (min-width: 1025px) {
    .wh-labels-modal__panel[data-mode="preview"] .wh-labels-modal__body {
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 0;
    }
}

.wh-labels-modal__footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e5e7eb;
}
.wh-btn-primary {
    background: #E6642E; color: #fff;
    border: 1px solid #E6642E;
}
.wh-btn-primary:hover { background: #cf5320; border-color: #cf5320; }
.wh-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.wh-btn-print {
    background: #fff; color: #1f2937;
    border: 1px solid #d1d5db;
}
.wh-btn-print:hover { background: #f3f4f6; }

.wh-btn-label {
    background: #fff; color: #1f2937;
    border: 1px solid #d1d5db;
}
.wh-btn-label:hover { background: #f3f4f6; }

.wh-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    flex: 0 0 auto;
}
.wh-icon svg { width: 18px; height: 18px; display: block; }
/* LABEL button: same outer width as ARCHIVE/ATTACH (18x18 reserved space),
   but the visible icon is rendered larger via overflow: visible.
   Net effect: bigger barcode glyph without changing the button box width. */
.wh-btn-label.wh-show-mobile { overflow: visible; }
.wh-btn-label .wh-icon {
    width: 18px; height: 18px;
    overflow: visible;
}
.wh-btn-label .wh-icon svg {
    width: 26px; height: 26px;
    /* Re-center the oversized SVG inside the 18x18 slot so it doesn't push
       siblings; (26 - 18) / 2 = 4px on each side. */
    margin: -4px;
}

/* Vertically center text in pallet-modal footer buttons.
   .btn is inline-block by default; in a flex row alongside icon buttons
   the baseline alignment makes text appear pushed up. Switching the buttons
   in this footer row to inline-flex with centered items fixes that. */
.wh-pallet-foot-row > .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* -------------------------------------------------------------------------
   Pallet modal — responsive button visibility (v=221)
   - Desktop & tablet (>600px): text-only buttons
   - Mobile portrait (<=600px portrait): icons for ARCHIVE/LABEL/ATTACH; no CLOSE
   - Mobile landscape (<=600px landscape): icons + CLOSE button visible
   ------------------------------------------------------------------------- */
/* Mobile detection covers BOTH portrait AND landscape phones:
   - Portrait: width <= 600px (typical phone in portrait)
   - Landscape: width <= 950px AND height <= 500px (typical phone in landscape)
   Tablet: 601 - 1024 px (or hover:none, no phone-size match)
   Desktop: hover:hover AND min-width 1025px. */
.wh-show-tablet-up           { display: inline-flex !important; }
.wh-show-mobile              { display: none !important; }
.wh-show-not-mobile-portrait { display: inline-flex !important; }
/* Default (desktop): hidden — only shown on tablet/mobile via overrides below. */
.wh-show-tablet-only         { display: none !important; }
.wh-show-not-desktop         { display: none !important; }

/* Tablet & mobile (anything that is NOT a hover-capable desktop ≥1025px). */
@media (hover: none), (max-width: 1024px) {
    .wh-show-tablet-only { display: inline-flex !important; }
    .wh-show-not-desktop { display: inline-flex !important; }
}

/* Phone (portrait OR landscape): swap text buttons for icons. */
@media (max-width: 600px), (max-width: 950px) and (max-height: 500px) {
    .wh-show-tablet-up   { display: none !important; }
    .wh-show-mobile      { display: inline-flex !important; }
    /* Tablet-only label hides on phones (mobile uses icon variant instead). */
    .wh-show-tablet-only { display: none !important; }
}
/* Phone portrait only: hide CLOSE. Detect both narrow viewport and tall-phone. */
@media (max-width: 600px) and (orientation: portrait) {
    .wh-show-not-mobile-portrait { display: none !important; }
}

/* HEIGHT/NOTE rows hidden when not in DB (display mode only).
   In edit mode, .wh-pallet-edit-show inputs force the row to remain visible. */
.wh-pallet-modal:not(.is-edit) .wh-pallet-meta-row.wh-meta-empty-hide {
    display: none !important;
}

body.wh-modal-open { overflow: hidden; }

/* Touch / tablet / mobile: panel fills the visible viewport so footer
   (CLOSE / CREATE → PRINT) stays visible without page-level scrolling.
   Use dvh (dynamic viewport height) so iOS Safari's address bar isn't
   counted as part of the panel — 100vh on iOS is *bigger* than the
   visible area and pushes the footer off-screen. Fall back to vh
   for browsers that don't support dvh. Matches the JS touch breakpoint
   (hover:none) or (max-width:1024px). */
/* Touch / tablet / mobile: shared rules (all viewports below 1025 or no-hover).
   Panel is fullscreen in PREVIEW mode (CLOSE+PRINT pinned at bottom).
   In SELECT mode the body grows the pallet list to fill the panel —
   no large empty white space between the pallet list and the footer. */
@media (hover: none), (max-width: 1024px) {
    /* Native iframe PDF is hidden on touch (we use PDF.js canvases). */
    .wh-labels-modal__panel[data-mode="preview"] #wh-labels-iframe,
    .wh-labels-modal__panel[data-mode="preview"] #wh-pallet-label-iframe {
        display: none !important;
    }
    /* SELECT-mode: list grows to fill the body so footer is right below. */
    .wh-labels-modal__body {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .wh-labels-modal__list {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
    }
    .wh-labels-canvases {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
    /* Preview-mode goes fullscreen so the canvases area + footer use the
       full viewport. */
    .wh-labels-modal__panel[data-mode="preview"] {
        position: fixed; inset: 0;
        margin: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .wh-labels-modal__panel[data-mode="preview"] .wh-labels-modal__body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 0;
    }
    .wh-labels-modal__panel[data-mode="preview"] .wh-labels-modal__preview {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .wh-labels-modal__panel[data-mode="preview"] .wh-labels-modal__footer {
        flex: 0 0 auto;
        padding: 10px 14px;
        background: #fff;
    }
}

/* Mobile only — select-mode also fullscreen so the keyboard/list don't
   leave gaps. (Was the original v=212 layout.) */
@media (max-width: 720px) {
    .wh-labels-modal {
        padding: 0;
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }
    .wh-labels-modal__panel {
        margin: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .wh-labels-modal__body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .wh-labels-modal__footer {
        flex: 0 0 auto;
        padding: 10px 14px;
        background: #fff;
    }
}

@media (max-width: 720px) {
    /* Mobile-specific compact tweaks (not duplicated above). */
    .wh-labels-modal__header { padding: 10px 14px; }
    .wh-labels-modal__header h2 { font-size: 15px; }
    .wh-labels-modal__body {
        padding: 10px 14px;
        gap: 8px;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: hidden;
        display: flex; flex-direction: column;
    }
    /* Keep ADD next to the input on mobile (was stacking full-width before). */
    .wh-labels-controls__row { flex-direction: row; align-items: flex-end; gap: 6px; }
    .wh-labels-controls__field { font-size: 11px; gap: 2px; }
    .wh-labels-controls__field input { padding: 6px 8px; font-size: 13px; }
    .wh-labels-controls__btn {
        width: auto;
        height: 32px;
        padding: 0 10px;
        font-size: 12px;
        flex: 0 0 auto;
    }
    /* ALL / NONE row: compact, side-by-side, with the counter pushed right. */
    .wh-labels-controls__row--actions { gap: 6px; }
    .wh-labels-controls__row--actions .wh-labels-controls__btn {
        flex: 0 0 auto;
        min-width: 56px;
        padding: 0 10px;
    }
    .wh-labels-counter { font-size: 12px; }
    /* List grows to fill the remaining vertical space — no fixed max-height
       so there's no large empty gap between list and footer. */
    .wh-labels-modal__list {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }
    .wh-labels-row { grid-template-columns: 24px 90px 1fr; padding: 5px 10px; font-size: 12px; }
    .wh-labels-modal__footer {
        padding: 10px 14px;
        background: #fff;
        flex: 0 0 auto;
    }
    /* Preview area shrinks on small screens; iframe is hidden via touch rule
       but OPEN PDF link + hint remain visible. */
    #wh-labels-iframe { height: 280px; }
    .wh-labels-preview__bar { padding: 6px 10px; flex-wrap: wrap; gap: 6px; }
    .wh-labels-preview__title { font-size: 11px; }
    .wh-labels-mobile-hint { padding: 6px 10px; font-size: 11px; }
}
