﻿/* ======================================================
   BADGES
====================================================== */

.tree-badge {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

    .tree-badge.subtle {
        background: #f1f5f9;
        color: #475569;
    }

    .tree-badge.unit {
        background: #eef2f7;
        color: #475569;
    }

    .tree-badge.tenant {
        background: #e7f8ed;
        color: #15803d;
    }

    .tree-badge.contract {
        background: #fff1d6;
        color: #92400e;
        font-weight: 700;
    }

    .tree-badge.section {
        background: #f3f4f6;
        color: #4b5563;
    }

    .tree-badge.active {
        background: #dcfce7;
        color: #166534;
    }

/* ======================================================
   UNIT LINE
====================================================== */

.tree-unit-line {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.tree-unit-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.tree-unit-meta {
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.tree-unit-tenant {
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* ======================================================
   PILLS
====================================================== */

.tree-pill {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1;
    font-weight: 800;
    white-space: nowrap;
}

    .tree-pill.success {
        background: #dcfce7;
        color: #166534;
    }

    .tree-pill.danger {
        background: #fee2e2;
        color: #b91c1c;
    }

    .tree-pill.neutral {
        background: #e5e7eb;
        color: #4b5563;
    }

/* ======================================================
   SUMMARY
====================================================== */

.tree-summary {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #526277;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
}

/* ======================================================
   RESPONSIVE
====================================================== */

@media (max-width: 900px) {
    .tree-unit-main {
        gap: 6px;
    }
}
/* ======================================================
   SECTION NODES
====================================================== */

.tree-section-line {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.tree-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}
.tree-context-menu {
    position: fixed;
    z-index: 5000;
    min-width: 220px;
    background: #fff;
    border: 1px solid #d9e2ef;
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(18, 38, 63, 0.18);
    padding: 6px;
}

    .tree-context-menu.is-hidden {
        display: none;
    }

.tree-context-menu-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    color: #1e2f4d;
}

    .tree-context-menu-item:hover {
        background: #eef4ff;
    }

.tree-context-menu-item-icon {
    width: 18px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: #56739a;
}

.tree-context-menu-item-title {
    flex: 1;
}

.tree-context-menu-empty {
    padding: 10px 12px;
    color: #6b7b93;
    font-size: 0.95rem;
}

.tree-context-menu-separator {
    height: 1px;
    margin: 4px 6px;
    background: #e3ebf5;
}

.tree-context-menu-item-chevron {
    color: #8aa0bf;
    font-size: 12px;
}

.tree-context-menu-item-check {
    color: #1d7a43;
    font-size: 16px;
    line-height: 1;
}

.tree-context-menu-item.is-back {
    font-weight: 700;
}

.node-details {
    position: static;
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.98) 100%);
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    max-height: calc(100vh - 108px);
    overflow-y: auto;
}

.node-editor {
    position: static;
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.98) 100%);
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

#node-details-panel.is-hidden,
#node-editor-panel.is-hidden {
    display: none;
}

.node-details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.node-details-eyebrow {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.node-details-title-block h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.1;
    color: #122443;
    letter-spacing: -0.03em;
}

.node-details-subtitle {
    margin-top: 8px;
    color: #475569;
    font-size: 13px;
    line-height: 1.45;
}

.node-details-status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.node-details-status.is-issued {
    background: #dbeafe;
    color: #1d4ed8;
}

.node-details-status.is-new {
    background: #ffedd5;
    color: #c2410c;
}

.node-details-status.is-returned {
    background: #dcfce7;
    color: #166534;
}

.node-details-status.is-broken {
    background: #fee2e2;
    color: #b91c1c;
}

.node-details-status.is-neutral {
    background: #e2e8f0;
    color: #334155;
}

.node-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 18px;
}

.node-detail-action {
    border: 1px solid #d7e3f4;
    background: #fff;
    color: #1f3356;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.node-detail-action:hover {
    background: #f8fbff;
    border-color: #bfd3f4;
    transform: translateY(-1px);
}

.node-detail-action.is-primary {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

.node-detail-action.is-primary:hover {
    background: #1e40af;
    border-color: #1e40af;
}

.node-detail-action.is-danger {
    color: #991b1b;
    border-color: #fecaca;
    background: #fff5f5;
}

.node-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0 0;
}

.node-detail-grid > div {
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e5edf6;
}

.node-detail-grid > div.is-wide {
    grid-column: 1 / -1;
}

.node-detail-grid dt {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}

.node-detail-grid dd {
    margin: 0;
    color: #122443;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.45;
}

.node-detail-grid--tenant {
    grid-template-columns: 1fr;
}

.node-detail-grid--tenant > div {
    min-width: 0;
}

.node-detail-grid--tenant dd {
    overflow-wrap: anywhere;
}

.node-details-section {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid #e5edf6;
    border-radius: 16px;
    background: #f8fafc;
}

.node-details-section h3 {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.node-details-section p {
    margin: 0;
    color: #122443;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.node-detail-sysinfo {
    margin-top: 16px;
    border: 1px solid #dbe7f6;
    border-radius: 16px;
    background: linear-gradient(180deg, #f8fbff 0%, #f6f9fd 100%);
    overflow: hidden;
}

.node-detail-sysinfo > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    color: #1f3356;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.node-detail-sysinfo > summary::-webkit-details-marker {
    display: none;
}

.node-detail-sysinfo-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: transform 0.15s ease;
}

.node-detail-sysinfo[open] .node-detail-sysinfo-toggle {
    transform: rotate(90deg);
}

.node-detail-sysinfo-body {
    padding: 0 14px 14px;
}

.node-detail-grid--sysinfo {
    margin-top: 0;
}

.node-detail-sysinfo .node-detail-grid dd {
    overflow-wrap: anywhere;
}

.node-detail-display.is-hidden,
.node-detail-edit-form.is-hidden {
    display: none;
}

.node-detail-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.node-detail-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.node-detail-field.is-wide {
    grid-column: 1 / -1;
}

.node-detail-field span {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}

.node-detail-field input,
.node-detail-field select,
.node-detail-field textarea {
    width: 100%;
    border: 1px solid #d6e2f2;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    color: #122443;
    background: #fff;
}

.node-detail-field input:disabled {
    background: #f8fafc;
    color: #64748b;
}

.node-detail-field textarea {
    resize: vertical;
    min-height: 92px;
}

.node-detail-edit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.node-detail-create-form {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #e5edf6;
}

.node-detail-helper {
    margin: 14px 0 0;
    color: #475569;
    font-size: 13px;
    line-height: 1.5;
}

.node-detail-toggle {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    width: 100%;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
    color: #122443;
}

    .node-detail-toggle > input {
        margin-top: 3px;
    }

    .node-detail-toggle > div,
    .node-detail-toggle > span {
        min-width: 0;
    }

    .node-detail-toggle strong,
    .node-detail-toggle span {
        display: block;
        text-transform: none;
        letter-spacing: 0;
        font-size: 14px;
        font-weight: 650;
        color: #122443;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

.node-empty,
.node-details-loading,
.node-details-error {
    padding: 18px 0 4px;
    color: #475569;
    line-height: 1.5;
}

@media (max-width: 900px) {
    .node-details {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .node-detail-grid {
        grid-template-columns: 1fr;
    }

    .node-detail-grid--tenant > div {
        grid-column: auto;
    }

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