/*
  Plan canvas panel styles — KHÔNG scoped (global).
  Dùng chung cho YardCanvasHost và các component con tách ra (Layer Manager, Inspector, Dialog…).
  Blazor CSS isolation chỉ scope theo component; markup con không nhận YardCanvasHost.razor.css.
*/

.map-overlay {
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(195, 204, 214, 0.88);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    position: absolute;
    z-index: 3;
    pointer-events: auto;
}

/* CoPlanner/Layers dock phải cao hơn overlay chọn vùng (z=30). */
.plan-dock {
    z-index: 35;
}

.plan-dock-panel-stack {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.plan-dock-panel-layer {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.plan-dock-panel-layer.is-active {
    display: flex;
}

.chip {
    background: #eef5ff;
    border: 1px solid #8db9eb;
    border-radius: 999px;
    color: #174f86;
    cursor: pointer;
    min-height: 1.85rem;
    padding: 0.2rem 0.7rem;
}

.chip-secondary {
    background: #ffffff;
    border-color: #c3ccd6;
    color: #334155;
}

.hint {
    color: #586575;
    font-size: 0.9rem;
}

.map-empty-state,
.inspector-panel {
    padding: 0.75rem;
}

.plan-layer-manager {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    left: 1rem;
    max-height: calc(100% - 2rem);
    overflow: auto;
    top: 1rem;
    width: min(360px, calc(100% - 2rem));
}

.plan-layer-manager.is-docked {
    position: relative;
    inset: auto;
    top: auto;
    left: auto;
    width: 100%;
    max-height: none;
    height: 100%;
    overflow: auto;
    padding: 0.65rem 0.75rem;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.plan-layer-source {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-size: 0.72rem;
    line-height: 1.4;
    color: #475569;
}

.plan-layer-source strong {
    font-size: 0.74rem;
    color: #0f172a;
}

.plan-layer-source.is-live {
    border-color: #86efac;
    background: #f0fdf4;
}

.plan-layer-source.is-live strong {
    color: #166534;
}

.plan-layer-source.is-mock {
    border-color: #fcd34d;
    background: #fffbeb;
}

.plan-layer-source.is-mock strong {
    color: #92400e;
}

.plan-layer-source.is-loading,
.plan-layer-source.is-partial {
    border-color: #93c5fd;
    background: #eff6ff;
}

.plan-layer-source.is-loading strong,
.plan-layer-source.is-partial strong {
    color: #1d4ed8;
}

.plan-layer-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Header dock: ALL/ACTIVE/INACTIVE cạnh Refresh */
.plan-list-status-filter {
    flex: 0 0 auto;
    margin-right: 0.15rem;
}

.plan-list-status-filter .btn {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.1;
    min-height: 1.45rem;
    padding: 0.12rem 0.4rem;
}

.plan-layer-item-title-row {
    align-items: center;
    display: flex;
    gap: 0.35rem;
    min-width: 0;
}

.plan-layer-item-title-row strong {
    min-width: 0;
}

.plan-layer-item-title-row .plan-status-chip {
    flex: 0 0 auto;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    min-height: 1.15rem;
    padding: 0 0.35rem;
}

.plan-item-meta {
    align-items: center;
    color: #64748b;
    display: flex;
    font-size: 0.68rem;
    gap: 0.28rem;
    line-height: 1.15;
    min-width: 0;
}

.plan-item-meta-icon {
    color: #94a3b8;
    flex: 0 0 auto;
}

.plan-item-meta > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-item-expiry {
    color: #64748b;
    display: flex;
    font-size: 0.68rem;
    line-height: 1.15;
}

.plan-item-expiry.is-expired,
.plan-layer-item.is-expired .plan-item-expiry {
    color: #b91c1c;
    font-weight: 600;
}

.plan-item-expiry.is-expired .plan-item-meta-icon,
.plan-layer-item.is-expired .plan-item-expiry .plan-item-meta-icon {
    color: #b91c1c;
}

.plan-status-chip.is-inactive,
.plan-status-chip.is-expired {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.plan-status-chip.is-empty {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #64748b;
}

.plan-status-chip.is-muted {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #64748b;
}

.plan-layer-loading {
    align-items: stretch;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    min-height: 6rem;
    padding: 1rem 0.75rem;
}

.plan-layer-loading .empty-state {
    margin: 0;
    text-align: center;
}

/* Thanh chạy ngang indeterminate — dùng chung panel kế hoạch + bird view. */
.plan-indet-bar {
    position: relative;
    display: block;
    width: 100%;
    height: 3px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.plan-indet-bar--lg {
    height: 4px;
}

.plan-indet-bar-run {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40%;
    border-radius: inherit;
    background: linear-gradient(90deg, #60a5fa, #2563eb 55%, #1d4ed8);
    animation: plan-indet-slide 1.15s ease-in-out infinite;
}

@keyframes plan-indet-slide {
    0% {
        transform: translateX(-120%);
    }

    100% {
        transform: translateX(320%);
    }
}

.plan-dock-refresh {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    height: 1.65rem;
    justify-content: center;
    padding: 0;
    width: 1.65rem;
}

.plan-dock-refresh:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

.plan-dock-refresh:disabled {
    cursor: default;
    opacity: 0.55;
}

.plan-dock-refresh.is-busy {
    color: #2563eb;
}

.plan-dock-refresh.is-busy svg {
    opacity: 0.55;
}

.plan-layer-list {
    --plan-layer-indent: 1.2rem;
    --plan-layer-gap: 0.28rem;
    --plan-layer-card-pad: 0.35rem;
    /* Sát lề trái card hơn. */
    --plan-layer-lead-pad: 0.1rem;
    --plan-layer-lead-half: 0.525rem; /* nửa cột lead 1.05rem */
    --plan-layer-color-radius: 0.475rem; /* nửa chấm màu 0.95rem */
    /* Tâm cột màu/[+/-] từ mép trái card cha (cùng trục dọc connector). */
    --plan-layer-lead-center: calc(var(--plan-layer-lead-pad) + var(--plan-layer-lead-half));
    /* Tâm chấm màu từ mép trên padding-box card con. */
    --plan-layer-color-mid: calc(var(--plan-layer-card-pad) + var(--plan-layer-color-radius));
    /*
     * Kéo line lên đủ cao để chạm [-] cha:
     * gap + pad dưới card cha + gần hết chiều cao lead cha (màu + nút ≈ 2.15rem).
     */
    --plan-layer-bridge: calc(var(--plan-layer-gap) + var(--plan-layer-card-pad) + 2.15rem);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.plan-layer-item {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    margin-bottom: var(--plan-layer-gap);
    /* Thụt cả card con sang phải. */
    margin-left: calc(var(--plan-layer-depth, 0) * var(--plan-layer-indent));
    overflow: visible;
    padding: var(--plan-layer-card-pad) 0.4rem var(--plan-layer-card-pad) var(--plan-layer-lead-pad);
    position: relative;
}

.plan-layer-item:last-child {
    margin-bottom: 0;
}

.plan-layer-item.is-child {
    border-left-color: #c5d4e8;
}

.plan-layer-item.is-hidden {
    background: rgba(248, 250, 252, 0.94);
    opacity: 0.72;
}

.plan-layer-item.is-effective {
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.16);
}

.plan-layer-item-head {
    align-items: start;
    display: grid;
    gap: 0.3rem;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-width: 0;
}

.plan-layer-item:not(.has-item-actions) .plan-layer-item-head {
    grid-template-columns: auto minmax(0, 1fr);
}

/*
 * Connector chỉ trên item con — nét L liền (dọc + ngang), góc vuông.
 * Dùng nền solid 1px (không dotted) để tránh pha dash đứt giữa các đoạn.
 */
.plan-layer-tree-guides {
    bottom: 0;
    display: flex;
    flex-direction: row;
    left: calc(-1 * var(--plan-layer-depth, 1) * var(--plan-layer-indent));
    pointer-events: none;
    position: absolute;
    top: calc(-1 * var(--plan-layer-bridge));
    width: calc(var(--plan-layer-depth, 1) * var(--plan-layer-indent));
    z-index: 0;
}

.plan-layer-tree-rail {
    flex: 0 0 var(--plan-layer-indent);
    position: relative;
    width: var(--plan-layer-indent);
}

.plan-layer-tree-rail.is-blank {
    /* Tổ tiên là sibling cuối. */
}

.plan-layer-tree-rail.is-pipe::before,
.plan-layer-tree-rail.is-elbow::before,
.plan-layer-tree-rail.is-elbow-last::before {
    background: #94a3b8;
    content: "";
    left: calc(var(--plan-layer-lead-center) - 0.5px);
    position: absolute;
    top: 0;
    width: 1px;
}

/* Pipe / ├ : dọc xuyên xuống sibling kế (+2px chồng gap). */
.plan-layer-tree-rail.is-pipe::before,
.plan-layer-tree-rail.is-elbow::before {
    bottom: calc(-1 * var(--plan-layer-gap) - 2px);
}

/* └ : dọc một đoạn tới hàng ngang (+2px chồng góc). */
.plan-layer-tree-rail.is-elbow-last::before {
    height: calc(var(--plan-layer-bridge) + var(--plan-layer-color-mid) + 2px);
}

/* Ngang vào đúng tâm chấm màu — solid liền với dọc. */
.plan-layer-tree-rail.is-elbow::after,
.plan-layer-tree-rail.is-elbow-last::after {
    background: #94a3b8;
    content: "";
    height: 1px;
    left: calc(var(--plan-layer-lead-center) - 0.5px);
    position: absolute;
    top: calc(var(--plan-layer-bridge) + var(--plan-layer-color-mid));
    width: calc(
        var(--plan-layer-indent)
        - var(--plan-layer-lead-center)
        + var(--plan-layer-lead-pad)
        + var(--plan-layer-color-radius)
        + 0.5px
    );
    z-index: 3;
}

/* Cột trái: màu trên, [+/-] dưới — sát lề. */
.plan-layer-item-lead {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 0.22rem;
    justify-content: flex-start;
    margin: 0;
    min-width: 1.05rem;
    padding: 0;
    position: relative;
    z-index: 2;
}

.plan-layer-item-lead .layer-color {
    border: 1px solid #9aa7b5;
    border-radius: 50%;
    display: block;
    flex: 0 0 auto;
    height: 0.95rem;
    margin: 0;
    width: 0.95rem;
}

.plan-layer-collapse {
    align-items: center;
    background: #f1f5f9;
    border: 1px solid #94a3b8;
    border-radius: 3px;
    color: #1e293b;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 700;
    height: 0.95rem;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 0.95rem;
}

.plan-layer-collapse:hover,
.plan-layer-collapse.is-expanded {
    background: #e2e8f0;
    border-color: #64748b;
    color: #0f172a;
}

/* Bootstrap split button + dropdown — gọn. */
.plan-layer-btn-group {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    position: relative;
}

.plan-layer-btn-group > .btn,
.plan-layer-btn-group > .btn-group > .btn {
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
    padding: 0.18rem 0.4rem;
    white-space: nowrap;
}

.plan-layer-btn-group .dropdown-toggle-split {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

/* Menu fixed (portal trong panel) — tránh bị .plan-dock / overflow:auto cắt. */
.plan-layer-actions-menu {
    position: fixed;
    min-width: 9.5rem;
    padding: 0.25rem 0;
    margin: 0;
    z-index: 2000;
}

.plan-layer-actions-menu .dropdown-item {
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
}

.plan-layer-actions-menu .dropdown-item.text-danger {
    color: #b91c1c;
}

.plan-layer-item-text {
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    padding-top: 0;
}

.plan-layer-item-text strong,
.plan-layer-item-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tiêu đề ngang hàng chấm màu (0.95rem). */
.plan-layer-item-text strong {
    display: block;
    font-size: 0.82rem;
    line-height: 0.95rem;
    margin: 0;
}

.plan-layer-item-text small {
    color: #647386;
    line-height: 1.15;
}

/* Equips panel — actions riêng (không dùng btn-group). */
.plan-equ-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
    max-width: 9.5rem;
}

.plan-equ-action {
    font-size: 0.68rem;
    line-height: 1.2;
    min-height: 1.35rem;
    padding: 0.05rem 0.45rem;
}

.plan-layer-order {
    color: #647386;
    font-size: 0.74rem;
    font-weight: 700;
    min-width: 2rem;
    text-align: right;
}

.plan-layer-metrics {
    color: #647386;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.76rem;
}

.plan-status-chip {
    border: 1px solid #d6dee8;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    min-height: 1.45rem;
    padding: 0.05rem 0.45rem;
    background: #ffffff;
    color: #475569;
}

.plan-status-chip.is-active {
    background: #e8f1ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.plan-status-chip.is-draft {
    background: #fff7e6;
    border-color: #f7c97f;
    color: #9a6700;
}

.plan-status-chip.is-superseded,
.plan-status-chip.is-hidden {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #64748b;
}

.plan-status-chip.is-visible {
    background: #ecfdf5;
    border-color: #86efac;
    color: #15803d;
}

.plan-version-history {
    border-top: 1px dashed #d6dee8;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding-top: 0.45rem;
}

.plan-version-item {
    background: rgba(248, 250, 252, 0.94);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.45rem;
}

.plan-version-item.is-current {
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.14);
}

.plan-version-item.is-active {
    border-color: #93c5fd;
}

.plan-version-item.is-draft {
    border-color: #f7c97f;
}

.plan-version-item.is-superseded {
    opacity: 0.84;
}

.map-empty-state {
    bottom: 1rem;
    left: 1rem;
    max-width: min(320px, calc(100% - 2rem));
}

.design-properties-panel,
.design-placement-state {
    right: 12px;
    top: 12px;
    width: min(340px, calc(100% - 24px));
}

.design-properties-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: calc(100% - 24px);
    overflow: auto;
    padding: 0.75rem;
}

.design-placement-state {
    padding: 0.75rem;
}

.design-block-modal {
    max-width: min(980px, calc(100vw - 32px));
    width: 100%;
}

.design-form {
    gap: 0.75rem;
}

.design-editor-layout {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: minmax(0, 1.2fr) minmax(20rem, 1fr);
}

.design-preview-panel,
.design-form-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.design-preview-surface {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(238, 245, 255, 0.98)),
        linear-gradient(90deg, rgba(23, 79, 134, 0.04), rgba(23, 79, 134, 0.04));
    border: 1px solid #d6dee8;
    border-radius: 12px;
    min-height: 18rem;
    overflow: auto;
    padding: 0.75rem;
}

.design-preview-svg {
    display: block;
    height: auto;
    min-width: 100%;
    width: 100%;
}

.design-preview-title {
    fill: #174f86;
    font-size: 18px;
    font-weight: 700;
}

.design-preview-meta,
.design-preview-label {
    fill: #5c6c7b;
    font-size: 12px;
    font-weight: 600;
}

.design-preview-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.design-preview-hint {
    margin: 0;
}

.design-form-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: 1fr 1fr;
}

.design-form-grid label {
    color: #29313a;
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    gap: 0.25rem;
}

.design-form-grid input,
.design-form-grid select {
    border: 1px solid #b8c2cc;
    border-radius: 6px;
    min-height: 2rem;
    padding: 0.25rem 0.45rem;
}

.design-properties-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.design-schema-section {
    gap: 0.65rem;
}

.schema-mode-switch {
    display: flex;
    gap: 0.35rem;
}

.schema-columns {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: 1fr;
}

.schema-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    padding: 0.55rem;
}

.schema-card strong {
    display: block;
    margin-bottom: 0.45rem;
}

.schema-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 9.5rem;
    overflow: auto;
}

.schema-row {
    align-items: center;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: 4.2rem 1fr;
}

.schema-row span {
    color: #647386;
    font-size: 0.76rem;
    font-weight: 700;
}

.schema-row input {
    border: 1px solid #b8c2cc;
    border-radius: 6px;
    min-height: 1.9rem;
    padding: 0.2rem 0.45rem;
}

.status-pill {
    background: rgba(244, 247, 251, 0.96);
    border: 1px solid #d6dee8;
    border-radius: 999px;
    color: #475569;
    font-size: 0.76rem;
    padding: 0.18rem 0.55rem;
    white-space: nowrap;
}

.status-pill-text {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 720px) {
    .plan-layer-manager {
        left: 12px;
        max-height: min(40vh, 24rem);
        right: 12px;
        top: 12px;
        width: auto;
    }

    .design-editor-layout {
        grid-template-columns: 1fr;
    }

    .design-properties-panel,
    .design-placement-state {
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 12px;
        width: auto;
    }

    .design-properties-panel {
        max-height: 48vh;
    }

    .design-form-grid {
        grid-template-columns: 1fr;
    }
}

.inspector-panel {
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow: auto;
    right: 1rem;
    top: 1rem;
    width: min(320px, calc(100% - 2rem));
}

.inspector-header {
    align-items: flex-start;
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

.inspector-header h3,
.section-heading h4 {
    font-size: 0.92rem;
    margin: 0;
}

.selection-count-badge {
    background: #eef5ff;
    border: 1px solid #bfd6f2;
    border-radius: 999px;
    color: #174f86;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

.scan-mode-hint {
    margin: 0;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 0.78rem;
    line-height: 1.35;
}

.overlay-section,
.layer-list,
.group-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.section-heading span {
    color: #647386;
    font-size: 0.72rem;
}

.empty-state {
    color: #6a7685;
    margin: 0;
}

.group-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-left-width: 4px;
    border-radius: 8px;
    padding: 0.55rem;
}

.group-card header,
.plan-node header,
.layer-card header {
    align-items: center;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: auto 1fr auto;
}

.group-card header small,
.plan-node small {
    color: #647386;
    display: block;
}

.group-card header b {
    background: #f4f7fb;
    border-radius: 999px;
    color: #174f86;
    min-width: 2rem;
    padding: 0.1rem 0.4rem;
    text-align: center;
}

.group-metrics {
    color: #647386;
    display: flex;
    flex-direction: column;
    font-size: 0.76rem;
    gap: 0.15rem;
    margin-top: 0.35rem;
}

.group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}

.resolution-panel {
    gap: 0.65rem;
}

.resolution-summary-card,
.resolution-entry {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    padding: 0.6rem;
}

.resolution-summary-card header,
.resolution-entry header {
    align-items: center;
    display: flex;
    gap: 0.45rem;
    justify-content: space-between;
}

.resolution-summary-card p,
.resolution-entry p {
    color: #647386;
    font-size: 0.78rem;
    margin: 0.35rem 0 0;
}

.resolution-summary-metrics {
    color: #647386;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.76rem;
    margin-top: 0.45rem;
}

.resolution-trace-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.resolution-entry-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.resolution-entry-text strong,
.resolution-entry-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resolution-entry-text small {
    color: #647386;
}

.resolution-entry.is-effective {
    background: #eff6ff;
    border-color: rgba(37, 99, 235, 0.38);
}

.resolution-entry.is-hidden {
    border-style: dashed;
    opacity: 0.72;
}

.resolution-entry.is-conflict {
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.18);
}

.add-plan-button,
.add-overlap-button,
.view-slots-button {
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    min-height: 1.75rem;
    padding: 0.15rem 0.55rem;
}

.add-plan-button {
    background: #174f86;
    color: #ffffff;
}

.add-overlap-button {
    background: #6f42c1;
    color: #ffffff;
}

.view-slots-button {
    background: #ffffff;
    border: 1px solid #8db9eb;
    color: #174f86;
}

.plan-tree {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.plan-tree-divider {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px dashed rgba(195, 204, 214, 0.88);
}

.plan-node,
.layer-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    padding: 0.55rem;
}

.child-plan-node {
    margin: 0.5rem 0 0 1rem;
}

.overlap-plan-node {
    border-left: 4px solid #6f42c1;
}

.plan-node-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.plan-node-text strong,
.plan-node-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-node-meta {
    color: #647386;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.76rem;
    margin-top: 0.4rem;
}

.plan-node-status {
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    white-space: nowrap;
}

.plan-node-status.is-effective {
    background: #dbeafe;
    color: #1d4ed8;
}

.plan-node-status.is-visible {
    background: #eef5ff;
    color: #174f86;
}

.plan-node-status.is-hidden {
    background: #f1f5f9;
    color: #647386;
}

.compact-layer-list h4 {
    color: #29313a;
    font-size: 0.92rem;
}

.layer-card p {
    color: #647386;
    font-size: 0.76rem;
    margin: 0.25rem 0 0;
}

.active-layer {
    background: #fff8e1;
    border-color: #ffb300;
}

.layer-card.hidden-layer {
    border-style: dashed;
    opacity: 0.72;
}

.layer-color {
    border: 1px solid #9aa7b5;
    border-radius: 50%;
    display: inline-block;
    height: 0.9rem;
    width: 0.9rem;
}

.modal-backdrop {
    align-items: center;
    background: rgba(17, 24, 39, 0.42);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1rem;
    position: fixed;
    z-index: 20;
}

.capability-hint {
    color: #0f766e;
    font-size: 0.8rem;
    margin: 0.35rem 0 0;
}

.area-assign-grid {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: 1fr 1fr;
}

.area-assign-modal {
    max-width: 520px;
}

.area-assign-modal .link-button {
    align-self: flex-start;
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0;
    text-align: left;
}

.area-assign-modal .link-button:hover {
    text-decoration: underline;
}

.inquiry-modal {
    max-width: 560px;
}

.inquiry-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 12rem;
    overflow: auto;
}

.inquiry-hit {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.4rem 0.55rem;
    text-align: left;
}

.inquiry-hit.is-active {
    background: #ecfdf5;
    border-color: #0f766e;
}

.inquiry-shift {
    font-size: 0.8rem;
    margin: 0;
    padding-left: 1.1rem;
}

.plan-modal {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(17, 24, 39, 0.28);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-height: calc(100vh - 2rem);
    max-width: 720px;
    overflow: auto;
    padding: 1rem;
    width: min(720px, 100%);
}

.plan-modal.plan-add-slim {
    display: grid;
    gap: 0;
    grid-template-columns: minmax(280px, 1fr) minmax(0, 1.4fr);
    max-height: min(92vh, 680px);
    max-width: 980px;
    min-height: min(72vh, 560px);
    overflow: hidden;
    padding: 0;
    width: min(980px, 100%);
}

.plan-add-slim-content {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 0;
    min-width: 0;
    overflow: auto;
    padding: 0.85rem 1rem 0.9rem;
}

.plan-add-slim-header {
    align-items: flex-start;
    display: flex;
    flex-shrink: 0;
    gap: 0.75rem;
    justify-content: space-between;
}

.plan-add-slim-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.plan-add-slim-header h3 {
    margin: 0;
}

.selection-prose-compact {
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.plan-add-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.plan-add-tag {
    background: #eef3f8;
    border-radius: 999px;
    color: #3a4a5a;
    font-size: 0.78rem;
    padding: 0.2rem 0.55rem;
}

.plan-add-slim-main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 0;
    min-width: 0;
}

.plan-add-meta {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: 1.4fr 7.5rem;
    margin-top: 0;
}

.plan-add-meta label {
    color: #29313a;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    gap: 0.25rem;
}

.plan-add-meta input,
.plan-add-meta select {
    border: 1px solid #b8c2cc;
    border-radius: 4px;
    min-height: 2rem;
    padding: 0.25rem 0.45rem;
}

.plan-add-colors {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #29313a;
}

.plan-add-swatches {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.plan-add-swatch {
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    height: 1.55rem;
    padding: 0;
    width: 1.55rem;
}

.plan-add-swatch.is-selected {
    border-color: #111827;
    box-shadow: 0 0 0 2px #fff;
}

.plan-add-color-custom {
    border: 1px solid #b8c2cc;
    border-radius: 4px;
    height: 1.7rem;
    padding: 0;
    width: 2.2rem;
}

.plan-add-slim-side {
    background: #f6f8fb;
    border-right: 1px solid #d6dee8;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    height: 100%;
    max-height: none;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 0.75rem 0.65rem;
}

.plan-add-slim-side.has-ai {
    background: #eef8f1;
    border-color: #b7dcc4;
}

.plan-add-side-head {
    align-items: baseline;
    display: flex;
    flex-shrink: 0;
    gap: 0.4rem;
    justify-content: space-between;
}

.plan-add-side-head strong {
    color: #174f86;
    font-size: 0.82rem;
    line-height: 1.2;
}

.plan-add-slim-side.has-ai .plan-add-side-head strong {
    color: #1f6b3a;
}

.plan-add-side-head small {
    color: #6a7785;
    font-size: 0.7rem;
    white-space: nowrap;
}

.plan-add-side-add {
    border: 1px solid #b8c2cc;
    border-radius: 4px;
    flex-shrink: 0;
    min-height: 1.7rem;
    padding: 0.1rem 0.35rem;
    width: 100%;
}

.plan-add-side-error {
    flex-shrink: 0;
    font-size: 0.75rem;
    margin: 0;
}

.plan-add-side-composer {
    background: #fff;
    border-top: 1px solid #d8e0ea;
    flex-shrink: 0;
    margin: 0 -0.65rem -0.75rem;
    padding: 0.5rem 0.65rem 0.65rem;
    position: relative;
}

.plan-add-side-input {
    background: #f8fafc;
    border: 1px solid #cfd8e3;
    border-radius: 10px;
    color: #0f172a;
    font: inherit;
    font-size: 0.82rem;
    padding: 0.5rem 2.6rem 0.5rem 0.6rem;
    resize: none;
    width: 100%;
}

.plan-add-side-input:focus {
    background: #fff;
    border-color: #7aa2d6;
    outline: 2px solid rgba(13, 71, 161, 0.25);
}

.plan-add-side-input:disabled {
    opacity: 0.65;
}

.plan-add-side-send {
    background: #0d47a1;
    border: none;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(13, 71, 161, 0.18);
    color: #fff;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 700;
    height: 1.85rem;
    position: absolute;
    right: 0.95rem;
    top: 0.85rem;
    width: 1.85rem;
}

.plan-add-side-send:disabled {
    cursor: default;
    opacity: 0.45;
}

.plan-add-side-list {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.28rem;
    min-height: 0;
    overflow: auto;
    padding-right: 0.1rem;
}

.plan-add-side-row {
    align-items: center;
    background: #fff;
    border: 1px solid #e0e7ef;
    border-radius: 4px;
    display: grid;
    flex-shrink: 0;
    gap: 0.3rem;
    grid-template-columns: 4.6rem minmax(0, 1fr) 1.35rem;
    min-height: 1.65rem;
    padding: 0.12rem 0.28rem;
}

.plan-add-slim-side.has-ai .plan-add-side-row {
    border-color: #cfe8d6;
}

.plan-add-side-row strong {
    color: #174f86;
    font-size: 0.7rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-add-side-row input,
.plan-add-side-row select {
    border: 1px solid #b8c2cc;
    border-radius: 3px;
    min-height: 1.45rem;
    min-width: 0;
    padding: 0.05rem 0.3rem;
    width: 100%;
}

.plan-add-side-row .icon-button {
    height: 1.35rem;
    min-width: 1.35rem;
    padding: 0;
    width: 1.35rem;
}

.plan-add-slim-footer {
    align-items: center;
    border-top: 1px solid #e4ebf2;
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.55rem;
}

@media (max-width: 720px) {
    .plan-modal.plan-add-slim {
        grid-template-columns: 1fr;
        max-height: min(94vh, 760px);
        min-height: 0;
    }

    .plan-add-slim-side {
        border-bottom: 1px solid #d6dee8;
        border-right: none;
        max-height: 40vh;
    }
}

.plan-add-preview {
    align-items: center;
    color: #3a4a5a;
    display: inline-flex;
    font-size: 0.88rem;
    gap: 0.35rem;
}

.plan-add-slim-footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-left: auto;
}

.plan-modal header,
.plan-modal footer,
.criteria-title {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.plan-modal header p,
.criteria-title span {
    color: #647386;
    font-size: 0.85rem;
    margin: 0.2rem 0 0;
}

.modal-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr 8rem 6rem;
}

.modal-grid label {
    color: #29313a;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    gap: 0.25rem;
}

.modal-grid input,
.criteria-title select,
.criteria-row input {
    border: 1px solid #b8c2cc;
    border-radius: 4px;
    min-height: 2rem;
    padding: 0.25rem 0.45rem;
}

.criteria-row select {
    border: 1px solid #b8c2cc;
    border-radius: 4px;
    min-height: 2rem;
    padding: 0.25rem 0.45rem;
}

.criteria-panel {
    border: 1px solid #d6dee8;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.inherited-criteria {
    background: #f4f7fb;
}

.inherited-criteria p {
    color: #29313a;
    margin: 0;
}

.criteria-row {
    align-items: center;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 2.5rem 1fr 1fr auto;
}

.criteria-row strong {
    color: #174f86;
}

.criteria-row span {
    color: #29313a;
}

.selection-prose {
    color: #3a4654;
    line-height: 1.45;
    margin: 0.2rem 0 0;
    max-width: 36rem;
}

.selection-prose.is-loading {
    color: #6a7785;
    font-style: italic;
}

.selection-technical {
    margin-top: 0.35rem;
}

.selection-technical summary {
    color: #5a6a7a;
    cursor: pointer;
    font-size: 0.85rem;
}

.selection-technical p {
    color: #4a5560;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.8rem;
    margin: 0.25rem 0 0;
}

.criteria-mode-switch {
    display: inline-flex;
    gap: 0.25rem;
    background: #eef2f6;
    border-radius: 6px;
    padding: 0.2rem;
}

.criteria-mode-switch button {
    border: 0;
    background: transparent;
    border-radius: 4px;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    color: #3a4654;
}

.criteria-mode-switch button.is-active {
    background: #fff;
    color: #174f86;
    box-shadow: 0 0 0 1px #d0dae6;
}

.criteria-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.criteria-chip {
    background: #e8f1fb;
    border-radius: 999px;
    color: #174f86;
    font-size: 0.8rem;
    padding: 0.15rem 0.55rem;
}

.criteria-chip em {
    font-style: normal;
    font-weight: 600;
    margin-right: 0.25rem;
    opacity: 0.85;
}

.criteria-quick-add {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.criteria-chip-btn {
    align-items: baseline;
    background: #f4f7fb;
    border: 1px solid #d0dae6;
    border-radius: 6px;
    color: #174f86;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    font-size: 0.8rem;
    gap: 0.1rem;
    padding: 0.3rem 0.55rem;
    text-align: left;
}

.criteria-chip-btn small {
    color: #5a6a7a;
    font-size: 0.7rem;
}

.criteria-chip-btn:hover {
    background: #e8f1fb;
    border-color: #4f8cff;
}

.criteria-nl {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.criteria-nl textarea {
    border: 1px solid #b8c2cc;
    border-radius: 4px;
    min-height: 4.5rem;
    padding: 0.45rem 0.55rem;
    resize: vertical;
}

.icon-button {
    background: #f4f7fb;
    border: 1px solid #c3ccd6;
    border-radius: 4px;
    cursor: pointer;
    min-height: 2rem;
    min-width: 2rem;
}

.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.primary-button,
.secondary-button {
    border-radius: 4px;
    cursor: pointer;
    min-height: 2rem;
    padding: 0.25rem 0.85rem;
}

.primary-button {
    background: #174f86;
    border: 1px solid #174f86;
    color: #ffffff;
}

.secondary-button {
    background: #ffffff;
    border: 1px solid #b8c2cc;
    color: #29313a;
}

.danger-button {
    background: #fff5f5;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    color: #b91c1c;
    cursor: pointer;
    font-weight: 600;
    min-height: 2rem;
    padding: 0.25rem 0.85rem;
}

.danger-button:hover {
    background: #fee2e2;
    border-color: #f87171;
}

.plan-layer-delete {
    flex-shrink: 0;
    min-height: 1.35rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.68rem;
    line-height: 1.2;
}

.ai-review-banner {
    align-items: center;
    display: flex;
    gap: 0.9rem;
    justify-content: space-between;
}

.ai-review-banner p {
    color: #475569;
    margin: 0.2rem 0 0;
}

.ai-review-banner-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

@media (max-width: 1200px) {
    .inspector-panel {
        width: 300px;
    }
}

@media (max-width: 960px) {
    .panel-view {
        height: auto;
        min-height: 0;
    }

    .workspace-shell {
        min-height: calc(100vh - 8rem);
    }

    .map-empty-state,
    .inspector-panel {
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
    }

    .inspector-panel {
        bottom: 0.75rem;
        max-height: 44vh;
        top: auto;
    }

    .map-empty-state {
        bottom: 0.75rem;
        max-width: none;
    }

    .ai-review-banner {
        align-items: stretch;
        flex-direction: column;
    }

    .ai-review-banner-actions {
        width: 100%;
    }
}

@media (max-width: 720px) {
    .workspace-shell {
        min-height: calc(100vh - 7rem);
    }

    .pixi-host {
        min-height: 520px;
    }

    .toolbar-primary {
        align-items: stretch;
    }

    .toolbar-title {
        min-width: 0;
    }

    .toolbar-select {
        width: 100%;
    }

    .toolbar-select select {
        flex: 1;
        min-width: 0;
    }

    .modal-grid,
    .criteria-row {
        grid-template-columns: 1fr;
    }
}

.plan-equips-dock .equ-assign-bar.is-docked {
    flex: 1 1 auto;
    min-height: 0;
}

/* Panel Kế hoạch / Equips — master list / detail; flex chain để list cuộn khi tràn. */
.plan-plan-dock {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.plan-plan-dock.is-detail {
    background: #f7f9fc;
}

.plan-plan-dock .plan-layer-manager,
.plan-plan-dock .plan-editor-embed {
    flex: 1 1 auto;
    min-height: 0;
}

.plan-plan-dock .plan-layer-manager.is-docked {
    height: auto;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
}

.plan-equips-dock .overlay-section {
    min-height: min-content;
}

/* ALLOC Equips — cùng layout item với plan-layer-list. */
.cover-list {
    --plan-layer-indent: 0;
    --plan-layer-gap: 0.28rem;
}

.cover-list > .plan-layer-item {
    margin-left: 0;
}

/* —— Plan Editor embed (trong tab Kế hoạch detail) —— */
.plan-editor-embed {
    background: #f7f9fc;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.plan-editor-embed .plan-editor-identity {
    flex: 0 0 auto;
}

.plan-editor-embed .plan-editor-tabs {
    flex: 0 0 auto;
}

.plan-editor-embed .plan-editor-tab-panels {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.plan-editor-embed .plan-editor-identity-summary {
    flex: 0 0 auto;
}

.plan-editor-embed .plan-editor-criteria {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.plan-editor-embed .plan-editor-identity.is-tab-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.plan-editor-embed .plan-editor-foot {
    flex: 0 0 auto;
    border-top: 1px solid #e4ebf2;
}

.plan-editor-modal {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: min(92vh, 680px);
    max-width: 440px;
    overflow: hidden;
    padding: 0;
    width: min(440px, 100%);
}

.plan-editor-modal .plan-editor-tabs {
    flex: 0 0 auto;
}

.plan-editor-modal .plan-editor-tab-panels {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.plan-editor-modal .plan-editor-criteria {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.plan-editor-modal .plan-editor-identity.is-tab-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.plan-editor-modal-head {
    align-items: flex-start;
    border-bottom: 1px solid #e4ebf2;
    display: flex;
    gap: 0.55rem;
    justify-content: space-between;
    padding: 0.85rem 1rem;
}

.plan-editor-modal-head h3 {
    margin: 0;
}

.plan-editor-modal-head > div {
    flex: 1 1 auto;
    min-width: 0;
}

.plan-dock-bay-view {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    height: 1.7rem;
    justify-content: center;
    padding: 0;
    width: 1.7rem;
}

.plan-dock-bay-view:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

.plan-dock-bay-view:disabled {
    cursor: default;
    opacity: 0.45;
}

.plan-editor-color-picker,
.plan-dock-color-picker {
    flex: 0 0 auto;
}

.plan-editor-prose {
    margin: 0.45rem 0.75rem 0;
}

.plan-editor-tabs {
    background: #dbe3ee;
    border-bottom: 1px solid #c5ced8;
    display: flex;
    flex: 0 0 auto;
    gap: 0;
    min-height: 1.75rem;
}

.plan-editor-tab {
    align-items: center;
    background: transparent;
    border: 0;
    border-right: 1px solid #c5ced8;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    flex: 0 1 auto;
    font-size: 0.72rem;
    font-weight: 600;
    gap: 0.3rem;
    letter-spacing: 0.01em;
    max-width: 9rem;
    min-width: 0;
    overflow: hidden;
    padding: 0 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-editor-tab:hover {
    background: rgba(255, 255, 255, 0.45);
}

.plan-editor-tab.is-active {
    background: #fff;
    box-shadow: inset 0 1px 0 #fff;
    color: #0f172a;
}

.plan-editor-tab:focus-visible {
    outline: 2px solid #0d47a1;
    outline-offset: -2px;
}

.plan-editor-tab-count {
    background: #e2e8f0;
    border-radius: 999px;
    color: #475569;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1;
    min-width: 1rem;
    padding: 0.12rem 0.3rem;
    text-align: center;
}

.plan-editor-tab.is-active .plan-editor-tab-count {
    background: #dbeafe;
    color: #1d4ed8;
}

.plan-editor-identity-summary {
    align-items: center;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #e4ebf2;
    border-radius: 0;
    color: #64748b;
    cursor: pointer;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    font: inherit;
    font-size: 0.68rem;
    gap: 0.25rem;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
    padding: 0.35rem 0.65rem;
    text-align: left;
    white-space: nowrap;
    width: 100%;
}

.plan-editor-identity-summary:hover {
    background: #f8fafc;
    color: #475569;
}

.plan-editor-identity-summary-name {
    color: #334155;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-editor-identity-summary-sep {
    color: #cbd5e1;
    flex: 0 0 auto;
}

.plan-editor-identity {
    background: #fff;
    border-bottom: 1px solid #e4ebf2;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: minmax(0, 1.4fr) 5.5rem;
    min-width: 0;
    padding: 0.55rem 0.65rem;
}

.plan-editor-identity.is-tab-panel {
    align-content: start;
    border-bottom: 0;
}

.plan-editor-validity {
    display: grid;
    gap: 0.4rem;
    grid-column: 1 / -1;
    /* Stack dọc — datetime-local quá rộng nếu xếp ngang trong dock hẹp. */
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
}

.plan-editor-validity label {
    min-width: 0;
}

.plan-editor-validity input[type="datetime-local"] {
    box-sizing: border-box;
    font-size: 0.72rem;
    max-width: 100%;
    min-width: 0;
    padding: 0.15rem 0.25rem;
    width: 100%;
}

.plan-editor-identity label {
    color: #5b6b7c;
    display: flex;
    flex-direction: column;
    font-size: 0.72rem;
    font-weight: 550;
    gap: 0.22rem;
    min-width: 0;
}

.plan-editor-identity input,
.plan-editor-identity select,
.plan-editor-cr-row input,
.plan-editor-cr-row select {
    border: 1px solid #b8c2cc;
    border-radius: 5px;
    box-sizing: border-box;
    font: inherit;
    font-size: 0.82rem;
    max-width: 100%;
    min-height: 1.85rem;
    min-width: 0;
    padding: 0.2rem 0.4rem;
    width: 100%;
}

/* Dropdown giá trị có sẵn trong hàng tiêu chí (PTNR_CODE/POD/CARGO_TYPE...) — mũi tên tùy chỉnh
   thay vì chrome mặc định của OS, để đồng bộ với input text cạnh bên trong cùng 1 hàng. */
.plan-editor-cr-row select.plan-editor-cr-value-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position: calc(100% - 1.1rem) center, calc(100% - 0.7rem) center;
    background-repeat: no-repeat;
    background-size: 0.4rem 0.4rem, 0.4rem 0.4rem;
    cursor: pointer;
    overflow: hidden;
    padding-right: 1.6rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-editor-cr-row select.plan-editor-cr-value-select:hover {
    border-color: #94a3b8;
}

.plan-editor-cr-row select.plan-editor-cr-value-select:focus-visible {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    outline: none;
}

.plan-editor-cr-multi {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.55rem;
    max-height: 5.5rem;
    overflow-y: auto;
    padding: 0.15rem 0;
}

.plan-editor-cr-multi-item {
    align-items: center;
    color: #29313a;
    cursor: pointer;
    display: inline-flex;
    font-size: 0.72rem;
    gap: 0.22rem;
    line-height: 1.2;
    margin: 0;
    user-select: none;
    white-space: nowrap;
}

.plan-editor-cr-multi-item input {
    margin: 0;
}

.plan-editor-criteria {
    background: #f0f4f8;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 10rem;
    padding: 0.45rem 0 0.5rem;
}

.plan-editor-criteria.has-values {
    background: #eef8f1;
}

.plan-editor-cr-head {
    align-items: center;
    display: flex;
    gap: 0.45rem;
    justify-content: space-between;
    padding: 0 0.65rem;
}

.plan-editor-cr-head-text {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    min-width: 0;
}

.plan-editor-cr-head strong {
    font-size: 0.8rem;
}

.plan-editor-converge-hint {
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.35;
    margin: 0;
    padding: 0 0.65rem;
}

.plan-editor-converge-empty {
    color: #94a3b8;
    font-size: 0.72rem;
    margin: 0.35rem 0;
}

.plan-editor-converge-name {
    color: #475569;
    flex: 1 1 auto;
    font-size: 0.75rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-editor-cr-actions {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 0.3rem;
    justify-content: flex-end;
    line-height: 1;
}

.plan-editor-cr-dropdown {
    align-items: center;
    align-self: center;
    display: inline-flex;
    position: relative;
}

/* Portal menu (ngoài overflow criteria) — fixed theo viewport, giống .plan-layer-actions-menu. */
.plan-editor-cr-add-menu {
    position: fixed !important;
    inset: auto auto auto auto;
    margin: 0 !important;
    max-height: min(19rem, calc(100vh - 24px));
    min-width: 15.5rem;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.3rem;
    transform: none !important;
    z-index: 2000;
}

.plan-editor-cr-dropdown-item {
    align-items: center;
    border-radius: 4px;
    display: flex;
    gap: 0.6rem;
    line-height: 1.3;
    padding: 0.32rem 0.5rem;
    white-space: nowrap;
}

.plan-editor-cr-dropdown-item + .plan-editor-cr-dropdown-item {
    margin-top: 1px;
}

.plan-editor-cr-dropdown-item .fw-semibold {
    color: #17324d;
    flex: 0 0 5.6rem;
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-editor-cr-dropdown-item .text-muted {
    flex: 1 1 auto;
    font-size: 0.7rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-editor-cr-dropdown-item:hover,
.plan-editor-cr-dropdown-item:focus-visible {
    background: #eef2ff;
}

.plan-editor-cr-actions .btn-sm {
    align-items: center;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    padding: 0.2rem 0.55rem;
    vertical-align: middle;
}

.plan-editor-cr-actions .dropdown-toggle::after {
    margin-left: 0.35em;
    vertical-align: 0.1em;
}

.plan-editor-cr-list {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 0;
    overflow: auto;
    padding: 0.15rem 0.65rem;
}

.plan-editor-cr-row {
    align-items: center;
    background: #fff;
    border: 1px solid #e0e7ef;
    border-radius: 4px;
    display: grid;
    gap: 0.25rem;
    grid-template-columns: 4.6rem minmax(0, 1fr) 1.3rem;
    padding: 0.1rem 0.25rem;
}

.plan-editor-cr-row:has(.plan-editor-cr-multi) {
    align-items: start;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.plan-editor-cr-inherited {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.35rem;
    opacity: 0.78;
}

.plan-editor-cr-row.is-inherited {
    background: #f1f5f9;
    border-color: #d8e0ea;
    grid-template-columns: 4.6rem minmax(0, 1fr) auto;
    opacity: 0.85;
    pointer-events: none;
}

.plan-editor-cr-row.is-inherited strong {
    color: #64748b;
    font-weight: 600;
}

.plan-editor-cr-row.is-inherited input {
    background: #e8eef5;
    border-color: #cbd5e1;
    color: #64748b;
}

.plan-editor-cr-inherited-badge {
    color: #94a3b8;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0 0.2rem;
    white-space: nowrap;
}

.plan-editor-criteria.has-values .plan-editor-cr-row {
    border-color: #cfe8d6;
}

.plan-editor-cr-row strong {
    color: #174f86;
    font-size: 0.68rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-editor-cr-row input,
.plan-editor-cr-row select {
    min-height: 1.4rem;
    min-width: 0;
    width: 100%;
}

.plan-editor-cr-row .icon-button {
    height: 1.3rem;
    min-width: 1.3rem;
    padding: 0;
    width: 1.3rem;
}

.plan-editor-foot {
    align-items: center;
    background: #fff;
    border-top: 1px solid #e4ebf2;
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
    padding: 0.55rem 0.75rem;
}

.plan-editor-match {
    align-items: center;
    color: #5b6b7c;
    display: inline-flex;
    font-size: 0.8rem;
    gap: 0.3rem;
}

.plan-editor-match strong {
    color: #142033;
}

.plan-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-left: auto;
}

/* Split Lưu + dropdown "Lưu & kích hoạt" (dropup vì nằm footer). */
.plan-editor-save-group {
    position: relative;
}

.plan-editor-save-group > .btn {
    min-height: 2rem;
    padding: 0.25rem 0.85rem;
}

.plan-editor-save-group .plan-editor-save-split {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

.plan-editor-save-menu {
    font-size: 0.85rem;
    min-width: 10.5rem;
    z-index: 1050;
}

.plan-editor-save-menu .dropdown-item {
    padding: 0.35rem 0.75rem;
}

.bay-seq-modal {
    max-width: 880px;
    width: min(880px, 100%);
}

.bay-seq-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.bay-seq-toolbar select {
    margin-left: 0.35rem;
}

.bay-seq-error {
    color: #b91c1c;
}

.bay-seq-grid-wrap {
    max-height: min(52vh, 420px);
    overflow: auto;
}

.bay-seq-grid {
    border-collapse: collapse;
    font-size: 0.78rem;
}

.bay-seq-grid th,
.bay-seq-grid td {
    padding: 0.15rem;
    text-align: center;
}

.bay-seq-cell {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    min-height: 1.7rem;
    min-width: 1.7rem;
    padding: 0.15rem;
}

.bay-seq-cell.is-set {
    background: #dbeafe;
    color: #1e3a8a;
    font-weight: 700;
}

/* Legend tách kênh visual bird view: chọn (viền) / plan (fill) / TB (viền màu). */
.plan-coverage-legend {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(195, 204, 214, 0.9);
    border-radius: 8px;
    bottom: 4.75rem;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 0.85rem;
    left: 0.75rem;
    padding: 0.4rem 0.65rem;
    pointer-events: none;
    position: absolute;
    z-index: 4;
}

.plan-coverage-legend .pcl-item {
    align-items: center;
    color: #334155;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 600;
    gap: 0.3rem;
}

.plan-coverage-legend .pcl-swatch {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 3px;
    display: inline-block;
    height: 0.72rem;
    width: 0.95rem;
    box-sizing: border-box;
}

.plan-coverage-legend .pcl-swatch.is-none {
    background: #eef2f6;
}

.plan-coverage-legend .pcl-swatch.is-clean {
    background: #60a5fa;
}

.plan-coverage-legend .pcl-swatch.is-selection {
    background: repeating-linear-gradient(
        90deg,
        #e11d48 0 3px,
        transparent 3px 5px,
        #f59e0b 5px 8px,
        transparent 8px 10px);
    border: 1px dashed #e11d48;
    box-shadow: none;
}

.plan-coverage-legend .pcl-swatch.is-equ {
    background:
        linear-gradient(
            135deg,
            transparent 0 52%,
            #7c3aed 52% 55%,
            transparent 55% 62%,
            #7c3aed 62% 65%,
            transparent 65% 100%);
    border: 1px solid #cbd5e1;
}

.plan-coverage-legend .pcl-swatch.is-secondary {
    background: #fff;
    border: 1.5px dotted #2563eb;
    outline: 1.5px dotted #2563eb;
    outline-offset: 2px;
}

.plan-coverage-legend .pcl-swatch.is-conflict {
    background: repeating-linear-gradient(
        -45deg,
        #93c5fd 0 3px,
        #d97706 3px 5px);
}

.plan-coverage-legend .pcl-swatch.is-draft {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.35), #e2e8f0);
    border-style: dashed;
}

