/* =========================
   SIDEBAR
========================= */

#sidebar {
    width: var(--dh-sidebar-width, 240px);
    min-width: var(--dh-sidebar-width, 240px);     /* CRITICAL: Prevents sidebar from disappearing */
    height: 100vh;
    flex-shrink: 0;                               /* Double protection against shrinking */
    position: sticky;                             /* Keeps sidebar fixed while scrolling */
    top: 0;
    overflow: hidden;
}

.sidebar {
    width: 100%;
    height: 100vh;
    background: linear-gradient(
        180deg,
        #071226 0%,
        #020817 100%
    );
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,.05);
}

/* =========================
   LOGO
========================= */

.logo {
    padding: 14px 14px 0 14px;
    margin-bottom: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.logo-inner {
    display: contents;
}

.logo-img {
    width: 140px;
    max-width: 100%;
    height: auto;
    max-height: 38px;
    object-fit: contain;
    display: block;
}

/* =========================
   NAVIGATION
========================= */

.nav-menu {
    flex: 1;
    min-height: 0;
    padding: 0 10px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.16);
    border-radius: 4px;
}

.nav-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.26);
}

/* =========================
   NAV ITEM
========================= */

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 35px;
    padding: 0 12px;
    border-radius: 9px;
    color: #94A3B8;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all .16s ease;
    flex-shrink: 0;
    user-select: none;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,.05);
    color: #F1F5F9;
}

.nav-item:hover svg {
    color: #F1F5F9;
}

/* =========================
   ICONS
========================= */

.nav-item svg,
.nav-item i {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    color: #94A3B8;
    flex-shrink: 0;
    transition: color .16s ease;
}

/* =========================
   ACTIVE
========================= */

.nav-item.active {
    background: linear-gradient(
        90deg,
        rgba(37,99,235,.28) 0%,
        rgba(30,64,175,.20) 100%
    );
    color: #FFFFFF;
    font-weight: 600;
    border: 1px solid rgba(59,130,246,.35);
    box-shadow: 0 1px 3px rgba(0,0,0,.15), inset 0 1px 0 rgba(255,255,255,.08);
}

.nav-item.active svg {
    color: #38BDF8;
}

/* =========================
   SIDEBAR BOTTOM SECTION
========================= */

.sidebar-bottom {
    position: relative;
    flex-shrink: 0;
    padding: 8px 10px 10px 10px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    background: linear-gradient(
        180deg,
        rgba(7, 18, 38, 0.96) 0%,
        #020817 100%
    );
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 20;
}

.sidebar-firm-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.sidebar-firm-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.12);
}

.firm-card-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94A3B8;
    flex-shrink: 0;
}

.firm-card-icon svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

.firm-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.firm-card-name {
    font-size: 11px;
    font-weight: 700;
    color: #F8FAFC;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.firm-card-action {
    font-size: 10px;
    color: #64748B;
    font-weight: 500;
}

.firm-card-arrow {
    color: #64748B;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, color 0.15s ease;
}

.sidebar-firm-card:hover .firm-card-arrow {
    color: #94A3B8;
    transform: translateX(2px);
}

.firm-card-arrow svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.2;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 2px 6px;
}

.sidebar-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 2px 0;
}

.sidebar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94A3B8;
    font-size: 11px;
    font-weight: 500;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.6);
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.offline {
    background: #EF4444;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.6);
}

.sidebar-version {
    color: #64748B;
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* =========================
   COMPANY SWITCHER POPOVER
========================= */

.sidebar-firm-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 14px;
    right: 14px;
    background: #09152e;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.35);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(16px);
    animation: popoverFadeIn 0.16s ease-out;
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar-firm-popover.hidden {
    display: none !important;
}

.firm-popover-header {
    padding: 10px 14px 9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.firm-popover-title {
    font-size: 11px;
    font-weight: 700;
    color: #94A3B8;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.firm-popover-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.firm-popover-list {
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.firm-popover-list::-webkit-scrollbar {
    width: 4px;
}

.firm-popover-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.firm-popover-section-label {
    padding: 7px 10px 4px;
    font-size: 10px;
    font-weight: 700;
    color: #64748B;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.firm-popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    user-select: none;
}

.firm-popover-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
}

.firm-popover-item.active {
    background: rgba(37, 99, 235, 0.20);
    border-color: rgba(59, 130, 246, 0.35);
}

.firm-popover-check {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #38BDF8;
    font-size: 13px;
    font-weight: 700;
}

.firm-popover-check svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
    color: #38BDF8;
}

.firm-popover-check.empty {
    visibility: hidden;
}

.firm-popover-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.firm-popover-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #F1F5F9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}

.firm-popover-item.active .firm-popover-name {
    color: #FFFFFF;
    font-weight: 700;
}

.firm-popover-role {
    font-size: 11px;
    color: #94A3B8;
    font-weight: 500;
    text-transform: capitalize;
}

.firm-popover-item.active .firm-popover-role {
    color: #60A5FA;
}