/* megatwin_project — 컨소시엄 과제 관리 사이트
   빌드 단계가 없으므로 순수 CSS 한 장으로 유지한다. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --border-strong: #cbd2dc;
  --text: #1c2129;
  --text-dim: #5b6472;
  --text-faint: #8b95a4;
  --accent: #2563eb;
  --accent-soft: #eaf0ff;

  --planned: #94a3b8;
  --active: #2563eb;
  --done: #16a34a;
  --delayed: #dc2626;
  --hold: #a16207;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 목록의 항목명처럼, 링크이되 강조색을 쓰지 않고 주변 텍스트 색을 그대로
   유지하고 싶을 때(예: 에셋 목록의 에셋명). */
.link-plain { color: inherit; text-decoration: none; }
.link-plain:hover { text-decoration: underline; }

/* ------------------------------------------------------------ 레이아웃 */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex: 0 0 210px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 0 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh; /* 모바일 브라우저 주소창/제스처바 만큼 100vh가 실제보다
                     커서 메뉴 맨 아래가 화면 밖으로 잘리는 문제 — dvh는
                     실제 보이는 높이를 따라간다(구형 브라우저는 위 100vh로 동작) */
  overflow-y: auto;
}

.brand {
  padding: 4px 16px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.brand a { color: var(--text); font-weight: 700; font-size: 14px; line-height: 1.35;
           display: block; }
.brand .period { color: var(--text-faint); font-size: 11px; font-weight: 400;
                 margin-top: 3px; font-family: var(--mono); }

.nav-group { padding: 10px 16px 4px; font-size: 11px; color: var(--text-faint);
             font-weight: 600; letter-spacing: .03em; }
.nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px 7px 32px; color: var(--text-dim); font-size: 13px;
  border-left: 2px solid transparent;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active {
  color: var(--accent); background: var(--accent-soft);
  border-left-color: var(--accent); font-weight: 600;
}
.nav .badge { margin-left: auto; }
.nav-star { margin-left: auto; color: #eab308; font-size: 12px; line-height: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 52px; flex: 0 0 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-dim); font-size: 13px; }
.topbar .who b { color: var(--text); }

/* 모바일 사이드바 열기 버튼 — 데스크톱에서는 숨기고 700px 이하에서만 보인다 */
.nav-toggle {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 19px; line-height: 1; color: var(--text); padding: 4px 6px;
}
.nav-backdrop { display: none; }

.content { padding: 22px; max-width: 1400px; width: 100%; }

.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; }

/* -------------------------------------------------------------- 컴포넌트 */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card > h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.card > h2 .sub { font-weight: 400; color: var(--text-faint); font-size: 12px;
                  margin-left: 6px; }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-block; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 100;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, .18);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-backdrop.open {
    display: block; position: fixed; inset: 0; z-index: 90;
    background: rgba(15, 23, 42, .4);
  }
  .topbar-org { display: none; }
}

.stat { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--text-dim); }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 2px;
               font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-faint); }
.stat .foot { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* 상태 배지 */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.7; white-space: nowrap;
}
.badge.planned { background: #eef1f5; color: #5b6472; }
.badge.active  { background: #e0ecff; color: #1d4ed8; }
.badge.done    { background: #dcfce7; color: #15803d; }
.badge.delayed { background: #fee2e2; color: #b91c1c; }
.badge.hold    { background: #fef3c7; color: #92400e; }
.badge.gray    { background: #eef1f5; color: #5b6472; }
.badge.info    { background: var(--accent-soft); color: var(--accent); }

.org-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px 1px 6px; border-radius: 999px;
  background: #f1f3f6; font-size: 11px; font-weight: 600; color: var(--text-dim);
  white-space: nowrap;
}
.org-chip i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* 마일스톤 상세의 수행기관 추가/제외 (staff 전용) */
.org-chip-edit { position: relative; display: inline-flex; }
.org-chip-remove-form { display: contents; }
.org-chip-remove-btn {
  position: absolute; top: -6px; right: -6px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--delayed); color: #fff; border: 2px solid var(--surface);
  font-size: 11px; line-height: 1; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; opacity: 0; transform: scale(0.8);
  transition: opacity .12s, transform .12s;
}
.org-chip-edit:hover .org-chip-remove-btn { opacity: 1; transform: scale(1); }
.org-chip-add select {
  font-size: 12px; padding: 3px 6px; border-radius: 7px;
  border: 1px solid var(--border-strong); background: var(--surface);
}

/* 진행 막대 */
.bar { height: 6px; background: #eceff3; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent);
              border-radius: 999px; }
.bar.done > span { background: var(--done); }
.bar.delayed > span { background: var(--delayed); }

/* 표 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.tbl th {
  font-size: 11px; color: var(--text-dim); font-weight: 600;
  background: #fafbfc; white-space: nowrap; position: sticky; top: 0;
}
table.tbl tr:hover td { background: #fafbfc; }
table.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap;
                   color: var(--text-dim); }
.table-wrap { overflow-x: auto; }

/* 버튼 */
.btn {
  display: inline-block; padding: 6px 13px; border-radius: 7px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.sm { padding: 3px 9px; font-size: 12px; }

/* 필터 버튼 우측 상단에 걸쳐 보이는 개수 배지(예: 에셋 유형별 건수) */
.btn-count-wrap { position: relative; display: inline-block; }
.btn-count {
  position: absolute; top: -7px; right: -7px; z-index: 1;
  min-width: 16px; height: 16px; padding: 0 3px; border-radius: 999px;
  background: var(--text-dim); color: #fff; border: 2px solid var(--surface);
  font-size: 10px; font-weight: 700; line-height: 12px; text-align: center;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.btn-count-wrap .btn.primary ~ .btn-count { background: var(--accent); }

/* 에셋 목록의 유형/기관 필터 — PC에서는 한 줄에 양쪽 끝으로, 모바일에서는
   줄을 나눠 세로로 쌓는다. */
.asset-filters {
  padding: 10px 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.asset-filters .filter-group {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.asset-filters .filter-label { font-size: 12px; color: var(--text-dim); }
@media (max-width: 700px) {
  .asset-filters { flex-direction: column; align-items: stretch; }
}

/* 다중선택 토글 필터(체크박스를 버튼처럼). .btn.sm과 같은 모양을 쓴다. */
.chk-btn {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 3px 9px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 12px; font-weight: 600;
  user-select: none;
}
.chk-btn input { display: none; }
.chk-btn:hover { background: var(--bg); }
.chk-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 폼 */
.form label { display: block; font-size: 12px; font-weight: 600;
              color: var(--text-dim); margin: 12px 0 4px; }
.form input[type=text], .form input[type=password], .form input[type=email],
.form input[type=date], .form input[type=number], .form select, .form textarea {
  width: 100%; padding: 7px 10px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 7px; background: #fff;
}
.form textarea { min-height: 90px; resize: vertical; }
.form .help { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.form .errors { color: var(--delayed); font-size: 12px; margin-top: 3px; }

.messages { margin-bottom: 14px; }
.msg { padding: 9px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.msg.success { background: #dcfce7; color: #15803d; }
.msg.error   { background: #fee2e2; color: #b91c1c; }
.msg.warning { background: #fef3c7; color: #92400e; }
.msg.info    { background: var(--accent-soft); color: var(--accent); }

.empty { padding: 28px; text-align: center; color: var(--text-faint); font-size: 13px; }

.note {
  font-size: 12px; color: var(--text-dim); background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 8px; padding: 9px 12px;
  margin-bottom: 14px;
}

/* ---------------------------------------------------------------- 간트 */

.gantt { width: 100%; border-collapse: collapse; font-size: 12px; }
.gantt th, .gantt td { border: 1px solid var(--border); padding: 0; }
.gantt th { background: #fafbfc; font-size: 11px; color: var(--text-dim);
            font-weight: 600; text-align: center; padding: 5px 0; }
.gantt th.name, .gantt td.name { text-align: left; padding: 6px 9px; width: 40%;
                                 min-width: 260px; }
.gantt td.no { text-align: center; color: var(--text-faint); width: 34px;
               font-variant-numeric: tabular-nums; }
.gantt td.m { height: 26px; width: 38px; }
.gantt td.m.on { background: var(--accent); }
.gantt td.m.on.done { background: var(--done); }
.gantt td.m.on.delayed { background: var(--delayed); }
.gantt td.m.na { background: repeating-linear-gradient(45deg, #f1f3f6, #f1f3f6 3px,
                 #e4e8ee 3px, #e4e8ee 6px); }
.gantt td.m.now { box-shadow: inset 0 0 0 2px #f59e0b; }
.gantt tr:hover td.name { background: #fafbfc; }

/* --------------------------------------------------- 클릭 가능한 통계 카드 */

a.stat {
  display: block; text-decoration: none; color: inherit; cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
a.stat:hover { border-color: var(--border-strong); box-shadow: 0 2px 8px rgba(16,24,40,.08); }

/* ------------------------------------------------- 표 안에 붙는 소형 간트 */
/* 마일스톤 표의 '목표일정' 칸. 1단계는 21개월(26.04~27.12), 2단계는 12개월
   (28.01~28.12)이라 폭을 좁게 잡는다. 상태 색상은 .gantt와 동일한 규칙. */

table.gantt-mini th.yr {
  font-size: 10px; color: var(--text-dim); font-weight: 700; text-align: center;
  padding: 3px 0; background: #f1f3f6; border-bottom: 1px solid var(--border);
}
table.gantt-mini th.m {
  font-size: 10px; color: var(--text-faint); font-weight: 600; text-align: center;
  padding: 3px 0; background: #fafbfc; white-space: nowrap;
}
table.gantt-mini td.m {
  width: 20px; min-width: 20px; padding: 0; border-left: 1px solid #f4f5f7;
}
table.gantt-mini td.m.on { background: var(--accent); }
table.gantt-mini td.m.on.done { background: var(--done); }
table.gantt-mini td.m.on.delayed { background: var(--delayed); }
table.gantt-mini td.m.now:not(.on) { background: #fef3c7; }
table.gantt-mini td.m.now.on { box-shadow: inset 0 0 0 2px #f59e0b; }
table.gantt-mini td.name { min-width: 220px; }
table.gantt-mini { table-layout: fixed; }
table.gantt-mini td.name, table.gantt-mini td.name a { overflow-wrap: break-word; }

/* 단계당 표를 하나만 쓰므로, 그룹(예: '1. 시스템 설계') 구분은 표 안의
   구분 행으로 넣는다 — 표를 쪼개면 표끼리 칸 너비가 달라져 월 축이
   어긋난다(2026-08 발견). */
table.gantt-mini tr.group-row td {
  background: #f1f3f6; font-weight: 700; font-size: 12px; color: var(--text-dim);
  padding: 7px 10px; border-bottom: 1px solid var(--border);
}

/* 헤더가 두 줄(연도 병합 행 + 월 행)이라, .tbl th의 기본 sticky(top:0)를
   그대로 두면 두 행이 같은 위치에서 겹친다. 이 표만 sticky를 끈다. */
table.gantt-mini th { position: static; }


/* --------------------------------------------------------- 목표 트리 */

.goal-final {
  background: linear-gradient(135deg, #1e3a8a, #2563eb); color: #fff;
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.goal-final .label { font-size: 11px; opacity: .8; font-weight: 600;
                     letter-spacing: .04em; }
.goal-final p { margin: 6px 0 0; font-size: 15px; line-height: 1.6; font-weight: 500; }

.subgoal { border-left: 3px solid var(--accent); }
.subgoal .no { font-size: 11px; font-weight: 700; color: var(--accent); }
.subgoal h3 { margin: 2px 0 8px; font-size: 14px; font-weight: 700; }
.subgoal ul { margin: 0; padding-left: 17px; color: var(--text-dim); font-size: 12px; }
.subgoal li { margin-bottom: 3px; }

details.tree { margin-bottom: 6px; }
details.tree > summary {
  cursor: pointer; padding: 7px 10px; border-radius: 7px; background: #fafbfc;
  font-size: 13px; font-weight: 600; list-style: none;
}
details.tree > summary::-webkit-details-marker { display: none; }
details.tree > summary::before { content: "▸ "; color: var(--text-faint); }
details.tree[open] > summary::before { content: "▾ "; }
details.tree > summary:hover { background: #f1f3f6; }
details.tree .body { padding: 9px 10px 4px 22px; }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 5px 12px; font-size: 13px; }
.kv dt { color: var(--text-dim); font-size: 12px; }
.kv dd { margin: 0; }

ul.plain { margin: 0; padding-left: 17px; }
ul.plain li { margin-bottom: 3px; }

.prose { font-size: 14px; line-height: 1.7; }
.prose img { max-width: 100%; height: auto; }
.prose table { border-collapse: collapse; }
.prose table td, .prose table th { border: 1px solid var(--border); padding: 5px 8px; }
.prose pre { background: #f6f7f9; padding: 10px; border-radius: 7px; overflow-x: auto; }

/* ------------------------------------------------------ TinyMCE 툴바 축소 */
/* 셀프호스팅 스킨(static/tinymce/)은 install_tinymce로 다시 받을 때마다
   초기화되므로 거기 CSS를 직접 고치면 안 된다 — 여기서 덮어쓴다.
   주의: 아이콘 svg는 viewBox가 없어 24x24 고정 좌표계다. width/height를
   CSS로 직접 줄이면 그림이 비율대로 작아지는 게 아니라 잘려나간다(실제
   발생한 문제). 대신 transform:scale()로 렌더된 결과물을 통째로 축소한다
   — 이러면 원본 좌표계를 그대로 쓰고 화면에 그린 다음 시각적으로만
   줄이므로 잘리지 않는다. */
.tox .tox-tbtn { width: 30px !important; height: 28px !important; }
.tox .tox-tbtn__icon-wrap,
.tox .tox-icon { transform: scale(0.75); transform-origin: center; }
