:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-bg: #eef2ff;

  --danger: #e11d48;
  --danger-bg: #fff1f2;
  --danger-border: #fecdd3;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.06);

  --status-start-bg: #fca5a5;     /* 시작전 — 빨강 */
  --status-start-fg: #7f1d1d;
  --status-p1ip-bg: #fdba74;      /* 1차진행중 — 주황 */
  --status-p1ip-fg: #7c2d12;
  --status-p1done-bg: #fde047;    /* 1차개발완료 — 노랑 */
  --status-p1done-fg: #713f12;
  --status-p2ip-bg: #bef264;      /* 2차진행중 — 연두 */
  --status-p2ip-fg: #3f6212;
  --status-p2done-bg: #93c5fd;    /* 2차개발완료 — 파랑 */
  --status-p2done-fg: #1e3a8a;

  --status-start-accent: #dc2626;
  --status-p1ip-accent: #ea580c;
  --status-p1done-accent: #a16207;
  --status-p2ip-accent: #4d7c0f;
  --status-p2done-accent: #1d4ed8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR",
               "Segoe UI", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1760px;
  margin: 0 auto;
  padding: 20px;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 0;
}
.topbar__left { justify-content: flex-start; }
.topbar__right { justify-content: flex-end; }
.topbar__center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.topbar label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.scope-hint {
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== Form controls ===== */
select,
button {
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}

select {
  padding: 6px 28px 6px 10px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
select:hover { border-color: var(--border-strong); }
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

button {
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 500;
}
button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
button:disabled { opacity: 0.55; cursor: default; }

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
button.primary:disabled {
  background: var(--primary);
  color: #fff;
  opacity: 0.55;
}

button.outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
button.outline:hover:not(:disabled) {
  background: rgba(79, 70, 229, 0.08);
  border-color: var(--primary-hover);
  color: var(--primary-hover);
}

/* ===== User overview (전체 담당자 진행상황) ===== */
.user-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.uo__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.uo__card:hover {
  border-color: var(--border-strong);
}
.uo__card.active {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.uo__card--all {
  border-style: dashed;
}
.uo__card--all .uo__name {
  color: var(--primary);
}
.uo__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.uo__name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
}
.uo__val {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.uo__bar {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--status-start-bg);
}
.uo__seg {
  height: 100%;
  transition: flex-grow 300ms ease;
}
.uo__seg.s-start   { background: var(--status-start-accent); }
.uo__seg.s-p1ip    { background: var(--status-p1ip-accent); }
.uo__seg.s-p1done  { background: var(--status-p1done-accent); }
.uo__seg.s-p2ip    { background: var(--status-p2ip-accent); }
.uo__seg.s-p2done  { background: var(--status-p2done-accent); }

/* ===== Error banner ===== */
.error-banner {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  color: var(--danger);
}
.error-banner__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.error-banner button {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger);
  padding: 4px 10px;
  font-size: 12px;
}
.error-banner button:hover:not(:disabled) { background: #fff; }
.error-list {
  margin: 10px 0 0;
  padding-left: 20px;
  max-height: 240px;
  overflow: auto;
  color: var(--text);
}
.error-list li { margin: 4px 0; font-size: 13px; }
.error-list li.warn { color: var(--text-muted); }

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
  align-items: start;
}
.layout__main { min-width: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr !important; }
  .progress-panel { position: static; }
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
}
.tab {
  padding: 7px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 120ms, color 120ms;
}
.tab:hover:not([data-active="1"]) {
  background: var(--surface-hover);
  color: var(--text);
}
.tab[data-active="1"] {
  background: var(--primary);
  color: #fff;
}

.tabs--sub {
  margin-top: -4px;
}
.tabs--sub .tab {
  padding: 4px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.tab__count {
  display: block;
  font-size: 10.5px;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  margin-top: 1px;
}

/* 시나리오 파일번호 세부 필터 (1차 / 2차 선택 시 그 아래) */
.tabs--files {
  margin-top: -4px;
  margin-bottom: 10px;
  gap: 2px;
  background: #f9fafb;
  border: 1px dashed var(--border);
}
.tabs--files .tab {
  padding: 4px 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.3px;
}
.tabs--files .tab[data-active="1"] {
  background: #64748b;
  color: #fff;
}
.tabs--files.hidden { display: none; }

/* ===== Tree ===== */
.tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 240px;
}

.user-group { margin-bottom: 18px; }
.user-group__topline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.user-group__topline > .user-group__head {
  margin-bottom: 0;
}
.user-group__topline > .memo-hint {
  margin-left: auto;
}

/* 트리 그룹 헤더 옆 강조 안내 배지 */
.memo-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  color: #78350f;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.2);
}
.memo-hint__icon { font-size: 14px; }
.memo-hint__emoji { font-size: 14px; }
.memo-hint b {
  font-weight: 800;
  color: #92400e;
  text-decoration: underline;
  text-decoration-color: #f59e0b;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}
.user-group:last-child { margin-bottom: 0; }

.user-group__head {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
  margin-bottom: 8px;
  padding: 4px 12px;
  background: var(--primary-bg);
  border-radius: 999px;
}
.user-group__head .stat {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11.5px;
}

.node { margin: 1px 0; }
.node__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: background 100ms, border-color 100ms;
}
.node__row:hover {
  background: var(--surface-hover);
  border-color: #dc2626;
}


.node__kind {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
  flex-shrink: 0;
}
.node__kind.page  { background: #e0f2fe; color: #0369a1; }
.node__kind.popup { background: #fef3c7; color: #b45309; }
.node__kind.tab   { background: #ede9fe; color: #6d28d9; }

.node__name {
  font-weight: 500;
  color: var(--text);
}
.node__badges {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}
.node__meta {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.node__status {
  font-size: 12px;
  padding: 3px 24px 3px 10px;
  border: 1px solid transparent;
  font-weight: 500;
}
.node__status:disabled {
  background-color: transparent;
  color: var(--text-muted);
  cursor: default;
  padding-right: 10px;
  background-image: none;
}
.node__status.s-start   { background-color: var(--status-start-bg);   color: var(--status-start-fg); }
.node__status.s-p1ip    { background-color: var(--status-p1ip-bg);    color: var(--status-p1ip-fg); }
.node__status.s-p1done  { background-color: var(--status-p1done-bg); color: var(--status-p1done-fg); }
.node__status.s-p2ip    { background-color: var(--status-p2ip-bg);    color: var(--status-p2ip-fg); }
.node__status.s-p2done  { background-color: var(--status-p2done-bg); color: var(--status-p2done-fg); font-weight: 600; }

.badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.crosses-first  { background: #e0f2fe; color: #0369a1; }
.badge.crosses-second { background: #fef3c7; color: #b45309; }
.badge.cycle          { background: #ffe4e6; color: #be123c; }
.badge.partner        { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }
.badge.scenario-ref {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid var(--border);
  font-size: 10.5px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.badge.scenario-ref.more {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.node__children {
  border-left: 1px solid var(--border);
  margin-left: 20px;
  padding-left: 14px;
}

/* === 접기/펼치기 토글 === */
.node__toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
  transition: transform 160ms ease, color 100ms, background 100ms, border-color 100ms;
}
.node__toggle::before {
  content: "▾";  /* 펼친 상태 */
  display: block;
  line-height: 1;
}
.node__toggle:hover {
  color: var(--primary);
  background: var(--primary-bg);
  border-color: var(--primary);
}
.node.collapsed > .node__row > .node__toggle {
  transform: rotate(-90deg);
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-bg);
}
.node__toggle--empty {
  visibility: hidden;
}

/* === 접힌 상태 자식 숨김 === */
.node.collapsed > .node__children { display: none; }

/* === Ghost (접혀 있을 때의 자식 힌트 — +N 개수 표시) === */
.node__ghost {
  display: none;
  margin-left: 34px;     /* .node__children 의 margin+padding 과 맞춤 (20+14) */
  margin-top: 3px;
  padding: 6px 12px;
  gap: 8px;
  align-items: center;
  opacity: 0.35;
  cursor: pointer;
  transition: opacity 140ms ease, background 140ms;
  width: calc(100% - 34px);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  font-size: 12px;
  color: var(--text-muted);
}
.node.collapsed.has-children > .node__ghost {
  display: flex;
}
.node.collapsed.has-children > .node__ghost:hover {
  opacity: 0.85;
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}
.node__ghost__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 20px;
  padding: 0 8px;
  background: var(--text-faint);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.node.collapsed.has-children > .node__ghost:hover .node__ghost__count {
  background: var(--primary);
}
.node__ghost__label {
  font-size: 12px;
}

.node__warn {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 4px;
  white-space: nowrap;
}
.node__warn.done {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

/* 개발 가능/불가 뱃지 — 행의 맨 오른쪽 */
.node__ship {
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}
.node__ship.ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.node__ship.blocked {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.node__ship.dup {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  text-decoration: none;  /* 행 strikethrough 상속 차단 */
}

/* 개발 불가 사유 안내 — ⚠ 아이콘 + hover 큰 팝오버 */
.node__ship-alert {
  appearance: none;
  border: none;
  background: transparent;
  cursor: help;
  font-size: 13px;
  line-height: 1;
  margin-left: 4px;
  padding: 3px 5px;
  border-radius: 4px;
  color: #d97706;
  transition: background 0.15s, transform 0.15s;
}
.node__ship-alert:hover,
.node__ship-alert:focus-visible {
  background: #fef3c7;
  transform: scale(1.15);
  outline: none;
}

.blocker-popover {
  position: fixed;
  z-index: 9999;
  width: 420px;
  max-width: calc(100vw - 20px);
  max-height: 440px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #111827;
}
.blocker-popover.hidden { display: none; }

.blocker-popover__header {
  font-weight: 700;
  font-size: 14.5px;
  color: #b45309;
  margin-bottom: 4px;
}
.blocker-popover__self {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.blocker-popover__rule {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
  color: #78350f;
  font-size: 12.5px;
}
.blocker-popover__rule b { color: #b45309; }

.blocker-popover__section-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: #374151;
}
.blocker-popover__section-title .muted { color: #9ca3af; font-weight: 500; }

.blocker-popover__empty {
  padding: 8px 2px;
  font-size: 12.5px;
}

.blocker-popover__list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.blocker-popover__item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 4px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 12.5px;
}
.blocker-popover__item:last-child { border-bottom: none; }
.blocker-popover__item .blocker-popover__screen {
  flex: 1;  /* screen_id 가 남은 공간 차지해서 charge / status 오른쪽 정렬 */
  min-width: 0;
}

.blocker-popover__charge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #f3f4f6;
  color: #4b5563;
  white-space: nowrap;
  font-weight: 500;
}
.blocker-popover__charge:empty { display: none; }
.blocker-popover__charge.is-common {
  background: #ede9fe;
  color: #6d28d9;
}
.blocker-popover__kind {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #e5e7eb;
  color: #374151;
  font-weight: 600;
  text-transform: uppercase;
}
.blocker-popover__screen {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #374151;
}
.blocker-popover__status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.blocker-popover__status.s-start   { background: var(--status-start-bg); color: var(--status-start-fg); }
.blocker-popover__status.s-p1ip    { background: var(--status-p1ip-bg); color: var(--status-p1ip-fg); }
.blocker-popover__status.s-p1done  { background: var(--status-p1done-bg); color: var(--status-p1done-fg); }
.blocker-popover__status.s-p2ip    { background: var(--status-p2ip-bg); color: var(--status-p2ip-fg); }
.blocker-popover__status.s-p2done  { background: var(--status-p2done-bg); color: var(--status-p2done-fg); }

/* +N 배지용 시나리오 파일 목록 툴팁 (다크) */
.refs-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1f2937;
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  max-width: 320px;
}
.refs-tooltip.hidden { display: none; }
.refs-tooltip__title {
  font-size: 11px;
  color: #cbd5e1;
  margin-bottom: 6px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.refs-tooltip__count {
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}
.refs-tooltip__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.refs-tooltip__file {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #374151;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.3px;
  font-size: 11.5px;
}

/* ===== Progress panel ===== */
.progress-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 14px;
}

/* ===== History section (변경 이력 — 진행률 패널 내부) ===== */
.history-section .history-list {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-list li {
  font-size: 11.5px;
  line-height: 1.4;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fafafa;
}
.history-list li .h-ts {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
}
.history-list li .h-user {
  color: var(--primary);
  font-weight: 600;
  margin-left: 4px;
}
.history-list li .h-screen {
  color: var(--text);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10.5px;
}
.history-list li .h-arrow {
  color: var(--text-muted);
  margin: 0 4px;
}
.history-list li .h-from,
.history-list li .h-to {
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 500;
}
.history-list li .h-to { font-weight: 600; }

.progress-panel__title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.progress-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.progress-section--first {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.progress-section__title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.progress-section__hint {
  margin: 8px 2px 0;
  font-size: 11px;
}

.scenario-item { margin-bottom: 10px; }
.scenario-item:last-child { margin-bottom: 0; }
.scenario-item__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 4px;
}
.scenario-item__label {
  color: var(--text);
  font-weight: 500;
}
.scenario-item__val {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.progress-thin {
  height: 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}
.progress-thin__fill {
  height: 100%;
  background: var(--primary);
  transition: width 400ms ease;
}
.progress-thin__fill.s-start   { background: var(--status-start-accent); }
.progress-thin__fill.s-p1ip    { background: var(--status-p1ip-accent); }
.progress-thin__fill.s-p1done  { background: var(--status-p1done-accent); }
.progress-thin__fill.s-p2ip    { background: var(--status-p2ip-accent); }
.progress-thin__fill.s-p2done  { background: var(--status-p2done-accent); }

.progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.progress-list li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 180ms ease, outline-color 120ms;
  outline: 2px solid transparent;
  outline-offset: -1px;
}
.progress-list li:hover:not(.active) {
  opacity: 0.95;
  outline-color: rgba(79, 70, 229, 0.35);
}
.progress-list li.active {
  opacity: 1;
  outline-color: var(--primary);
}
.progress-list__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.progress-list__label { font-weight: 600; }
.progress-list__val {
  font-size: 11px;
  opacity: 0.75;
}
.progress-list li.s-start  { background: var(--status-start-bg); color: var(--status-start-fg); }
.progress-list li.s-p1ip   { background: var(--status-p1ip-bg); color: var(--status-p1ip-fg); }
.progress-list li.s-p1done { background: var(--status-p1done-bg); color: var(--status-p1done-fg); }
.progress-list li.s-p2ip   { background: var(--status-p2ip-bg); color: var(--status-p2ip-fg); }
.progress-list li.s-p2done { background: var(--status-p2done-bg); color: var(--status-p2done-fg); }

.progress-list li.all {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--primary);
  color: #fff;
}
.progress-list li.all:hover { outline-color: var(--primary-hover); }
.progress-list li.all.active { outline-color: var(--primary-hover); }
.progress-list li.all .progress-thin {
  background: rgba(255, 255, 255, 0.2);
}
.progress-list li.all .progress-thin__fill {
  background: #fff;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  margin-bottom: 10px;
  background: var(--primary-bg);
  border-radius: 999px;
  font-size: 12px;
  color: var(--primary);
}
.filter-chip__label { font-weight: 600; }
.filter-chip button {
  padding: 0;
  width: 20px;
  height: 20px;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  border-radius: 50%;
}
.filter-chip button:hover { background: rgba(79, 70, 229, 0.15); }

.node.dim > .node__row { opacity: 0.38; }
.node.dim > .node__row:hover { opacity: 0.85; }

.node.done > .node__row { opacity: 0.5; }
.node.done > .node__row:hover { opacity: 0.9; }

/* 담당자 그룹 내 중복 노드 */
body:not(.hide-duplicates) .node.duplicate > .node__row {
  text-decoration: line-through;
  text-decoration-color: #dc2626;
  color: #dc2626;
}
body.hide-duplicates .node.duplicate { display: none; }

/* 완료 숨기기: "자신 + 모든 자손"이 전부 완료일 때만 숨김.
   자손 중 미완료가 하나라도 있으면 본인도 표시(맥락 제공). */
body.hide-done .node.all-done { display: none; }

/* ===== Switch (iOS-style) ===== */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch__track {
  position: relative;
  width: 34px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 180ms ease;
}
.switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  transition: left 180ms ease;
}
.switch input:checked + .switch__track {
  background: var(--primary);
}
.switch input:checked + .switch__track .switch__thumb {
  left: 16px;
}
.switch input:focus-visible + .switch__track {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}
.switch__label { font-weight: 500; }

/* ===== Icon button ===== */
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-hover); }

/* ===== Login button (topbar 좌측, primary) ===== */
.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.25);
  transition: filter 120ms;
}
.login-btn:hover { filter: brightness(1.08); }
.login-btn__icon { font-size: 14px; }
.login-btn__name {
  padding: 1px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 700;
  font-size: 12px;
}
.login-btn__name--empty {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
}

/* ===== Login overlay (현재 사용자 선택 모달) ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fadeIn 100ms ease-out;
}
.login-overlay.hidden { display: none; }
.login-modal {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  padding: 22px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-modal__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.login-modal__desc {
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}
/* 디자인 dropdown (combo) — login 모달용 */
.combo {
  position: relative;
  width: 100%;
}
.combo__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: border-color 100ms, box-shadow 100ms;
}
.combo__trigger:hover { border-color: var(--primary); }
.combo__trigger[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.combo__value {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combo__value--placeholder {
  color: var(--text-faint);
  font-weight: 400;
}
.combo__caret {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 120ms;
}
.combo__trigger[aria-expanded="true"] .combo__caret {
  transform: rotate(180deg);
}
.combo__menu {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 10;
}
.combo__menu.hidden { display: none; }
.combo__option {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.combo__option:hover { background: var(--surface-hover); }
.combo__option.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}
.combo__option.active::before {
  content: "✓";
  font-size: 12px;
}
.combo__option:not(.active)::before {
  content: "";
  display: inline-block;
  width: 0.7em;
}
.combo__option--viewer {
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  padding-bottom: 10px;
  color: var(--muted);
  font-weight: 500;
}
.login-modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.login-cancel {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}
.login-cancel:hover { background: var(--surface-hover); }

/* ===== Search button (topbar 중앙 강조) ===== */
.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--primary);
  background: linear-gradient(180deg, var(--primary-bg) 0%, #fff 100%);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.18);
  min-width: 220px;
  transition: transform 120ms, box-shadow 120ms, background 120ms;
}
.search-btn:hover {
  background: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}
.search-btn:active { transform: translateY(0); }
.search-btn__icon {
  font-size: 15px;
}
.search-btn__label {
  flex: 1;
  text-align: left;
  letter-spacing: 0.02em;
}
.search-btn__hint {
  font-size: 11px;
  font-family: ui-monospace, Menlo, monospace;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Search (spotlight-like) ===== */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  z-index: 1000;
  animation: fadeIn 100ms ease-out;
}
.search-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.search-modal {
  width: min(560px, 92vw);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.search-input {
  border: 0;
  outline: none;
  padding: 18px 22px;
  font-size: 18px;
  font-family: ui-monospace, Menlo, monospace;
  border-bottom: 1px solid var(--border);
}
.search-results {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 50vh;
  overflow-y: auto;
}
.search-results:empty { display: none; }
.search-results li {
  padding: 10px 22px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 3px solid transparent;
}
.search-results li.active,
.search-results li:hover {
  background: var(--primary-bg);
  border-left-color: var(--primary);
}
.search-results .sr-screen {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.search-results .sr-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.search-results .sr-tag {
  padding: 1px 7px;
  border-radius: 4px;
  background: #f1f5f9;
}
.search-results .sr-tag.project-partner { background: #ede9fe; color: #6d28d9; }
.search-results .sr-tag.project-hallain { background: #dbeafe; color: #1e40af; }
.search-results .sr-tag.scenario-first { background: #fef3c7; color: #78350f; }
.search-results .sr-tag.scenario-second { background: #d1fae5; color: #065f46; }
.search-results .sr-tag.scenario-rest { background: #e5e7eb; color: #334155; }
.search-results .sr-tag.charge-none { background: #fee2e2; color: #991b1b; }

.search-hint {
  padding: 8px 22px;
  font-size: 11px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

/* 검색 결과 선택 시 트리에서 강조 — 중앙에서 1.2배 팝 후 클릭 전까지 깜빡임 */
@keyframes nodeFlashPop {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0   rgba(220, 38, 38, 0); }
  40%  { transform: scale(1.2); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.85); }
  100% { transform: scale(1);   box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.7); }
}
@keyframes nodeFlashBlink {
  0%, 100% { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.85); }
  50%      { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1); }
}
.node.flash > .node__row {
  transform-origin: center center;
  position: relative;
  z-index: 10;
  animation:
    nodeFlashPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 1,
    nodeFlashBlink 0.9s ease-in-out 0.55s infinite;
}

/* ===== Status-colored node rows (toggle-controlled) ===== */
body.show-status-bg .node.status-s-start  > .node__row { background: var(--status-start-bg); }
body.show-status-bg .node.status-s-p1ip   > .node__row { background: var(--status-p1ip-bg); }
body.show-status-bg .node.status-s-p1done > .node__row { background: var(--status-p1done-bg); }
body.show-status-bg .node.status-s-p2ip   > .node__row { background: var(--status-p2ip-bg); }
body.show-status-bg .node.status-s-p2done > .node__row { background: var(--status-p2done-bg); }
body.show-status-bg .node > .node__row:hover {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

/* 중복(같은 node_id) 트윈 하이라이트 — status-bg 뒤에 배치해 source-order 로 이김.
   hover 중인 자신은 제외, 나머지 트윈에만 빗금 배경.
   status-bg 의 background 단축속성이 덮는 걸 막기 위해 !important 사용. */
.node.twin-hover:not(:hover) > .node__row {
  border-color: #dc2626 !important;
  background: repeating-linear-gradient(
    45deg,
    #fef2f2 0,
    #fef2f2 6px,
    rgba(220, 38, 38, 0.45) 6px,
    rgba(220, 38, 38, 0.45) 10px
  ) !important;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 1000;
  max-width: 420px;
  animation: toastIn 220ms ease-out;
}
.toast.error { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============== Memo (우클릭 마크다운 메모) ============== */

/* 노드 행의 '메모 있음' 배지 — ship(개발 가능/불가) 배지 바로 왼쪽 */
.node__memo-badge {
  border: none;
  background: transparent;
  padding: 2px 6px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0.85;
  transition: opacity 100ms, background 100ms;
}
.node__memo-badge:hover {
  opacity: 1;
  background: var(--primary-bg);
}
.node__memo-badge.hidden { display: none; }

/* 본인 담당 노드 우클릭 힌트(옵션) — 너무 노이지하면 빼도 됨 */
.node__row { cursor: default; }

/* 메모 오버레이/모달 — login-overlay 패턴 재사용 */
.memo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fadeIn 100ms ease-out;
}
.memo-overlay.hidden { display: none; }
.memo-modal {
  width: min(1080px, 96vw);
  height: min(820px, 92vh);
  max-height: 92vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.memo-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.memo-modal__titleblock { flex: 1; min-width: 0; }
.memo-modal__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}
.memo-modal__sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}
.memo-close {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.memo-close:hover { background: var(--primary-bg); color: var(--primary); }

.memo-readonly {
  font-size: 12px;
  color: var(--text-muted);
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 6px 10px;
}
.memo-readonly.hidden { display: none; }

.memo-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.memo-tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.memo-tab:hover { color: var(--text); }
.memo-tab[data-active] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.memo-tab.hidden { display: none; }

.memo-view {
  flex: 1;
  min-height: 320px;
  overflow-y: auto;
  padding: 8px 6px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}
.memo-view.hidden { display: none; }
.memo-view--empty { color: var(--text-muted); }
/* 메모 안의 마크다운 요소 스타일 */
.memo-view h1, .memo-view h2, .memo-view h3, .memo-view h4 {
  margin: 14px 0 6px;
  line-height: 1.3;
}
.memo-view h1 { font-size: 18px; }
.memo-view h2 { font-size: 16px; }
.memo-view h3 { font-size: 14px; }
.memo-view p { margin: 6px 0; }
.memo-view ul, .memo-view ol { margin: 6px 0 6px 22px; padding: 0; }
.memo-view li { margin: 2px 0; }
.memo-view code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.memo-view pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12.5px;
  margin: 8px 0;
}
.memo-view pre code { background: transparent; padding: 0; color: inherit; }
.memo-view blockquote {
  border-left: 3px solid var(--primary);
  background: var(--primary-bg);
  padding: 4px 10px;
  margin: 8px 0;
  color: var(--text);
  border-radius: 0 6px 6px 0;
}
.memo-view a { color: var(--primary); text-decoration: underline; }
.memo-view table { border-collapse: collapse; margin: 8px 0; }
.memo-view th, .memo-view td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: 13px;
}
.memo-view th { background: #f8fafc; }
.memo-view hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.memo-edit {
  flex: 1;
  min-height: 420px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  outline: none;
  transition: border-color 100ms, box-shadow 100ms;
}
.memo-edit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.memo-edit.hidden { display: none; }

.memo-modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.memo-meta {
  font-size: 11.5px;
}
.memo-actions {
  display: flex;
  gap: 8px;
}
.memo-save.hidden, #memo-save.hidden { display: none; }

/* ============== 담당자 편집 (관리자 전용) ============== */

.node__charge-edit {
  border: 1px dashed var(--border);
  background: transparent;
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0.85;
  transition: opacity 100ms, background 100ms, border-color 100ms;
  margin-left: 2px;
}
.node__charge-edit:hover {
  opacity: 1;
  background: var(--primary-bg);
  border-color: var(--primary);
}

/* 담당자 편집 모달 — login-modal 패턴 재사용, 별도 스타일 최소화 */
#charge-overlay .login-modal { min-width: 380px; max-width: 480px; }
#charge-sub {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}
#charge-current {
  font-weight: 600;
  color: var(--text);
}

/* 담당자 변경 이력 — 기본 .history-list 재사용 + 추가 상태 */
.charge-history__item { position: relative; }
.charge-history__item.is-reverted {
  opacity: 0.55;
}
.charge-history__item.is-reverted .h-from,
.charge-history__item.is-reverted .h-to {
  text-decoration: line-through;
}
.charge-history__item.is-revert {
  border-style: dashed;
}
.h-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.h-tag--revert { background: #fef3c7; color: #854d0e; }
.h-tag--reverted { background: #e5e7eb; color: #4b5563; }

.charge-history__actions {
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
}
.revert-btn {
  font-size: 10.5px;
  padding: 3px 8px;
  border: 1px solid #f59e0b;
  background: #fffbeb;
  color: #92400e;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
.revert-btn:hover {
  background: #fde68a;
}
