:root {
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 44px;
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

.custom-body {
    padding-top: 3.5rem;
    /* your desired top spacing */
}

/* Only login page — does NOT touch other pages */
body.login-body {
    margin: 0 !important;
    padding: 0 !important;
    background: #f2f4f7;
    /* optional */
}

.layout {
    height: calc(100dvh - 3.5rem);
    /* fill remaining height under the navbar */
    display: flex;
    gap: 1rem;
    padding: 1rem;
    box-sizing: border-box;
    overflow: hidden;
}

/* LEFT = the scroll container */
.left-col {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    min-width: 0;
    /* allow shrinking on collapse */
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: .5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    transition: width .2s ease, flex-basis .2s ease;
}

/* Sticky top bar (title + pill + search + controls + chevron) */
.left-topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: 1fr auto;
    /* left column | chevron */
    grid-auto-rows: auto;
    gap: .5rem .5rem;
    align-items: center;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: .5rem .5rem;
}

.title-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.left-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #212529;
    flex: 0 1 auto;
    min-width: 0;
}

.pill {
    font-size: .75rem;
    line-height: 1.2;
    white-space: nowrap;
    padding: .15rem .4rem;
    border-radius: 999px;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 380px) {
    .pill {
        display: none;
    }
}

.left-search {
    grid-column: 1 / 3;
    /* span full width under title when expanded */
}

.left-search .input-group.input-group-sm .form-control {
    height: 32px;
    padding-top: 0;
    padding-bottom: 0;
}

/* NEW: tree controls row */
.tree-controls {
    grid-column: 1 / 3;
    display: flex;
    gap: .5rem;
    align-items: center;
}

.sidebar-toggle {
    border: none;
    background: transparent;
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: #333;
    justify-self: end;
}

.left-list {
    padding: .5rem .25rem 1rem .25rem;
}

/* Tree styles */
.tree {
    list-style: none;
    margin: 0;
    padding: 0 .25rem;
}

.tree-item {
    display: block;
    border-radius: .375rem;
    padding: .25rem .375rem;
    user-select: none;
}

.tree-item:hover {
    background: #eef2f6;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: .375rem;
    min-width: 0;
}

.twisty {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    flex: 0 0 24px;
    color: #6c757d;
}

.twisty:focus-visible {
    outline: 2px solid #74c0fc;
    border-radius: .25rem;
}

.tree-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}

/* Selected tree label highlight */
.tree-label.tree-click.is-selected {
    background: rgba(13, 110, 253, 0.12);
    /* bootstrap-ish blue tint */
    border-radius: 0.375rem;
    padding-right: 0.25rem;
    padding-left: 0.25rem;
}

.badge-level {
    font-size: .7rem;
    padding: .1rem .35rem;
}

.tree-group {
    margin: .125rem 0 .25rem 1rem;
    padding: 0 0 0 .75rem;
    border-left: 1px dashed #dee2e6;
}

.collapsed>.tree-group {
    display: none;
}

/* RIGHT */
.right-col {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.right-shell {
    border: 1px solid #e9ecef;
    border-radius: .5rem;
    background: #fff;
    box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.right-header {
    padding: 1rem 1rem .5rem;
    border-bottom: 1px solid #f1f3f5;
    flex: 0 0 auto;
}

.right-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Collapsed state */
.layout.is-collapsed .left-col {
    width: var(--sidebar-collapsed-w);
    flex-basis: var(--sidebar-collapsed-w);
}

.layout.is-collapsed .left-topbar {
    grid-template-columns: 1fr;
    height: 44px;
    padding: 0;
    place-items: center;
    border-bottom: none;
}

.layout.is-collapsed .left-title,
.layout.is-collapsed .pill,
.layout.is-collapsed .left-search,
.layout.is-collapsed .tree-controls,
.layout.is-collapsed .left-list {
    display: none !important;
}

.layout.is-collapsed .sidebar-toggle {
    justify-self: center;
}

/* Search highlight */
mark.tree-hit {
    background: #ffe066;
    padding: 0 .1rem;
    border-radius: .125rem;
}

.form_container {
    min-height: 550px;
    background: linear-gradient(#fff, #f8f9fa);
    border: 1px dashed #dee2e6;
    border-radius: .5rem;
}

#treeBreadcrumbs .breadcrumb {
  margin-bottom: 0;
}

#treeBreadcrumbs a.bc-link {
  text-decoration: none;
}
#treeBreadcrumbs a.bc-link:hover {
  text-decoration: underline;
}