:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --line: #e7e3dc;
  --line-soft: #f0ece6;
  --ink: #23211d;
  --ink-soft: #8f887e;
  --accent: #4f8a6b;
  --accent-soft: #eef4f0;
  --center: #2a2825;
  --ring2: #fdfcfa;
  --card: #ffffff;
  --av: 46px;
  --av-bd: 2px;
  --av-fs: 13px;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

/* ── 우측 하단 컨트롤 캡슐 ── */
/* 개발 환경에서만 쓰는 컨트롤이라 기본은 숨김.
   기본값을 flex로 두면 JS가 도달하기 전까지 배포본에서도 잠긐 보였다 사라진다. */
#floating-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 15;
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 30px;
  padding: 4px 8px;
  /* 표시 여부는 main.js 가 .show 로 결정한다 */
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1), 0 2px 6px rgba(0, 0, 0, 0.04);
}

#floating-controls.show {
  display: flex;
}

#tree-branch-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

#tree-branch-toggle input {
  cursor: pointer;
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
}

/* ── 우측 상단 플로팅 검색 및 액션 버튼 ── */
/* 노션에 임베드하면 노션이 블록 상단 우측에 자기 툴바(원본 열기·캐션·⋯)를 띄워서
   거기 버튼을 두면 가려진다. 노션 툴바·크기조절 핸들(하단 중앙·좁우 중앙)과
   모두 겹치지 않는 하단 좌측에 둔다. 우측 명단 패널과도 멀리 떨어진다. */
#floating-actions {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-fab {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
  transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
  flex: 0 0 40px;
}

.icon-fab:hover {
  transform: translateY(-2px);
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.icon-fab:active {
  transform: translateY(0);
}

.icon-fab svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 검색 컨테이너 ── */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrapper {
  display: flex;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.search-container.expanded .search-wrapper {
  width: 320px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  border-color: rgba(30, 91, 79, 0.4);
}

#btn-search-toggle {
  border: none;
  background: transparent;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #334155;
  flex: 0 0 40px;
  padding: 0;
  outline: none;
  transition: color 0.15s ease;
}

#btn-search-toggle:hover {
  color: #0f172a;
}

#btn-search-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-input-box {
  display: flex;
  align-items: center;
  flex: 1;
  height: 100%;
  padding-right: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.search-container.expanded .search-input-box {
  opacity: 1;
  pointer-events: auto;
}

#search-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: "Pretendard", sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  padding: 0 4px;
}

#search-input::placeholder {
  color: #94a3b8;
  font-weight: 500;
  font-size: 13px;
}

.search-clear {
  border: none;
  background: rgba(0, 0, 0, 0.06);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  color: #64748b;
  margin-left: 4px;
  flex: 0 0 20px;
  outline: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-clear:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #0f172a;
}

/* ── 실시간 검색 결과 드롭다운 (검색 바와 좌우 너비 100% 일치) ── */
.search-dropdown {
  display: none;
  position: absolute;
  /* 버튼이 화면 아래쪽에 있으므로 결과 목록은 위로 열린다 */
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  max-height: 420px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(0, 0, 0, 0.04);
  padding: 8px 6px;
  z-index: 50;
  animation: fadeIn 0.18s ease;
}

.search-section {
  margin-bottom: 10px;
}

.search-section:last-child {
  margin-bottom: 0;
}

.search-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px 4px;
  margin-bottom: 2px;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.13s ease, transform 0.13s ease;
  outline: none;
}

.search-item:hover, .search-item.focused {
  background: rgba(30, 91, 79, 0.08);
  transform: translateX(2px);
}

.search-item-icon {
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
}

.search-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  position: relative;
  border: 1.5px solid #1e5b4f;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef4f0;
  flex: 0 0 38px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.search-av-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
}

.search-av-init {
  font-size: 12.5px;
  font-weight: 700;
  color: #1e5b4f;
}

.search-item-info {
  flex: 1;
  min-width: 0;
}

.search-item-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-sub {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-role-tag {
  font-size: 10px;
  font-weight: 700;
  color: #1e5b4f;
  background: rgba(30, 91, 79, 0.09);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  display: inline-block;
  vertical-align: middle;
}

.search-count-tag {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-left: 6px;
  display: inline-block;
  vertical-align: middle;
}

.search-mark {
  background: rgba(254, 240, 138, 0.75);
  color: inherit;
  font-weight: inherit;
  border-radius: 2px;
  padding: 0;
}

.search-empty {
  padding: 24px 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

.search-empty-icon {
  display: inline-block;
  margin-bottom: 8px;
}

/* ── 인쇄(@media print) 스타일 ── */
@media print {
  @page { size: landscape; margin: 8mm; }
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; }
  #app-branding, #floating-controls, #floating-actions, #roster-pane, #person-modal, #roster-modal, #toast, #roster-backdrop { display: none !important; }
  #canvas-wrap { position: static !important; inset: auto !important; width: 100% !important; height: 100vh !important; }
  #donut-pane { position: static !important; inset: auto !important; width: 100% !important; height: 100% !important; }
  svg#chart { width: 100% !important; height: 100% !important; }
}

/* ── 토스트 알림 ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#canvas-wrap { position: absolute; inset: 0; top: 0; }
#donut-pane { position: absolute; inset: 0; }
svg { width: 100%; height: 100%; display: block; }

/* ── 얇고 모던한 스크롤바 ── */
.rp-inner, #roster-modal .sheet, .rm-body, .search-dropdown {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}
.rp-inner::-webkit-scrollbar, #roster-modal .sheet::-webkit-scrollbar, .rm-body::-webkit-scrollbar, .search-dropdown::-webkit-scrollbar {
  width: 4.5px;
  height: 4.5px;
}
.rp-inner::-webkit-scrollbar-track, #roster-modal .sheet::-webkit-scrollbar-track, .rm-body::-webkit-scrollbar-track, .search-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.rp-inner::-webkit-scrollbar-thumb, #roster-modal .sheet::-webkit-scrollbar-thumb, .rm-body::-webkit-scrollbar-thumb, .search-dropdown::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 9999px;
}
.rp-inner::-webkit-scrollbar-thumb:hover, #roster-modal .sheet::-webkit-scrollbar-thumb:hover, .rm-body::-webkit-scrollbar-thumb:hover, .search-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.7);
}

/* ── 모바일 백드롭 ── */
#roster-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
#roster-backdrop.show {
  display: block;
  opacity: 1;
}

/* ── 선택한 조직 상세 명단 박스 (데스크톱 플로팅) ── */
#roster-pane {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1), transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  width: min(480px, 36vw);
  min-width: 320px;
  /* 상단 버튼 3개(높이 40px + 위 여백 18px)와 붙지 않게 위아래 여백을 확보한다.
     세로 가운데 정렬이라 높이를 줄이면 위쪽 간격이 같이 벌어진다(상하 74px). */
  max-height: calc(100% - 148px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(220, 215, 206, 0.9);
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(35, 33, 29, 0.14), 0 2px 8px rgba(35, 33, 29, 0.04);
  overflow: hidden;
  z-index: 20;
}

#roster-pane.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(28px);
}
#roster-pane.dragging {
  transition: none;
}

.rp-drag-handle { display: none; }
.rp-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 6;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  z-index: 5;
}
.rp-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

.rp-inner {
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  /* 여기에 position:relative 를 주면 닫기(✕) 버튼이 내용과 같이 스크롤되서 사라진다.
     버튼은 패널에 붙어 있어야 해서 기준점을 #roster-pane 으로 둔다. */
}

/* 조직명 헤더는 스크롤 영역 밖에 고정으로 둔다.
   스크롤바도 자연스럽게 헤더 아래 명단 영역에서만 생긴다. */
#roster-pane header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 22px 46px 12px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
}

/* 명단 스크롤 영역 — 여기서만 스크롤바가 생긴다 */
.rp-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 24px 22px;
  box-sizing: border-box;
}

.rp-dot {
  width: 5px;
  height: 22px;
  border-radius: 4px;
  flex: 0 0 auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

#roster-pane h3 {
  font-size: 19px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ink);
}

.rp-role {
  font-size: 13.5px;
  color: #475569;
  font-weight: 500;
  line-height: 1.65;
  letter-spacing: -0.2px;
  margin: 0 0 20px 4px;
}

.rp-lead {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 22px 0;
  padding: 6px 10px;
  border-radius: 12px;
  transition: background 0.15s ease, transform 0.15s ease;
  user-select: none;
}

.rp-lead:hover {
  background: rgba(35, 33, 29, 0.05);
  transform: translateX(3px);
}

.rp-leadname {
  font-size: 16.5px;
  color: #0f172a;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.rp-headav {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  position: relative;
  border: 1.2px solid;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: 0 2px 6px rgba(35, 33, 29, 0.07);
  margin-left: 11px;
}

.rp-headav img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
}

.rp-headav.vacant {
  border-style: dashed !important;
  border-color: var(--line-strong, #b5b0a8) !important;
  background: rgba(0, 0, 0, 0.035);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.2px;
  box-shadow: none;
  margin-left: 11px;
}

.rp-corps {
  font-size: 11px;
  color: var(--ink-soft);
  margin: -4px 0 14px 47px;
}

.rp-team {
  border-top: 1px solid var(--line-soft);
  padding: 12px 0 10px;
  cursor: default;
  box-sizing: border-box;
  scroll-margin-top: 10px;
}

.rp-team.on {
  background: linear-gradient(90deg, rgba(35, 33, 29, 0.05), rgba(35, 33, 29, 0.015) 70%, transparent);
  margin: 0 -18px 0 -22px;
  padding: 12px 18px 10px 18.5px;
  border-radius: 0;
  border-left: 3.5px solid var(--ink, #1e293b);
}

.rp-team-label {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  letter-spacing: -0.3px;
}

.rp-team-label b {
  color: var(--ink-soft);
  margin-left: 8px;
  font-weight: 600;
  font-size: 13.5px;
}

.rp-team-label .none {
  color: var(--ink-soft);
  font-weight: 500;
  margin-left: 8px;
  font-size: 12px;
}

.rp-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 12px 6px;
}

.rp-person {
  width: 100%;
  margin: 0;
  text-align: center;
  cursor: pointer;
  padding: 4px 2px 6px;
  border-radius: 8px;
  transition: transform 0.14s ease, background 0.14s ease;
}

.rp-person:hover {
  transform: translateY(-2px);
  background: rgba(35, 33, 29, 0.045);
}

/* 사진 없는 사람은 이니셜로 나오는데, 조직 색을 그대로 쓰면 사진보다 눈에 띄어 시선을 빼앗는다 */
.rp-av.initials,
.rp-headav.initials {
  border-color: rgba(203, 213, 225, 0.9);
  background: #f4f5f7;
  color: #a0a7b4;
  font-weight: 600;
  box-shadow: none;
}

.rp-av {
  width: 48px;
  height: 48px;
  margin: 0 auto 5px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  border: 1.2px solid;
  box-sizing: border-box;
  box-shadow: 0 2px 6px rgba(35, 33, 29, 0.07);
  transition: box-shadow 0.14s ease, transform 0.14s ease;
}

.rp-person:hover .rp-av {
  box-shadow: 0 4px 12px rgba(35, 33, 29, 0.13);
}

.rp-av img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 22%;
}

.rp-person.head .rp-av {
  border-width: 1.8px;
  border-color: #7c5cd6 !important;
}

.rp-person figcaption {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #0f172a;
  line-height: 1.2;
}

.rp-rank {
  display: inline-block;
  font-size: 10px;
  color: #1e5b4f;
  background: rgba(30, 91, 79, 0.08);
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 3px;
  line-height: 1.25;
}

.rp-hint {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}

#roster-pane.empty {
  box-shadow: none;
  background: transparent;
  border-style: dashed;
}

.rp-note {
  font-size: 11px;
  color: #a8865a;
  font-weight: 600;
  line-height: 1.55;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.link {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.3px;
  stroke-linecap: round;
}

/* ── 트리 뷰 스타일 ── */
.t-link {
  fill: none;
  stroke: #c7c4bf;
  stroke-width: 3.2px;
}

.t-apex, .t-group, .t-dept {
  stroke: none;
  transition: fill 0.13s ease, filter 0.13s ease;
}

.t-apex { fill: #1e5b4f; }
.t-group { fill: #2e7263; }
.t-dept { fill: #1e5b4f; }

.t-apex.hovered, .t-dept.hovered {
  fill: #14443b;
  filter: brightness(1.18);
}

.t-group.hovered {
  fill: #225c4f;
  filter: brightness(1.18);
}

.t-apex-text {
  font-family: "Pretendard", sans-serif;
  font-size: 32px;
  font-weight: 700;
  fill: #fff;
  letter-spacing: -0.4px;
}

.t-group-text {
  font-family: "Pretendard", sans-serif;
  font-size: 27px;
  font-weight: 700;
  fill: #fff;
  letter-spacing: -0.3px;
}

.t-dept-text {
  font-family: "Pretendard", sans-serif;
  font-size: 26px;
  font-weight: 700;
  fill: #fff;
  letter-spacing: -0.3px;
}

.t-dept-count {
  font-family: "Pretendard", sans-serif;
  font-size: 19px;
  font-weight: 700;
  fill: rgba(255, 255, 255, 0.92);
}

.t-leaf {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 2px;
  transition: fill 0.13s ease, stroke 0.13s ease, filter 0.13s ease;
}

.t-leaf.hovered {
  fill: #f1f5f9;
  stroke: #1e5b4f;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.08));
}

.t-leaf-text {
  font-family: "Pretendard", sans-serif;
  font-size: 26px;
  font-weight: 700;
  fill: #0f172a;
  letter-spacing: -0.3px;
}

.t-count {
  font-family: "Pretendard", sans-serif;
  font-size: 16px;
  font-weight: 700;
  fill: #1e5b4f;
}

.t-count.zero {
  fill: #b9b6b1;
  font-weight: 500;
}

.t-note {
  font-size: 12.5px;
  fill: #a8865a;
  font-weight: 600;
}

.node-box {
  fill: var(--card);
  stroke: var(--line-soft);
  stroke-width: 1px;
}

.node-box.exec { fill: var(--accent); stroke: none; }
.node-box.center { fill: var(--center); stroke: none; }
.node-box.center.v2-center { fill: #6f42c1 !important; }
.node-box.center.v3-center { fill: #1e5b4f !important; }

.center-ring {
  fill: none;
  stroke: var(--center);
  stroke-width: 1.5px;
  stroke-opacity: 0.35;
  pointer-events: none;
}

.node-label {
  font-size: 12px;
  fill: var(--ink);
  font-weight: 600;
  letter-spacing: -0.1px;
}

.node-sub {
  font-size: 10px;
  fill: var(--ink-soft);
}

.node-label.on-exec { fill: #fff; }
.avatar { stroke: none; fill-opacity: 0.14; }
.avatar-text { font-size: 9px; font-weight: 700; text-anchor: middle; }
.av-photo { clip-path: circle(50%); }
.av-ring { fill: none; stroke-width: 2.2px; }
.av-ring.head { stroke-width: 2.8px; }
.av-name { font-size: 11px; font-weight: 700; fill: var(--ink); letter-spacing: -0.3px; }
.av-title { font-size: 9px; fill: var(--ink-soft); }

.roster-card {
  fill: var(--card);
  stroke: var(--line-soft);
  stroke-width: 1px;
  filter: drop-shadow(0 2px 10px rgba(35, 33, 29, 0.055));
}

.roster-title {
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
  letter-spacing: -0.2px;
}

.roster-sub {
  font-size: 10px;
  fill: var(--ink-soft);
  font-weight: 500;
  letter-spacing: -0.1px;
}

.roster-count {
  font-size: 11px;
  fill: var(--ink-soft);
  font-weight: 600;
}

.roster-count.big {
  fill: var(--ink);
  font-weight: 800;
}

.roster-more {
  font-size: 10px;
  fill: var(--ink-soft);
  font-weight: 600;
}

.person-name {
  font-size: 12px;
  fill: var(--ink);
  font-weight: 600;
  letter-spacing: -0.1px;
}

.person-title {
  font-size: 10px;
  fill: var(--ink-soft);
}

[data-cluster] {
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), filter 0.28s ease;
}

.v3-center {
  transition: transform 0.2s ease, filter 0.2s ease;
}

.v3-center:hover {
  filter: drop-shadow(0 4px 14px rgba(30, 91, 79, 0.4));
}

path.v3-l1-dan, path.v3-l2-team, path.v3-l2-container {
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s ease,
              stroke 0.15s ease, stroke-width 0.15s ease;
}

/* 가리킨 칩을 띄우는 호버 그림자.
   부서별 색을 쓰면 링 전체가 산만해져서 무채색으로 통일한다. */
path.v3-l1-dan:hover, path.v3-l2-team:hover {
  filter: drop-shadow(0 5px 14px rgba(15, 23, 42, 0.3)) drop-shadow(0 1px 3px rgba(15, 23, 42, 0.14));
}

.center-sub {
  font-size: 10.5px;
  font-weight: 600;
  fill: #fff;
  fill-opacity: 0.72;
  letter-spacing: 0.2px;
}

.unit-head {
  font-size: 9.5px;
  font-weight: 600;
  fill: #fff;
  fill-opacity: 0.78;
  pointer-events: none;
}

.center-label {
  font-size: 17px;
  font-weight: 700;
  fill: #fff;
  letter-spacing: 0.4px;
}

.ring-label {
  fill: var(--ink);
  pointer-events: none;
  letter-spacing: -0.1px;
}

.ring-label.on-exec { fill: #fff; }
.ring1-arc { stroke: var(--bg); stroke-width: 2.5px; }

/* ── 방사형(도넛) 우측 대형 한백 로고 (데스크톱 전용) ── */
#canvas-logo {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(480px, 36vw);
  min-width: 320px;
}

#canvas-logo.show {
  opacity: 1;
  transform: translateY(-50%);
}

#canvas-logo img {
  width: 340px;
  max-width: 90%;
  height: auto;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.08));
}

.v3-top-logo {
  transition: opacity 0.3s ease;
}

/* ── 프로필 상세 모달 ── */
#person-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

#person-modal .sheet {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 28px 30px 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22), 0 4px 14px rgba(0, 0, 0, 0.06);
  position: relative;
}

#person-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

#person-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

.pm-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.pm-av {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  position: relative;
  border: 3px solid;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: 0 4px 14px rgba(35, 33, 29, 0.12);
}

.pm-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
}

#person-modal h2 {
  font-size: 23px;
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #0f172a;
}

.pm-sub {
  font-size: 14px;
  color: #64748b;
  font-weight: 600;
}

#pm-axes {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  align-items: baseline;
}

#pm-axes dt {
  font-size: 13px;
  color: #64748b;
  font-weight: 700;
  white-space: nowrap;
}

#pm-axes dd {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.2px;
}

#pm-axes dd .sep {
  color: var(--line);
  margin: 0 6px;
  font-weight: 400;
}

.pm-note {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.6;
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

/* ── 트리 뷰 명단 모달 ── */
#roster-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

#roster-modal .sheet {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: 82vh;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2), 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#roster-modal .sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.95);
}

.sheet-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-head-dot {
  width: 5px;
  height: 22px;
  border-radius: 4px;
  flex: 0 0 auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

#roster-modal .sheet-head h2 {
  font-size: 19px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #0f172a;
}

#roster-modal .rm-count-tag {
  font-size: 12.5px;
  font-weight: 700;
  color: #1e5b4f;
  background: rgba(30, 91, 79, 0.08);
  padding: 2px 9px;
  border-radius: 12px;
  margin-left: 8px;
}

#roster-modal .sheet-head button {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

#roster-modal .sheet-head button:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

.rm-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  flex: 1;
  box-sizing: border-box;
}

.rm-people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 14px 8px;
}

.rm-section {
  margin-bottom: 20px;
}

.rm-section:last-child {
  margin-bottom: 0;
}

.rm-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rm-section-title b {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* 2단 계층 그룹핑 */
.rm-parent-group {
  background: rgba(248, 250, 252, 0.75);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 18px;
  padding: 16px 18px 18px;
  margin-bottom: 20px;
}

.rm-parent-group:last-child {
  margin-bottom: 0;
}

.rm-parent-title {
  font-size: 16.5px;
  font-weight: 700;
  color: #1e5b4f;
  padding-bottom: 10px;
  border-bottom: 1.5px solid rgba(30, 91, 79, 0.15);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rm-parent-title b {
  font-size: 12.5px;
  color: #1e5b4f;
  background: rgba(30, 91, 79, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.rm-sub-section {
  margin-bottom: 16px;
}

.rm-sub-section:last-child {
  margin-bottom: 0;
}

.rm-sub-title {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rm-sub-title b {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}

.rm-lead-wrap {
  margin-bottom: 18px;
}

.rm-lead-wrap .rp-role {
  margin-bottom: 12px;
}

.rm-lead-wrap .rp-lead {
  margin-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   ── 모바일 반응형 미디어 쿼리 (max-width: 900px) ──
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* 1. 우측 대형 로고 숨김 (모바일) */
  #canvas-logo { display: none !important; }

  /* 2. 우측 상단 플로팅 액션 버튼 */
  /* 모바일은 명단이 하단 시트로 올라오므로 버튼은 위쪽에 둔다 */
  #floating-actions {
    top: 14px;
    right: 14px;
    bottom: auto;
    left: auto;
    gap: 6px;
  }
  .icon-fab {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }
  .icon-fab svg { width: 16px; height: 16px; }

  /* 4. 검색창 모바일 가변 폭 */
  .search-wrapper { width: 36px; height: 36px; border-radius: 18px; }
  #btn-search-toggle { width: 36px; height: 36px; flex: 0 0 36px; }
  #btn-search-toggle svg { width: 16px; height: 16px; }
  .search-container.expanded .search-wrapper {
    width: calc(100vw - 125px);
    max-width: 280px;
    height: 36px;
  }
  .search-dropdown {
    width: 100%;
    max-width: 100%;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    bottom: auto;
    max-height: 52vh;
  }

  /* 5. 우측 명단 패널 ➔ '모바일 바텀 시트' 전환 */
  #roster-pane {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 62vh;
    transform: translateY(0);
    opacity: 1;
    border-radius: 26px 26px 0 0;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-bottom: none;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.18), 0 -2px 8px rgba(0, 0, 0, 0.04);
    z-index: 25;
  }
  #roster-pane.hidden {
    transform: translateY(105%);
    opacity: 0;
    pointer-events: none;
  }
  .rp-drag-handle {
    display: block;
    width: 42px;
    height: 4.5px;
    background: #cbd5e1;
    border-radius: 4px;
    margin: 2px auto 14px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .rp-drag-handle:active {
    cursor: grabbing;
  }
  .rp-inner {
    max-height: calc(62vh - 20px);
    padding: 14px 0 0;
  }
  #roster-pane header {
    padding: 4px 44px 10px 18px;
  }
  .rp-scroll {
    padding: 12px 16px 28px 18px;
    overscroll-behavior-y: contain;
  }

  #roster-pane h3 { font-size: 17.5px; }
  .rp-role { font-size: 13px; margin: 0 0 16px 4px; }
  .rp-lead { margin: 0 0 18px 0; padding: 4px 6px; }
  .rp-leadname { font-size: 15px; }
  .rp-people {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 10px 4px;
  }
  .rp-person figcaption { font-size: 13px; }
  .rp-av { width: 44px; height: 44px; font-size: 13px; }

  /* 6. 모달 창 모바일 핏 */
  #person-modal .sheet {
    width: calc(100vw - 24px);
    max-width: 400px;
    padding: 22px 20px 20px;
    border-radius: 22px;
  }
  .pm-head { gap: 14px; margin-bottom: 16px; }
  .pm-av { width: 56px; height: 56px; font-size: 19px; }
  #person-modal h2 { font-size: 20px; }
  #pm-axes { grid-template-columns: 64px 1fr; gap: 8px 12px; }
  #pm-axes dt { font-size: 12.5px; }
  #pm-axes dd { font-size: 13.5px; }

  #roster-modal .sheet {
    width: calc(100vw - 20px);
    max-height: 82vh;
    border-radius: 22px;
  }
  #roster-modal .sheet-head { padding: 16px 18px 14px; }
  #roster-modal .sheet-head h2 { font-size: 17px; }
  .rm-body { padding: 16px 14px 22px; }
  .rm-people-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px 4px; }

  /* 7. 하단 개발용 컨트롤러 */
  #floating-controls {
    bottom: 14px;
    right: 14px;
    padding: 3px 6px;
  }
  #tree-branch-toggle { font-size: 11.5px; padding: 4px 8px; }
}
