* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f5f6fb;
  --sidebar-bg: #ffffff;
  --primary: #6366f1;
  --primary-soft: #eef2ff;
  --text: #1f2933;
    --muted: #000000;
  --backgroundcol: #d1a5ee;
}

body {
  font-family: Poppins, sans-serif;
  background: var(--bg);
}

/* SIDEBAR (SAME AS BEFORE) */
.sidebar {
  width: 250px;
  height: 100vh;
  background: var(--backgroundcol);
  position: fixed;
  left: 0;
  top: 0;
  padding: 16px;
  border-right: 1px solid #e5e7eb;
  transition: left 0.3s ease;
  z-index: 1000;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.brand-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex-grow: 1;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.brand-img {
  display: block;
  height: 40px;
  width: auto;
}

.brand-img-desktop { display: block; }
.brand-img-mobile { display: none; }

.brand h2 {
  font-size: 18px;
  color: var(--text);
}

.close-btn {
  background: none;
  border: none;
  font-size: 18px;
  display: none;
  cursor: pointer;
}

.menu {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s ease;
}

.menu-link i { font-size: 16px; }

.menu-link:hover,
.menu-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.menu-group .submenu {
  display: none;
  flex-direction: column;
  padding-left: 30px;
  gap: 4px;
  margin-top: 4px;
}

.menu-group.open .submenu { display: flex; }

.submenu-link {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 0;
}

.submenu-link:hover,
.submenu-link.active { color: var(--primary); }

/* TOPBAR + AVATAR ANIMATION (SAME AS BEFORE) */
.topbar {
  height: 60px;
  background: var(--backgroundcol);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  padding: 0 20px;
}

@media (min-width: 769px) {
  .topbar { margin-left: 250px; width: calc(100% - 250px); }
}

.hamburger {
  display: none;
  font-size: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.topbar-title {
  font-size: 14px;
  color: #6b7280;
  white-space: nowrap;
}

.topbar-title .current {
  color: #111827;
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.company-name {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}

.avatar-wrapper { position: relative; }

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(3px);
  position: relative;
  overflow: hidden;
}

.avatar-circle.multi-pulse {
  box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.8);
  animation: multiPulse 2s infinite;
}

.avatar-circle.multi-pulse::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    rgba(99, 102, 241, 0.7),
    rgba(96, 165, 250, 0.7),
    rgba(248, 113, 113, 0.7),
    rgba(34, 197, 94, 0.7),
    rgba(251, 191, 36, 0.7),
    rgba(99, 102, 241, 0.7)
  );
  animation: rotateGlow 3s linear infinite;
  border-radius: 50%;
  z-index: -1;
}

@keyframes multiPulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.8); }
  70% { box-shadow: 0 0 0 12px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

@keyframes rotateGlow {
  0% { transform: translate(-50%, -50%) rotate(0deg) scale(0.95); opacity: 0.9; }
  50% { opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(360deg) scale(1.05); opacity: 0.9; }
}

.avatar-circle.small {
  width: 28px;
  height: 28px;
  font-size: 13px;
  background: var(--primary);
  color: #fff;
}

.profile-popup {
  position: absolute;
  right: 0;
  top: 45px;
  width: 220px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  padding: 12px;
  display: none;
  z-index: 1001;
  animation: fadeIn 0.2s ease-out;
}

.profile-popup.open { display: block; }

.profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 10px;
}

.profile-info { font-size: 12px; }
.profile-name { font-weight: 600; color: #111827; margin: 0; }
.profile-email { color: #6b7280; margin: 0; }

.profile-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.profile-menu li a {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: #374151;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.profile-menu li a:hover {
  background: #f3f4ff;
  color: var(--primary);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* CONTENT WRAPPER */
.content-wrapper {
  padding: 80px 20px 24px;
  background: var(--bg);
  min-height: calc(100vh - 60px);
}

@media (min-width: 769px) {
  .content-wrapper { margin-left: 250px; }
}

.tree-page {
  max-width: 1280px;
  margin: 0 auto;
}

/* TREE HEADER */
.tree-header-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tree-header-text h2 {
  font-size: 18px;
  color: #111827;
  margin-bottom: 4px;
}

.tree-header-text p {
  font-size: 13px;
  color: #6b7280;
}

.tree-select-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.tree-select-label {
  font-size: 12px;
  color: #6b7280;
}

.tree-select-wrap select {
  min-width: 180px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 13px;
}

/* TREE CARD - Y-SCROLL ONLY */
.tree-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
  height: calc(100vh - 220px);
  display: flex;
  flex-direction: column;
}

.tree-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.tree-zoom-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: #f3f4ff;
  color: #4f46e5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Y-AXIS SCROLL ONLY - NO HORIZONTAL SCROLL */
.tree-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: #f3f4ff;
  border-radius: 14px;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

.tree-scroll-container::-webkit-scrollbar {
  width: 6px;
}

.tree-scroll-container::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.tree-scroll-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.tree-scroll-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.tree-canvas {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-height: 100%;
  transform-origin: center center;
  transition: transform 0.25s ease;
  max-width: 100%;
  width: auto;
}

/* TREE STRUCTURE */
.tree-node-root {
  display: flex;
  justify-content: center;
  width: 100%;
}

.tree-user-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
  min-width: 220px;
  max-width: 240px;
  text-align: left;
}

.tree-user-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.tree-user-email {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 8px;
}

.tree-user-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}

.tree-user-stats .pp { color: #16a34a; }
.tree-user-stats .pairs { color: #ef4444; }
.tree-user-stats .lr { color: #6b7280; }

.tree-level-connect {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 60px;
  margin: 16px 0;
  flex-wrap: nowrap;
}

.tree-level-connect.wide {
  gap: 40px;
}

.tree-level-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #ef4444;
  font-weight: 500;
}

/* TREE LEVELS */
.first-level {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 260px));
  justify-content: center;
  gap: 50px 60px;
  width: 100%;
}

.second-level {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 240px));
  justify-content: center;
  gap: 30px 35px;
  width: 100%;
}

.third-level {
  display: grid;
  grid-template-columns: repeat(5, minmax(200px, 220px));
  justify-content: center;
  gap: 25px 30px;
  width: 100%;
}

.tree-avatar-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e5e7eb, #d1d5db);
  margin: 0 auto 8px;
}

.tree-empty {
  background: #f9fafb;
  text-align: center;
  padding: 20px 12px;
}

.tree-empty-text-title {
  font-size: 13px;
  color: #111827;
  margin-bottom: 2px;
}

.tree-empty-text-sub {
  font-size: 11px;
  color: #9ca3af;
}

.tree-user-active {
  position: relative;
  padding-top: 28px;
  text-align: center;
}

.tree-user-status-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.tree-user-status-badge.green { background: #10b981; }
.tree-user-status-badge.orange { background: #f59e0b; }

/* RESPONSIVE */
@media (max-width: 1024px) {
  .tree-header-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .tree-select-wrap { align-items: flex-start; }
  .first-level { gap: 40px 50px; }
  .second-level { gap: 25px 30px; }
  .third-level { gap: 20px 25px; }
}

@media (max-width: 768px) {
  .sidebar { left: -260px; }
  .sidebar.open { left: 0; }
  .hamburger { display: flex !important; }
  .close-btn { display: block; }
  .topbar { padding: 0 12px; }
  .content-wrapper { padding: 80px 12px 18px; margin-left: 0; }
  .tree-card { height: calc(100vh - 200px); padding: 16px; }
  .tree-scroll-container { padding: 16px; }
  .brand-img-desktop { display: none; }
  .brand-img-mobile { display: block; height: 32px; }
  .first-level,
  .second-level,
  .third-level { grid-template-columns: repeat(2, 1fr); gap: 20px; }
  .tree-level-connect { gap: 30px; flex-wrap: wrap; }
}

@media (max-width: 479px) {
  .company-name { display: none; }
  .topbar { padding: 0 10px; }
  .topbar-title { font-size: 13px; }
  .content-wrapper { padding: 75px 10px 15px; }
  .profile-popup { right: 0; width: 180px; }
  .tree-user-card { min-width: 180px; }
}
