/* ===== Box Picker popover ===== */

.bp {
    display: inline;
}

.bp-trigger {
    all: unset;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.bp-trigger.has-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

.bp-trigger.bp-empty {
    color: #2b8a3e;
}

.bp-trigger.has-value:hover {
    text-decoration: underline;
}

/* Backdrop */
.bp-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 20000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 120ms ease-out, visibility 0s linear 120ms;
}

.bp-backdrop.is-in {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 120ms ease-out;
}

/* Popover */
.bp-pop {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 620px;
    max-width: calc(100vw - 16px);
    height: min(600px, calc(100dvh - 16px));
    background: rgba(255, 255, 255, .99);
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(16, 24, 40, .14);
    z-index: 200001;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: 12px 0;
    --bp-col-template: 1.15fr 1.15fr 0.7fr;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    pointer-events: none;
    transition: opacity 140ms ease, transform 160ms cubic-bezier(.16, 1, .3, 1);
}

.bp-pop.is-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    will-change: transform, opacity;
}

.bp-pop.is-out {
    opacity: 0;
    transform: translateY(-4px) scale(.99);
    pointer-events: none;
}

/* Header */
.bp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    flex-shrink: 0;
}

.bp-title {
    font-weight: 700;
    font-size: 13px;
    color: #1f2937;
    letter-spacing: .02em;
}

.bp-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bp-clear {
    height: 26px;
    padding: 0 10px;
    border: 1px solid rgba(220, 53, 69, .3);
    background: rgba(220, 53, 69, .06);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #dc3545;
    transition: background 120ms, border-color 120ms;
}

.bp-clear:hover {
    background: rgba(220, 53, 69, .12);
    border-color: rgba(220, 53, 69, .5);
}

.bp-close {
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(0, 0, 0, .06);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5f6b7a;
    transition: background 120ms;
}

.bp-close:hover {
    background: rgba(0, 0, 0, .10);
}

/* Filters */
.bp-filters {
    padding: 10px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    flex-shrink: 0;
}

.bp-filter-cols {
    display: grid;
    grid-template-columns: var(--bp-col-template);
    gap: 4px;
}

.bp-input {
    width: 100%;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, .14);
    background: rgba(255, 255, 255, .95);
    font-size: 12px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 120ms;
}

.bp-input:focus {
    border-color: rgba(15, 88, 214, .45);
    box-shadow: 0 0 0 2px rgba(15, 88, 214, .10);
}

.bp-dim-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.bp-dim-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.bp-dim-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #9ca3af;
    padding-left: 1px;
}

.bp-dim-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
}

.bp-input-sm {
    min-width: 0;
    width: 100%;
}

@media (max-width: 700px) {
    .bp-dim-grid {
        grid-template-columns: 1fr;
    }
}

/* List header */
.bp-list-header {
    display: grid;
    grid-template-columns: var(--bp-col-template);
    gap: 4px;
    padding: 6px 14px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #5f6b7a;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    flex-shrink: 0;
}

/* Box list */
.bp-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 0;
}

.bp-empty {
    padding: 20px 14px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

/* Box row */
.bp-row {
    position: relative;
    padding: 0 14px;
    cursor: pointer;
    transition: background 100ms;
}

.bp-row:hover {
    background: rgba(15, 88, 214, .06);
}

.bp-row-main {
    display: grid;
    grid-template-columns: var(--bp-col-template);
    gap: 4px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
    align-items: baseline;
}

.bp-row:last-child .bp-row-main {
    border-bottom: none;
}

.bp-cell-text {
    font-size: 11px;
    color: #1f2937;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
}

.bp-cell-copyable {
    position: relative;
    padding-right: 20px;
}

.bp-copy-btn {
    all: unset;
    cursor: pointer;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 100ms, color 100ms, background 100ms;
}

.bp-row:hover .bp-copy-btn {
    opacity: 1;
}

.bp-copy-btn:hover {
    color: #005daa;
    background: rgba(15, 88, 214, .10);
}

.bp-copy-btn:active {
    transform: translateY(-50%) scale(.9);
}

.bp-copy-icon,
.bp-copy-check {
    width: 13px;
    height: 13px;
}

.bp-copy-check {
    display: none;
}

.bp-copy-btn.is-copied .bp-copy-icon {
    display: none;
}

.bp-copy-btn.is-copied .bp-copy-check {
    display: block;
    color: #22c55e;
}

/* Row tooltip data source – hidden; content is copied to a body-level .bp-tooltip by JS */
.bp-row-tooltip {
    display: none;
}

.bp-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px 10px 12px;
}

.bp-detail-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bp-detail-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 1px;
}

.bp-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #fff;
    gap: 6px;
}

.bp-detail-row span:first-child {
    color: rgba(255, 255, 255, 0.78);
}

.bp-detail-row span:last-child {
    font-weight: 600;
    text-align: right;
}

/* Tooltip – mouse-following detail card */
.bp-tooltip {
    position: fixed;
    z-index: 300000;
    display: none;
    opacity: 0;
    pointer-events: none;
    background: #005eb8;
    border: 1px solid rgba(0, 94, 184, 0.35);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .30);
    width: max-content;
    max-width: calc(100vw - 32px);
    transition: opacity 100ms ease;
    transform-origin: 14px 0;
    will-change: transform, opacity;
}

.bp-tooltip.is-in {
    animation: rhwo-tooltip-snap-in 220ms cubic-bezier(.22, 1, .36, 1) both;
}

/* ===== Box Status – trigger dot ===== */

.bp-trigger-text {
    vertical-align: middle;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bp-status-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex-shrink: 0;
}

.bp-status-text {
    font-size: 10px;
    color: #6b7280;
    letter-spacing: .01em;
    flex-shrink: 0;
}

.bp-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    vertical-align: middle;
    flex-shrink: 0;
}

.bp-status-dot.bp-st-notfound { background: #22d3ee; }
.bp-status-dot.bp-st-exists   { background: #a855f7; }
.bp-status-dot.bp-st-moved    { background: #ec4899; }
.bp-status-dot.bp-st-sent     { background: #eab308; }
.bp-status-dot.bp-st-packed   { background: #22c55e; }
.bp-status-dot.bp-st-ordered   { background: #f97316; }
.bp-status-dot.bp-st-delivered { background: #10b981; }

/* ===== Box Status – popup section ===== */

.bp-status-section {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    flex-shrink: 0;
}

.bp-status-label {
    display: block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #9ca3af;
    margin-bottom: 6px;
}

.bp-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.bp-status-pill {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.3;
    border: 1.5px solid transparent;
    transition: background 100ms, border-color 100ms, opacity 100ms;
    opacity: .55;
}

.bp-status-pill:hover {
    opacity: .85;
}

.bp-status-pill.is-active {
    opacity: 1;
}

/* Status variants use neutral styling in popup */
.bp-status-pill.bp-st-notfound,
.bp-status-pill.bp-st-exists,
.bp-status-pill.bp-st-moved,
.bp-status-pill.bp-st-sent,
.bp-status-pill.bp-st-packed,
.bp-status-pill.bp-st-ordered,
.bp-status-pill.bp-st-delivered {
    background: #eaf2ff;
    color: #0b2e66;
    border-color: rgba(0, 93, 170, .28);
}

.bp-status-pill.bp-st-notfound.is-active,
.bp-status-pill.bp-st-exists.is-active,
.bp-status-pill.bp-st-moved.is-active,
.bp-status-pill.bp-st-sent.is-active,
.bp-status-pill.bp-st-packed.is-active,
.bp-status-pill.bp-st-ordered.is-active,
.bp-status-pill.bp-st-delivered.is-active {
    background: #d7e7ff;
    color: #003b80;
    border-color: #005daa;
}

/* ===== Pallet Location Picker popover ===== */

/* ===== Create New Box ===== */

.bp-create-link-row {
    padding: 6px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    flex-shrink: 0;
}

.bp-create-link {
    all: unset;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #005daa;
    opacity: .7;
    transition: opacity 120ms;
}

.bp-create-link:hover {
    opacity: 1;
    text-decoration: underline;
}

.bp-create-form {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.bp-create-title {
    font-weight: 700;
    font-size: 12px;
    color: #1f2937;
    letter-spacing: .02em;
}

.bp-create-error {
    font-size: 11px;
    color: #dc3545;
    background: rgba(220, 53, 69, .06);
    border: 1px solid rgba(220, 53, 69, .2);
    border-radius: 6px;
    padding: 6px 10px;
    word-break: break-word;
}

.bp-create-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bp-create-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: .02em;
}

.bp-create-section-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #9ca3af;
    margin-top: 4px;
}

.bp-create-row3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.bp-create-optional {
    padding-top: 4px;
}

.bp-create-toggle-optional {
    all: unset;
    cursor: pointer;
    font-size: 10px;
    color: #6b7280;
    transition: color 100ms;
}

.bp-create-toggle-optional:hover {
    color: #374151;
}

.bp-create-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 4px;
}

.bp-create-cancel {
    all: unset;
    cursor: pointer;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 8px;
    transition: background 100ms;
}

.bp-create-cancel:hover {
    background: rgba(0, 0, 0, .04);
}

.bp-create-save {
    all: unset;
    cursor: pointer;
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #005daa;
    border-radius: 8px;
    transition: background 100ms, opacity 100ms;
}

.bp-create-save:hover:not(:disabled) {
    background: #004a8a;
}

.bp-create-save:disabled {
    opacity: .45;
    cursor: default;
}

/* ===== Pallet Location Picker popover (continued) ===== */

.plp {
    display: block;
    min-width: 0;
}

.plp-trigger {
    all: unset;
    cursor: pointer;
    font: inherit;
    color: inherit;
    box-sizing: border-box;
    width: 100%;
    min-height: 38px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 2px 6px;
    border-radius: 6px;
    overflow: hidden;
    transition: background-color 120ms ease, box-shadow 120ms ease;
}

.plp-trigger.plp-empty {
    color: #2b8a3e;
}

.plp-trigger.has-value {
    max-width: 100%;
}

.plp-trigger.has-value:hover {
    background: rgba(15, 88, 214, 0.06);
    box-shadow: inset 0 0 0 1px rgba(15, 88, 214, .12);
}

.plp-cell-main,
.plp-cell-sub {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.15;
}

.plp-cell-main {
    font-size: 12px;
    font-weight: 700;
    color: #162033;
}

.plp-cell-sub {
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
}

.plp-tooltip {
    position: fixed;
    z-index: 300000;
    display: none;
    opacity: 0;
    pointer-events: none;
    background: #005eb8;
    border: 1px solid rgba(0, 94, 184, 0.35);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .30);
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #fff;
    transition: opacity 100ms ease;
    transform-origin: 14px 0;
    will-change: transform, opacity;
}

.plp-tooltip.is-in {
    animation: rhwo-tooltip-snap-in 220ms cubic-bezier(.22, 1, .36, 1) both;
}

.plp-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 20000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 120ms ease-out, visibility 0s linear 120ms;
}

.plp-backdrop.is-in {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 120ms ease-out;
}

.plp-pop {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 760px;
    max-width: calc(100vw - 16px);
    height: min(650px, calc(100dvh - 16px));
    background: rgba(255, 255, 255, .99);
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(16, 24, 40, .14);
    z-index: 200001;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: 12px 0;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    pointer-events: none;
    transition: opacity 140ms ease, transform 160ms cubic-bezier(.16, 1, .3, 1);
}

.plp-pop.is-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    will-change: transform, opacity;
}

.plp-pop.is-out {
    opacity: 0;
    transform: translateY(-4px) scale(.99);
    pointer-events: none;
}

.plp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    flex-shrink: 0;
}

.plp-title {
    font-weight: 700;
    font-size: 13px;
    color: #1f2937;
    letter-spacing: .02em;
}

.plp-close {
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(0, 0, 0, .06);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5f6b7a;
    transition: background 120ms;
}

.plp-close:hover {
    background: rgba(0, 0, 0, .10);
}

.plp-content {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    background: linear-gradient(180deg, rgba(15, 88, 214, .03), rgba(255, 255, 255, 0) 46px);
}

.plp-map-pane {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 12px 12px 14px;
    border-right: 1px solid rgba(15, 23, 42, .08);
}

.plp-map-pane::-webkit-scrollbar,
.plp-pallet-pane::-webkit-scrollbar {
    width: 8px;
}

.plp-map-pane::-webkit-scrollbar-thumb,
.plp-pallet-pane::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, .22);
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 999px;
}

.plp-pallet-pane {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.plp-map-pane .seq-location-map {
    min-height: 0;
}

.plp-current-section {
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    background: linear-gradient(180deg, rgba(15, 88, 214, .04), rgba(255, 255, 255, 0));
    flex-shrink: 0;
}

.plp-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #5f6b7a;
    margin-bottom: 7px;
}

.plp-current-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: min(220px, 28dvh);
    overflow-y: auto;
    padding-right: 2px;
}

.plp-current-option {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid rgba(15, 88, 214, .16);
    border-radius: 9px;
    background: rgba(255, 255, 255, .92);
    color: #263247;
    cursor: pointer;
    font-size: 12px;
    font-weight: 650;
    transition: background-color 130ms ease, border-color 130ms ease, box-shadow 130ms ease, transform 130ms ease;
}

.plp-current-option:hover {
    background: rgba(15, 88, 214, .07);
    border-color: rgba(15, 88, 214, .28);
    transform: translateY(-1px);
}

.plp-current-option.is-selected {
    background: #e7f0ff;
    border-color: rgba(15, 88, 214, .42);
    box-shadow: 0 0 0 2px rgba(15, 88, 214, .10);
    color: #0f3b82;
}

.plp-current-option.is-selected:hover {
    background: #dceafe;
    border-color: rgba(15, 88, 214, .54);
}

.plp-current-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    border: 1px solid rgba(15, 88, 214, .35);
    background: #fff;
    flex-shrink: 0;
}

.plp-current-option.is-selected .plp-current-dot {
    background: #0f58d6;
    border-color: #0f58d6;
}

.plp-current-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plp-input-area {
    padding: 10px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(15, 88, 214, .03), rgba(255, 255, 255, 0));
}

.plp-help {
    font-size: 11px;
    line-height: 1.35;
    color: #5f6b7a;
}

.plp-filter {
    width: 100%;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(15, 88, 214, .18);
    background: rgba(255, 255, 255, .98);
    font-size: 12px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 120ms, box-shadow 120ms;
}

.plp-filter:focus {
    border-color: rgba(15, 88, 214, .45);
    box-shadow: 0 0 0 2px rgba(15, 88, 214, .10);
}

.plp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    border: 1px dashed rgba(15, 88, 214, .18);
    border-radius: 10px;
    background: rgba(15, 88, 214, .02);
}

.plp-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e0edff;
    color: #1a56db;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
}

.plp-chip-x {
    all: unset;
    cursor: pointer;
    font-size: 10px;
    color: #1a56db;
    opacity: .6;
    transition: opacity 100ms;
    line-height: 1;
}

.plp-chip-x:hover {
    opacity: 1;
}

.plp-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.plp-input {
    flex: 1;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(43, 138, 62, .24);
    background: rgba(255, 255, 255, .95);
    font-size: 12px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 120ms, box-shadow 120ms;
}

.plp-input:focus {
    border-color: rgba(43, 138, 62, .50);
    box-shadow: 0 0 0 2px rgba(43, 138, 62, .10);
}

.plp-add-btn {
    height: 30px;
    padding: 0 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(180deg, #2f9a45, #267d37);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms;
    flex-shrink: 0;
}

.plp-add-btn:hover {
    background: linear-gradient(180deg, #2aa140, #206a2f);
}

.plp-add-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.plp-list-header {
    padding: 6px 14px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #5f6b7a;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    flex-shrink: 0;
}

.plp-list {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 2px 0;
}

.plp-add-section {
    padding: 10px 14px 12px;
    border-top: 1px solid rgba(0, 0, 0, .06);
    background: linear-gradient(180deg, rgba(43, 138, 62, .03), rgba(255, 255, 255, 0));
    flex-shrink: 0;
}

.plp-add-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #5f6b7a;
    margin-bottom: 8px;
}

.plp-empty {
    padding: 20px 14px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

.plp-row {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    cursor: pointer;
    transition: background-color 90ms ease;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
}

.plp-row:last-child {
    border-bottom: none;
}

.plp-row:hover {
    background: rgba(15, 88, 214, .06);
}

.plp-row-selected {
    background: rgba(43, 138, 62, .06);
}

.plp-row-selected:hover {
    background: rgba(43, 138, 62, .10);
}

.plp-check {
    width: 16px;
    height: 16px;
    border: 1px solid rgba(55, 65, 81, .28);
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    flex-shrink: 0;
    color: #374151;
    background: #fff;
    position: relative;
}

.plp-row-selected .plp-check {
    border-color: rgba(43, 138, 62, .45);
    background: rgba(43, 138, 62, .12);
    color: #2b8a3e;
}

.plp-row-selected .plp-check::after {
    content: "";
    width: 4px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(42deg) translateY(-1px);
}

.plp-cell-text {
    font-size: 12px;
    line-height: 1.2;
    color: #1f2937;
}

.plp-footer {
    padding: 8px 14px;
    border-top: 1px solid rgba(0, 0, 0, .08);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, .98);
}

.plp-footer-summary {
    min-width: 0;
    margin-right: auto;
    color: #667085;
    font-size: 11px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plp-error {
    color: #b42318;
    background: #fff1f1;
    border: 1px solid rgba(180, 35, 24, .18);
    border-radius: 8px;
    padding: 6px 8px;
}

.plp-save-btn {
    height: 30px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    background: #0f58d6;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms;
}

.plp-save-btn:hover {
    background: #0c47b0;
}

.plp-pop.plp-mobile {
    border-radius: 14px;
    overflow: hidden;
    overscroll-behavior: contain;
}

.plp-pop.plp-mobile .plp-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(255, 255, 255, .98);
}

.plp-pop.plp-mobile .plp-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.plp-pop.plp-mobile .plp-map-pane {
    flex: 0 0 auto;
    overflow: visible;
    padding: 9px 12px 8px;
    border-right: none;
    border-bottom: 1px solid rgba(15, 23, 42, .08);
}

.plp-pop.plp-mobile .plp-map-pane .seq-location-map-stage {
    max-height: min(26dvh, 210px);
}

.plp-pop.plp-mobile .plp-map-pane .seq-location-map-fallback {
    min-height: 30px;
}

.plp-pop.plp-mobile .plp-pallet-pane {
    flex: 0 0 auto;
    overflow: visible;
}

.plp-pop.plp-mobile .plp-current-section {
    padding: 0;
    border-bottom: 0;
    background: transparent;
}

.plp-pop.plp-mobile .plp-current-list {
    max-height: min(22dvh, 108px);
}

.plp-pop.plp-mobile .plp-current-option {
    padding: 6px 9px;
    font-size: 11px;
}

.plp-pop.plp-mobile .plp-input-area {
    padding: 8px 12px;
    gap: 7px;
}

.plp-pop.plp-mobile .plp-help {
    display: none;
}

.plp-pop.plp-mobile .plp-list-header {
    padding: 6px 12px;
}

.plp-pop.plp-mobile .plp-list {
    flex: 0 0 auto;
    min-height: 160px;
    max-height: 44dvh;
    overflow-y: auto;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.plp-pop.plp-mobile .plp-row {
    padding: 5px 10px;
}

.plp-pop.plp-mobile .plp-add-section {
    flex: 0 1 auto;
    padding: 8px 12px 10px;
}

.plp-pop.plp-mobile .plp-chips {
    max-height: 74px;
    overflow-y: auto;
}

.plp-pop.plp-mobile .plp-footer {
    flex-shrink: 0;
    z-index: 2;
    background: rgba(255, 255, 255, .98);
}

@media (max-width: 420px) {
    .plp-pop.plp-mobile .plp-add-row {
        align-items: stretch;
    }

    .plp-pop.plp-mobile .plp-input,
    .plp-pop.plp-mobile .plp-add-btn {
        height: 34px;
    }
}

/* ===== Responsive popup scaling ===== */

.bp-pop {
    --bp-s: var(--rh-pop-scale, 1);
    width: min(calc(620px * var(--bp-s)), calc(100vw - 16px));
    height: min(calc(600px * var(--bp-s)), calc(100dvh - 16px));
    border-radius: calc(14px * var(--bp-s));
    font-size: max(10px, calc(12px * var(--bp-s)));
}

.bp-header,
.bp-filters,
.bp-status-section {
    padding-left: calc(14px * var(--bp-s));
    padding-right: calc(14px * var(--bp-s));
}

.bp-header {
    padding-top: calc(10px * var(--bp-s));
    padding-bottom: calc(8px * var(--bp-s));
}

.bp-title {
    font-size: max(10px, calc(13px * var(--bp-s)));
}

.bp-close,
.bp-clear {
    min-height: 28px;
    border-radius: calc(8px * var(--bp-s));
    font-size: max(10px, calc(12px * var(--bp-s)));
}

.bp-close {
    width: max(28px, calc(26px * var(--bp-s)));
    height: max(28px, calc(26px * var(--bp-s)));
}

.bp-filters {
    padding-top: calc(10px * var(--bp-s));
    padding-bottom: calc(8px * var(--bp-s));
    gap: calc(6px * var(--bp-s));
}

.bp-filter-cols,
.bp-list-header,
.bp-row-main {
    gap: calc(4px * var(--bp-s));
}

.bp-input,
.bp-name-input {
    height: max(28px, calc(30px * var(--bp-s)));
    padding: 0 calc(10px * var(--bp-s));
    border-radius: calc(8px * var(--bp-s));
    font-size: max(10px, calc(12px * var(--bp-s)));
}

.bp-list-header {
    padding: calc(6px * var(--bp-s)) calc(14px * var(--bp-s));
    font-size: max(9px, calc(10px * var(--bp-s)));
}

.bp-cell-text,
.bp-empty {
    font-size: max(10px, calc(11px * var(--bp-s)));
}

.bp-status-label,
.bp-dim-label,
.bp-create-section-label,
.bp-create-label {
    font-size: max(9px, calc(9px * var(--bp-s)));
}

.bp-status-row,
.bp-dim-grid,
.bp-create-fields,
.bp-create-actions {
    gap: calc(6px * var(--bp-s));
}

.bp-status-pill {
    padding: calc(3px * var(--bp-s)) calc(8px * var(--bp-s));
    border-radius: calc(6px * var(--bp-s));
    font-size: max(10px, calc(10px * var(--bp-s)));
}

.bp-create-link-row {
    padding: calc(6px * var(--bp-s)) calc(14px * var(--bp-s));
}

.bp-create-form {
    padding: calc(12px * var(--bp-s)) calc(14px * var(--bp-s)) calc(14px * var(--bp-s));
    gap: calc(8px * var(--bp-s));
}

.bp-create-title {
    font-size: max(10px, calc(12px * var(--bp-s)));
}

.bp-create-cancel,
.bp-create-save {
    min-height: 28px;
    padding: 0 calc(12px * var(--bp-s));
    border-radius: calc(8px * var(--bp-s));
    font-size: max(10px, calc(11px * var(--bp-s)));
}

.plp-pop {
    --plp-s: var(--rh-pop-scale, 1);
    --seq-s: var(--plp-s);
    width: min(calc(760px * var(--plp-s)), calc(100vw - 16px));
    height: min(calc(650px * var(--plp-s)), calc(100dvh - 16px));
    border-radius: calc(14px * var(--plp-s));
    font-size: max(10px, calc(12px * var(--plp-s)));
}

.plp-header {
    padding: calc(10px * var(--plp-s)) calc(14px * var(--plp-s)) calc(8px * var(--plp-s));
}

.plp-title {
    font-size: max(10px, calc(13px * var(--plp-s)));
}

.plp-close {
    width: max(28px, calc(26px * var(--plp-s)));
    height: max(28px, calc(26px * var(--plp-s)));
    border-radius: calc(8px * var(--plp-s));
    font-size: max(10px, calc(13px * var(--plp-s)));
}

.plp-content {
    grid-template-columns: calc(330px * var(--plp-s)) minmax(0, 1fr);
}

.plp-map-pane {
    padding: calc(10px * var(--plp-s)) calc(12px * var(--plp-s)) calc(12px * var(--plp-s)) calc(14px * var(--plp-s));
}

.plp-current-section,
.plp-input-area,
.plp-add-section {
    padding-left: calc(14px * var(--plp-s));
    padding-right: calc(14px * var(--plp-s));
}

.plp-current-section {
    padding-top: calc(10px * var(--plp-s));
    padding-bottom: calc(8px * var(--plp-s));
}

.plp-section-title,
.plp-list-header,
.plp-add-title {
    font-size: max(9px, calc(10px * var(--plp-s)));
}

.plp-current-list {
    gap: calc(6px * var(--plp-s));
    max-height: min(calc(220px * var(--plp-s)), calc(28dvh * var(--plp-s)));
}

.plp-current-option {
    min-height: 28px;
    padding: calc(6px * var(--plp-s)) calc(10px * var(--plp-s));
    border-radius: calc(9px * var(--plp-s));
    font-size: max(10px, calc(12px * var(--plp-s)));
}

.plp-current-dot {
    width: calc(7px * var(--plp-s));
    height: calc(7px * var(--plp-s));
}

.plp-input-area {
    padding-top: calc(10px * var(--plp-s));
    padding-bottom: calc(8px * var(--plp-s));
    gap: calc(10px * var(--plp-s));
}

.plp-help {
    font-size: max(9px, calc(11px * var(--plp-s)));
}

.plp-filter,
.plp-input,
.plp-add-btn {
    height: max(28px, calc(30px * var(--plp-s)));
    border-radius: calc(8px * var(--plp-s));
    font-size: max(10px, calc(12px * var(--plp-s)));
}

.plp-filter,
.plp-input {
    padding: 0 calc(10px * var(--plp-s));
}

.plp-add-btn {
    padding: 0 calc(12px * var(--plp-s));
}

.plp-chips {
    gap: calc(4px * var(--plp-s));
    padding: calc(8px * var(--plp-s));
    border-radius: calc(10px * var(--plp-s));
}

.plp-chip {
    padding: calc(2px * var(--plp-s)) calc(8px * var(--plp-s));
    border-radius: calc(6px * var(--plp-s));
    font-size: max(9px, calc(11px * var(--plp-s)));
    line-height: max(18px, calc(20px * var(--plp-s)));
}

.plp-list-header {
    padding: calc(6px * var(--plp-s)) calc(14px * var(--plp-s));
}

.plp-list {
    min-height: max(100px, calc(120px * var(--plp-s)));
}

.plp-row {
    min-height: 24px;
    gap: calc(6px * var(--plp-s));
    padding: calc(4px * var(--plp-s)) calc(12px * var(--plp-s));
}

.plp-check {
    width: calc(16px * var(--plp-s));
    height: calc(16px * var(--plp-s));
    font-size: max(9px, calc(10px * var(--plp-s)));
}

.plp-cell-text,
.plp-empty {
    font-size: max(10px, calc(12px * var(--plp-s)));
}

.plp-add-section {
    padding-top: calc(10px * var(--plp-s));
    padding-bottom: calc(12px * var(--plp-s));
}

.plp-footer {
    padding: calc(8px * var(--plp-s)) calc(14px * var(--plp-s));
    gap: calc(10px * var(--plp-s));
}

.plp-footer-summary {
    font-size: max(9px, calc(11px * var(--plp-s)));
}

.plp-save-btn {
    height: max(30px, calc(30px * var(--plp-s)));
    padding: 0 calc(20px * var(--plp-s));
    border-radius: calc(8px * var(--plp-s));
    font-size: max(10px, calc(12px * var(--plp-s)));
}

.plp-pop.plp-mobile .plp-map-pane .seq-location-map-stage {
    max-height: min(calc(26dvh * var(--plp-s)), calc(210px * var(--plp-s)));
}

.plp-pop.plp-mobile .plp-current-list {
    max-height: min(calc(22dvh * var(--plp-s)), calc(108px * var(--plp-s)));
}

.plp-pop.plp-mobile .plp-list {
    min-height: max(120px, calc(160px * var(--plp-s)));
    max-height: calc(44dvh * var(--plp-s));
}

.plp-pop.plp-mobile .plp-chips {
    max-height: calc(74px * var(--plp-s));
}

/* ===== Factory State Picker popover ===== */

.fsp {
    display: inline;
}

.fsp-trigger {
    all: unset;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.fsp-trigger.fsp-empty {
    color: #2b8a3e;
}

.fsp-trigger.has-value:hover {
    text-decoration: underline;
}

.fsp-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 20000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 120ms ease-out, visibility 0s linear 120ms;
}

.fsp-backdrop.is-in {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 120ms ease-out;
}

.fsp-pop {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 320px;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    box-sizing: border-box;
    background: rgba(255, 255, 255, .99);
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(16, 24, 40, .14);
    z-index: 200001;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: 12px 0;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    pointer-events: none;
    transition: opacity 140ms ease, transform 160ms cubic-bezier(.16, 1, .3, 1);
}

.fsp-pop.is-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    will-change: transform, opacity;
}

.fsp-pop.is-out {
    opacity: 0;
    transform: translateY(-4px) scale(.99);
    pointer-events: none;
}

.fsp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    flex-shrink: 0;
}

.fsp-title {
    font-weight: 700;
    font-size: 13px;
    color: #1f2937;
    letter-spacing: .02em;
}

.fsp-close {
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(0, 0, 0, .06);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5f6b7a;
    transition: background 120ms;
}

.fsp-close:hover {
    background: rgba(0, 0, 0, .10);
}

.fsp-list {
    padding: 4px 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.fsp-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background-color 90ms ease;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
}

.fsp-row:last-child {
    border-bottom: none;
}

.fsp-row:hover {
    background: rgba(15, 88, 214, .06);
}

.fsp-row-selected {
    background: rgba(15, 88, 214, .06);
}

.fsp-row-selected:hover {
    background: rgba(15, 88, 214, .10);
}

.fsp-check {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    color: #374151;
}

.fsp-row-selected .fsp-check {
    color: #0f58d6;
}

.fsp-cell-text {
    font-size: 12px;
    color: #1f2937;
}

.fsp-name-section {
    padding: 10px 14px;
    border-top: 1px solid rgba(0, 0, 0, .06);
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.fsp-name-label {
    font-size: 11px;
    font-weight: 600;
    color: #5f6b7a;
}

.fsp-required {
    color: #e03131;
}

.fsp-name-input {
    width: 100%;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, .14);
    background: rgba(255, 255, 255, .95);
    font-size: 12px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 120ms, box-shadow 120ms;
}

.fsp-name-input:focus {
    border-color: rgba(15, 88, 214, .45);
    box-shadow: 0 0 0 2px rgba(15, 88, 214, .10);
}

.fsp-info {
    padding: 6px 14px 8px;
    font-size: 10px;
    color: #6b7280;
    border-top: 1px solid rgba(0, 0, 0, .04);
    flex-shrink: 0;
}

.fsp-footer {
    padding: 8px 14px;
    border-top: 1px solid rgba(0, 0, 0, .08);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.fsp-save-btn {
    height: 30px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    background: #0f58d6;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms;
}

.fsp-save-btn:hover {
    background: #0c47b0;
}

.fsp-save-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.fsp-pop {
    --fsp-s: var(--rh-pop-scale, 1);
    width: min(calc(320px * var(--fsp-s)), calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    border-radius: calc(14px * var(--fsp-s));
    font-size: max(10px, calc(12px * var(--fsp-s)));
}

.fsp-header {
    padding: calc(10px * var(--fsp-s)) calc(14px * var(--fsp-s)) calc(8px * var(--fsp-s));
}

.fsp-title {
    font-size: max(10px, calc(13px * var(--fsp-s)));
}

.fsp-close {
    width: max(28px, calc(26px * var(--fsp-s)));
    height: max(28px, calc(26px * var(--fsp-s)));
    border-radius: calc(8px * var(--fsp-s));
    font-size: max(10px, calc(13px * var(--fsp-s)));
}

.fsp-list {
    padding: calc(4px * var(--fsp-s)) 0;
}

.fsp-row {
    min-height: 28px;
    gap: calc(8px * var(--fsp-s));
    padding: calc(8px * var(--fsp-s)) calc(14px * var(--fsp-s));
}

.fsp-check {
    font-size: max(10px, calc(14px * var(--fsp-s)));
}

.fsp-cell-text {
    font-size: max(10px, calc(12px * var(--fsp-s)));
}

.fsp-name-section {
    padding: calc(10px * var(--fsp-s)) calc(14px * var(--fsp-s));
    gap: calc(4px * var(--fsp-s));
}

.fsp-name-label {
    font-size: max(9px, calc(11px * var(--fsp-s)));
}

.fsp-name-input {
    height: max(28px, calc(30px * var(--fsp-s)));
    padding: 0 calc(10px * var(--fsp-s));
    border-radius: calc(8px * var(--fsp-s));
    font-size: max(10px, calc(12px * var(--fsp-s)));
}

.fsp-info {
    padding: calc(6px * var(--fsp-s)) calc(14px * var(--fsp-s)) calc(8px * var(--fsp-s));
    font-size: max(9px, calc(10px * var(--fsp-s)));
}

.fsp-error {
    color: #b42318;
    background: #fff1f1;
    border-color: rgba(180, 35, 24, .18);
}

.fsp-footer {
    padding: calc(8px * var(--fsp-s)) calc(14px * var(--fsp-s));
}

.fsp-save-btn {
    height: max(30px, calc(30px * var(--fsp-s)));
    padding: 0 calc(20px * var(--fsp-s));
    border-radius: calc(8px * var(--fsp-s));
    font-size: max(10px, calc(12px * var(--fsp-s)));
}
