/* ==========================================================================
   SPREAD 2026 CSS 시스템
   목업(SPREAD Projects.dc.html) 팔레트를 CSS 변수로 정규화 (rules.md: 인라인 스타일 금지)
   ========================================================================== */

/* [hidden] 강제 — .form-field 등 display 규칙이 [hidden]의 display:none을 덮어쓰는 것 방지 */
[hidden] { display: none !important; }

:root {
  /* Brand / Primary */
  --color-primary: #4c6ef5;
  --color-primary-hover: #4263eb;
  --color-link: #3457d5;
  --color-primary-ink: #1c5fd6;
  --color-primary-bg: #e7f0ff;

  /* Surface / Background */
  --color-bg: #f4f5f7;
  --color-bg-subtle: #f7f8fa;
  --color-surface: #ffffff;
  --color-surface-alt: #fafbfc;
  --color-sidebar-bg: #fbfbfc;
  --color-active-bg: #eef0fd;
  --color-hover-bg: #f5f7ff;

  /* Text */
  --color-text: #1a1d24;
  --color-text-2: #3d434e;
  --color-text-3: #525866;
  --color-text-muted: #6b7280;
  --color-text-label: #8993a4;
  --color-text-faint: #9aa0aa;

  /* Border */
  --color-border: #ebecf0;
  --color-border-input: #e2e4e9;
  --color-border-cell: #f1f2f4;

  /* Status */
  --color-status-active: #2fb344;
  --color-status-active-ink: #1a7f4b;
  --color-status-active-bg: #e6f4ec;
  --color-status-done: #4c6ef5;
  --color-status-done-ink: #1c5fd6;
  --color-status-done-bg: #e7f0ff;
  --color-status-stop: #e03131;
  --color-status-stop-ink: #c92a2a;
  --color-status-stop-bg: #ffe8e8;
  --color-status-hold: #f08c00;
  --color-status-hold-ink: #c2620f;
  --color-status-hold-bg: #fff0e2;

  /* 연구구분 배지 */
  --type-contract-bg: #e7f0ff; --type-contract-fg: #1c5fd6;
  --type-advisory-bg: #e6f4ec; --type-advisory-fg: #1a7f4b;
  --type-academic-bg: #efeafd; --type-academic-fg: #6941c6;
  --type-national-bg: #fff0e2; --type-national-fg: #c2620f;
  --type-joint-bg: #e2f5f3;    --type-joint-fg: #0d7d72;
  --type-support-bg: #eef0f2;  --type-support-fg: #5b6370;
  --type-etc-bg: #eef0f2;      --type-etc-fg: #5b6370;

  /* Spacing / Radius */
  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --radius: 8px; --radius-lg: 12px; --radius-sm: 5px;

  --sidebar-width: 250px;
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
input, select, button, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--color-link); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #d3d6db; border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #b7bcc4; background-clip: content-box; }

/* --------------------------------------------------------------------------
   앱 셸: 사이드바 + 메인
   -------------------------------------------------------------------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-logo {
  height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 var(--space-4); border-bottom: 1px solid var(--color-border);
  font-weight: 800; font-size: 16.5px; flex-shrink: 0;
}
.sidebar-logo-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--color-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
}
.sidebar-section { padding: var(--space-3) var(--space-2); }
.sidebar-title {
  font-size: 12.5px; font-weight: 700; color: var(--color-text-label);
  line-height: 1.5; padding: var(--space-2) var(--space-2) 6px; letter-spacing: .4px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 12px; margin-bottom: 2px; border-radius: 7px; cursor: pointer;
  color: var(--color-text-2); font-size: 14.5px; line-height: 1.6;
}
.sidebar-item:hover { background: var(--color-hover-bg); }
.sidebar-item.active {
  background: var(--color-active-bg); color: var(--color-primary-ink);
  font-weight: 700;
}
.sidebar-item .count {
  margin-left: auto; font-size: 12.5px; color: var(--color-text-faint);
  background: var(--color-border-cell); border-radius: 10px; padding: 2px 8px;
}
.sidebar-item.active .count { background: #dde3fc; color: var(--color-primary-ink); }
/* SOP 서브메뉴 */
.sidebar-subnav { margin: 0 0 6px 10px; padding-left: 10px; border-left: 1px solid var(--color-border); display: flex; flex-direction: column; }
.sidebar-subitem {
  padding: 7px 10px; margin-bottom: 1px; border-radius: 6px;
  color: var(--color-text-muted); font-size: 13.5px; line-height: 1.5; text-decoration: none;
}
.sidebar-subitem:hover { background: var(--color-hover-bg); color: var(--color-text); }
.sidebar-subitem.active { background: var(--color-active-bg); color: var(--color-primary-ink); font-weight: 700; }
.sidebar-footer {
  margin-top: auto; padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  font-size: 14.5px;
}
.sidebar-footer .logout-link { margin-left: auto; font-size: 13px; color: var(--color-text-muted); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* --------------------------------------------------------------------------
   툴바 / 세그먼트 / 상태바
   -------------------------------------------------------------------------- */
.toolbar {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-4);
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.toolbar-title { font-weight: 800; font-size: 16.5px; margin-right: var(--space-2); }
.toolbar-spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--color-border-input);
  background: var(--color-surface); color: var(--color-text-2);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--color-bg-subtle); }
.btn.btn-primary {
  background: var(--color-primary); border-color: var(--color-primary); color: #fff;
}
.btn.btn-primary:hover { background: var(--color-primary-hover); }
.btn.btn-danger { color: var(--color-status-stop-ink); border-color: #f3c1c1; }
.btn.btn-danger:hover { background: var(--color-status-stop-bg); }
.btn.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 6px; }
.btn.on { background: var(--color-active-bg); border-color: #c9d3fb; color: var(--color-primary-ink); }
.btn .badge-count {
  background: var(--color-primary); color: #fff; border-radius: 9px;
  font-size: 11px; padding: 0 6px; line-height: 17px;
}

.search-box {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--color-border-input); border-radius: var(--radius);
  padding: 0 10px; height: 36px; background: var(--color-surface); width: 230px;
}
.search-box input { border: none; outline: none; flex: 1; background: transparent; font-size: 14px; }
.search-box input::placeholder { color: var(--color-text-faint); }

.segments {
  height: 46px; flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 0 var(--space-4);
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.segment {
  padding: 7px 14px; border-radius: 7px; cursor: pointer;
  font-weight: 600; color: var(--color-text-3); font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; border: none; background: none;
}
.segment:hover { background: var(--color-bg-subtle); }
.segment.active { background: var(--color-active-bg); color: var(--color-primary-ink); }
.segment .count { font-size: 12.5px; color: var(--color-text-faint); }
.segment.active .count { color: var(--color-primary-ink); }

.statusbar {
  height: 40px; flex-shrink: 0;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-4);
  background: var(--color-surface-alt); border-top: 1px solid var(--color-border);
  font-size: 13px; color: var(--color-text-muted);
}
.statusbar .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* --------------------------------------------------------------------------
   그리드
   -------------------------------------------------------------------------- */
/* scrollbar-gutter: 세로 스크롤바 자리를 항상 예약 → 필터로 행 수가 변해도
   가용 너비가 흔들리지 않아 테이블 폭이 튀지 않는다. */
.grid-wrap { flex: 1; overflow: auto; background: var(--color-surface); position: relative; scrollbar-gutter: stable; }

/* table-layout:fixed + <colgroup>: 컬럼 너비를 <col>이 단독 결정 →
   리사이즈가 헤더/바디에 동시 반영되고 다른 컬럼 폭이 흔들리지 않는다.
   테이블 전체 폭(width)은 grid.js가 컬럼 합으로 명시 설정한다
   (fixed 레이아웃 + max-content는 <col> 너비를 무시하므로 사용 금지). */
.sp-grid { table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.sp-grid th, .sp-grid td {
  border-right: 1px solid var(--color-border-cell);
  border-bottom: 1px solid var(--color-border-cell);
  padding: 0 10px; height: var(--row-h, 38px); text-align: left;
  overflow: hidden;
  background: var(--color-surface);
}
.sp-grid th {
  position: sticky; top: 0; z-index: 3;
  background: var(--color-surface-alt);
  font-size: 12.5px; font-weight: 700; color: var(--color-text-label);
  user-select: none; cursor: pointer;
}
.sp-grid th .th-inner { display: flex; align-items: center; gap: 5px; height: 100%; }
.sp-grid th .th-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-grid th .th-sort { color: var(--color-primary); font-size: 11px; flex-shrink: 0; }
.sp-grid th .col-resizer {
  position: absolute; right: -4px; top: 0; width: 9px; height: 100%;
  cursor: col-resize; z-index: 5;
}
/* 리사이즈 경계선 하이라이트: hover/드래그 시 파란 세로선 (헤더 높이) */
.sp-grid th .col-resizer::after {
  content: ""; position: absolute; right: 4px; top: 0; width: 2px; height: 100%;
  background: transparent; transition: background .1s;
}
.sp-grid th .col-resizer:hover::after,
.sp-grid th .col-resizer.resizing::after { background: var(--color-primary); }
.sp-grid th .th-menu {
  margin-left: auto; border: none; background: none; cursor: pointer;
  color: var(--color-text-faint); font-size: 14px; font-weight: 700;
  padding: 0 3px; border-radius: 4px; line-height: 18px;
  visibility: hidden; flex-shrink: 0;
}
.sp-grid th:hover .th-menu { visibility: visible; }
.sp-grid th.vf-active .th-menu { visibility: visible; color: var(--color-primary); }
.sp-grid th .th-menu:hover {
  background: var(--color-border-cell); color: var(--color-text-2);
}
.sp-grid th.vf-active .th-label { color: var(--color-primary-ink); }
.sp-grid th.drag-over { box-shadow: inset 2px 0 0 var(--color-primary); }
.sp-grid td { color: var(--color-text-2); vertical-align: middle; }
.sp-grid tbody tr { cursor: pointer; }
.sp-grid tbody tr:hover td { background: var(--color-hover-bg); }
.sp-grid tbody tr.active td { background: var(--color-active-bg); }
.sp-grid .sticky-left { position: sticky; z-index: 2; }
.sp-grid th.sticky-left { z-index: 4; }
.sp-grid .group-row td {
  background: var(--color-bg-subtle); font-weight: 700; color: var(--color-text-2);
  position: sticky; left: 0;
}

/* 셀 텍스트: 제목 줄수(테이블 패널) 제어 대상.
   -webkit-line-clamp(레거시 박스 모델)는 <td> 안에서 줄 수 제한이 깨지기 쉽고
   레이아웃 계산도 무거워 400+행 규모에서 조절이 느려지는 원인이었다.
   대신 line-height를 고정해 max-height를 정확히 N줄 높이로 계산 → 줄 경계와
   딱 맞아 글자가 반쪽으로 잘리지 않고, 일반 block 레이아웃이라 계산도 가볍다. */
.sp-grid td .cell-txt { display: block; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-grid.tl-2 td, .sp-grid.tl-all td {
  height: auto; min-height: var(--row-h, 38px); overflow: visible; vertical-align: top;
}
.sp-grid.tl-2 td .cell-txt {
  white-space: normal; overflow: hidden; max-height: 2.7em; padding: 4px 0;
}
.sp-grid.tl-all td .cell-txt { white-space: normal; padding: 6px 0; }

/* 리사이즈 가이드 (전체 높이 세로선) — left 고정 + transform 이동(합성 전용, 리플로우 없음) */
.resize-guide {
  position: absolute; top: 0; left: 0; width: 2px; background: var(--color-primary);
  z-index: 20; pointer-events: none; display: none; will-change: transform;
}
.resize-guide.show { display: block; }
.resize-guide.dragging { box-shadow: 0 0 0 1px rgba(76, 110, 245, .25); }
.resize-guide .resize-chip {
  display: none; position: sticky; top: 44px;
  margin-left: 8px; padding: 2px 8px; border-radius: 5px;
  background: var(--color-primary); color: #fff;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.resize-guide.dragging .resize-chip { display: inline-block; }
body.col-resizing { cursor: col-resize; user-select: none; }
/* 드래그 중 행 hover 배경 계산도 차단 (합성 외 작업 제거) */
body.col-resizing .sp-grid tbody tr:hover td { background: var(--color-surface); }

.cell-idx { color: var(--color-text-faint); font-size: 13px; }
.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-date { font-variant-numeric: tabular-nums; color: var(--color-text-3); }
.cell-empty { color: var(--color-text-faint); }

.code-link { color: var(--color-text-2); font-weight: 400; }
.code-link:hover { color: var(--color-text); }

/* 배지 (이모지 금지 — 텍스트 태그만, 기능정의 §5) */
.badge {
  display: inline-flex; align-items: center;
  border-radius: var(--radius-sm); padding: 2px 8px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.badge-type-contract { background: var(--type-contract-bg); color: var(--type-contract-fg); }
.badge-type-advisory { background: var(--type-advisory-bg); color: var(--type-advisory-fg); }
.badge-type-academic { background: var(--type-academic-bg); color: var(--type-academic-fg); }
.badge-type-national { background: var(--type-national-bg); color: var(--type-national-fg); }
.badge-type-joint    { background: var(--type-joint-bg);    color: var(--type-joint-fg); }
.badge-type-support  { background: var(--type-support-bg);  color: var(--type-support-fg); }
.badge-type-etc      { background: var(--type-etc-bg);      color: var(--type-etc-fg); }
.badge-bool { background: var(--color-primary-bg); color: var(--color-primary-ink); font-size: 11.5px; }

.tag-chip {
  display: inline-flex; border-radius: 4px; padding: 2px 7px;
  font-size: 11.5px; font-weight: 700;
  background: var(--color-status-active-bg); color: var(--color-status-active-ink);
  margin-right: 4px;
}
.tag-chip.alt { background: var(--color-primary-bg); color: var(--color-primary-ink); }

/* 문서유형 배지 (기능정의 §5, 16종 색상) */
.badge-doc-blue { background: #e7f0ff; color: #1c5fd6; }
.badge-doc-indigo { background: #e7ecfb; color: #3b5bdb; }
.badge-doc-teal { background: #e2f5f3; color: #0d7d72; }
.badge-doc-orange { background: #fff0e2; color: #c2620f; }
.badge-doc-purple { background: #efeafd; color: #6941c6; }
.badge-doc-green { background: #e6f4ec; color: #1a7f4b; }
.badge-doc-gray { background: #eef0f2; color: #5b6370; }
.badge-doc-red { background: #ffe8e8; color: #c92a2a; }
.badge-doc-yellow { background: #fff9db; color: #b58a00; }
.badge-doc-pink { background: #fde8ef; color: #c2255c; }
.badge-doc-brown { background: #f3ece5; color: #8a5a2b; }
.badge-doc-olive { background: #eef2e0; color: #5c7000; }
.badge-doc-skyblue { background: #e3f2fd; color: #0b6bcb; }
.badge-doc-maroon { background: #f5e6e6; color: #922b3e; }
.badge-doc-navy { background: #e6e9f5; color: #2b3a67; }
.badge-doc-lightgray { background: #f1f2f4; color: #6b7280; }
.badge[class*="badge-doc-"] {
  display: inline-flex; align-items: center; border-radius: var(--radius-sm);
  padding: 2px 8px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}

.doc-table thead th { background: var(--color-surface-alt); }
.doc-table td { vertical-align: middle; }
/* 마감일 입력 (테이블 셀 안 — .form-field 밖이라 별도 스타일 필요) */
.due-input {
  border: 1px solid var(--color-border-input); border-radius: var(--radius-sm);
  padding: 5px 8px; font-size: 13.5px; background: var(--color-surface);
  color: var(--color-text); font-family: inherit;
}
.due-input:focus { outline: 2px solid #c9d5fb; border-color: var(--color-primary); }
/* 작업 열: 업로드/제출완료/삭제 버튼을 한 줄로 */
.doc-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; white-space: nowrap; }
/* 행 단위 드래그앤드롭 업로드 */
.doc-table tbody tr.drop-target { position: relative; }
.doc-table tbody tr.drop-target.drag-over { outline: 2px dashed var(--color-primary); outline-offset: -2px; background: var(--color-surface-alt); }
/* 드래그 중 대상 행 위에 겹쳐 표시되는 안내 오버레이 (커서를 따라다니지 않음) */
.doc-drop-note {
  position: fixed; z-index: 200; pointer-events: none; display: none;
  align-items: center; justify-content: center; text-align: center;
  background: color-mix(in srgb, var(--color-primary) 90%, transparent);
  color: #fff; font-size: 13.5px; font-weight: 700; padding: 0 14px;
  border-radius: var(--radius); box-shadow: inset 0 0 0 2px #fff;
}
.doc-drop-note.on { display: flex; }
/* 문서 페이지 드래그 중 텍스트 선택 방지 */
body.doc-dragging { user-select: none; }
/* 전체 문서현황 — 프로젝트명 화면폭 따라 가변 말줄임 */
.doc-dash-table { table-layout: fixed; width: 100%; }
.doc-dash-table td, .doc-dash-table th { overflow: hidden; }
.doc-dash-table td.dash-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0;
}
/* 프로젝트 코드 태그 + 제목 간격 (전체 문서현황) */
.dash-name .code-tag {
  display: inline-block; background: var(--color-primary-bg, #e7f0ff); color: var(--color-primary-ink);
  border-radius: var(--radius-sm); padding: 2px 8px; font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dash-name .dash-title { margin-left: 12px; color: var(--color-text-2); }

/* 상단 토스트 알림 */
.toast-wrap {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  pointer-events: auto; cursor: pointer; min-width: 220px; max-width: 90vw;
  padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  color: #fff; background: var(--color-text); box-shadow: 0 8px 28px rgba(20,30,60,.28);
  opacity: 0; transform: translateY(-12px); transition: opacity .2s, transform .2s;
  display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast::before { content: "ℹ"; font-weight: 800; }
.toast-ok, .toast-success { background: var(--color-ok, #0f8a4d); }
.toast-ok::before, .toast-success::before { content: "✓"; }
.toast-error { background: var(--color-status-stop, #c0392b); }
.toast-error::before { content: "✕"; }
.toast-warning { background: var(--color-warn, #b3540a); }
.toast-warning::before { content: "!"; }

/* 공용 태그 입력 (tagfield.js) */
.tagfield { position: relative; }
.tf-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  border: 1px solid var(--color-border-input); border-radius: var(--radius);
  padding: 5px 8px; background: var(--color-surface); min-height: 38px; cursor: text;
}
.tf-box:focus-within { outline: 2px solid #c9d5fb; border-color: var(--color-primary); }
.tf-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: 16px; padding: 2px 4px 2px 10px; font-size: 13px; font-weight: 600;
  color: var(--color-text);
}
.tf-x {
  border: none; background: transparent; cursor: pointer; font-size: 15px; line-height: 1;
  color: var(--color-text-muted); padding: 0 4px; border-radius: 50%;
}
.tf-x:hover { color: #fff; background: var(--color-status-stop); }
.tf-input { border: none; outline: none; flex: 1; min-width: 90px; font-size: 14px; background: transparent; color: var(--color-text); }
.tf-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 70;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,30,60,.16);
  max-height: 220px; overflow-y: auto; padding: 4px;
}
.tf-item { padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13.5px; cursor: pointer; }
.tf-item:hover, .tf-item.active { background: var(--color-surface-alt); color: var(--color-primary); font-weight: 600; }

/* NAS 문서 리스트 (문서현황 하단) */
.nas-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-2); }
.nas-file {
  display: inline-flex; align-items: center; gap: 7px; cursor: grab;
  border: 1px solid var(--color-border-input); border-radius: var(--radius);
  padding: 6px 11px; font-size: 13px; background: var(--color-surface); max-width: 340px;
}
.nas-file:hover { border-color: var(--color-primary); background: var(--color-surface-alt); }
.nas-file:active { cursor: grabbing; }
.nas-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nas-file-icon { flex: none; }

/* 삭제 모달 경고문 */
.warn-text {
  background: #fdf0ee; border: 1px solid #f0c4bd; border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 12.5px; line-height: 1.6; color: #8a3327; margin: 4px 0 2px;
}
.warn-text b { color: var(--color-status-stop); }

/* 업로드 모달 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 24, 40, .4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 440px; max-width: 92vw; background: var(--color-surface);
  border-radius: var(--radius-lg); padding: var(--space-5);
  box-shadow: 0 12px 40px rgba(20, 24, 40, .2);
  /* 내용이 길면 화면을 벗어나지 않고 모달 안에서 스크롤 */
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 var(--space-4); font-size: 16px; font-weight: 800; }
.modal .form-field { margin-bottom: var(--space-3); }
.modal .form-field input[type="file"] { font-size: 13.5px; }
/* 넓은 폼 모달 (논문 등 항목이 많은 경우) — 2열 배치 */
.modal.modal-wide { width: 720px; }
.modal.modal-wide .form-grid-2 {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2) var(--space-4);
}
.modal.modal-wide .form-grid-2 > .form-field { min-width: 0; }   /* 자식이 열 폭 안에서 줄어들 수 있게 */
.modal.modal-wide .form-grid-2 .full { grid-column: 1 / -1; }
/* 모달 내 입력요소가 셀 폭을 넘지 않도록 */
.modal .form-field input, .modal .form-field select, .modal .form-field textarea,
.modal .form-field .tagfield, .modal .form-field .tf-box {
  max-width: 100%; box-sizing: border-box;
}
.modal .tf-input { min-width: 40px; }

/* 상태 dot + 텍스트 */
.status-cell { display: inline-flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.st-active .status-dot { background: var(--color-status-active); }
.st-active .status-text { color: var(--color-status-active-ink); font-weight: 700; }
.st-done .status-dot { background: var(--color-status-done); }
.st-done .status-text { color: var(--color-status-done-ink); font-weight: 700; }
.st-hold .status-dot { background: var(--color-status-hold); }
.st-hold .status-text { color: var(--color-status-hold-ink); font-weight: 700; }
.st-stopped .status-dot { background: var(--color-status-stop); }
.st-stopped .status-text { color: var(--color-status-stop-ink); font-weight: 700; }

.status-badge {
  display: inline-flex; padding: 4px 10px; border-radius: 6px;
  font-weight: 700; font-size: 13px;
}
.status-badge.st-active { background: var(--color-status-active-bg); color: var(--color-status-active-ink); }
.status-badge.st-done { background: var(--color-status-done-bg); color: var(--color-status-done-ink); }
.status-badge.st-hold { background: var(--color-status-hold-bg); color: var(--color-status-hold-ink); }
.status-badge.st-stopped { background: var(--color-status-stop-bg); color: var(--color-status-stop-ink); }

/* 아바타 */
.user-chip { display: inline-flex; align-items: center; gap: 6px; }
.uc-circle {
  width: 23px; height: 23px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  border: 1.5px solid var(--color-surface);
}
.uc-name { font-size: 14px; }
.user-multi { display: inline-flex; align-items: center; }
.user-multi .uc-circle { margin-right: -5px; }
.user-multi .uc-more {
  margin-left: 9px; font-size: 12px; color: var(--color-text-muted);
}
.avatar-0 { background: #e7f0ff; color: #1c5fd6; }
.avatar-1 { background: #e6f4ec; color: #1a7f4b; }
.avatar-2 { background: #efeafd; color: #6941c6; }
.avatar-3 { background: #fff0e2; color: #c2620f; }
.avatar-4 { background: #e2f5f3; color: #0d7d72; }
.avatar-5 { background: #fde8ef; color: #c2255c; }

/* 프로그레스 (문서제출률) */
.progress-cell { display: flex; align-items: center; gap: 8px; }
.progress-track {
  flex: 1; height: 6px; background: var(--color-border-cell);
  border-radius: 4px; overflow: hidden; min-width: 40px;
}
.progress-fill { height: 100%; border-radius: 4px; }
.progress-low .progress-fill { background: var(--color-status-stop); }
.progress-mid .progress-fill { background: var(--color-status-hold); }
.progress-high .progress-fill { background: var(--color-status-active); }
.progress-pct { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   팝오버 (필터/그룹/컬럼)
   -------------------------------------------------------------------------- */
.popover {
  position: absolute; z-index: 50; min-width: 260px; max-width: 420px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 28px rgba(20, 24, 40, .13);
  padding: var(--space-3);
}
.popover h4 {
  margin: 0 0 var(--space-2); font-size: 13px; color: var(--color-text-label);
  font-weight: 700;
}
.popover .pop-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.popover select, .popover input[type="text"], .popover input[type="number"] {
  border: 1px solid var(--color-border-input); border-radius: 6px;
  padding: 6px 8px; font-size: 13.5px; background: var(--color-surface);
}
.popover .pop-actions { display: flex; gap: 6px; margin-top: var(--space-2); justify-content: flex-end; }
/* 필터 팝오버 — 값 필터/고급 필터 통합 */
.popover .pop-hint { font-size: 11.5px; color: var(--color-text-muted); margin: 0 0 8px; line-height: 1.5; }
.popover .pop-empty { font-size: 13px; color: var(--color-text-muted); margin: 6px 0 10px; }
.popover .col-check { display: flex; align-items: center; gap: 8px; padding: 5px 2px; cursor: pointer; font-size: 14px; }
.popover .col-check input { accent-color: var(--color-primary); }
.popover .col-list { max-height: 320px; overflow-y: auto; }
.popover .menu-item {
  display: flex; width: 100%; align-items: center; gap: 7px;
  border: none; background: none; cursor: pointer; text-align: left;
  padding: 8px 9px; border-radius: 6px; font-size: 14px;
  color: var(--color-text-2); font-weight: 500;
}
.popover .menu-item:hover { background: var(--color-hover-bg); }
.popover .menu-item.on {
  background: var(--color-active-bg); color: var(--color-primary-ink); font-weight: 700;
}
.popover .menu-sep { height: 1px; background: var(--color-border-cell); margin: 5px 0; }

/* 빠른 값 필터 서브메뉴 */
.popover .pop-head { display: flex; align-items: center; gap: 6px; margin-bottom: var(--space-2); }
.popover .pop-head h4 { margin: 0; }
.popover .pop-back {
  border: none; background: none; cursor: pointer; font-size: 19px; line-height: 1;
  color: var(--color-text-muted); padding: 0 4px; border-radius: 4px;
}
.popover .pop-back:hover { background: var(--color-hover-bg); color: var(--color-text); }
.popover .vf-search { margin-bottom: 6px; }
.popover .vf-search input { width: 100%; }
.popover .vf-bulk { justify-content: flex-start; margin: 0 0 6px; }
.popover .vf-list { max-height: 260px; min-width: 220px; }
.popover .vf-item { justify-content: flex-start; }
.popover .vf-item .vf-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover .vf-item .vf-count {
  margin-left: auto; font-size: 11.5px; color: var(--color-text-faint);
  background: var(--color-border-cell); border-radius: 9px; padding: 0 6px;
}

/* 테이블 UI 패널 */
.popover .panel-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.popover .panel-label { font-size: 13px; color: var(--color-text-label); width: 56px; flex-shrink: 0; }
.popover .seg-btns { display: inline-flex; gap: 2px; }
.popover .seg-btns button {
  border: 1px solid var(--color-border-input); background: var(--color-surface);
  cursor: pointer; font-size: 13px; padding: 5px 11px; color: var(--color-text-2);
}
.popover .seg-btns button:first-child { border-radius: 6px 0 0 6px; }
.popover .seg-btns button:last-child { border-radius: 0 6px 6px 0; }
.popover .seg-btns button.on { background: var(--color-active-bg); color: var(--color-primary-ink); border-color: #c9d3fb; font-weight: 700; }

/* --------------------------------------------------------------------------
   카드/폼/상세 공통
   -------------------------------------------------------------------------- */
.content { flex: 1; overflow-y: auto; padding: var(--space-5); background: var(--color-bg-subtle); }
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-5);
  margin-bottom: var(--space-4); max-width: 980px;
}
.card h3 {
  margin: 0 0 var(--space-4); font-size: 16px; font-weight: 800;
  color: var(--color-text);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-5); }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 700; color: var(--color-text-label); }
.form-field label .req { color: var(--color-status-stop); }
.form-field input[type="text"], .form-field input[type="password"],
.form-field input[type="email"], .form-field input[type="number"],
.form-field input[type="date"], .form-field input[type="tel"],
.form-field select, .form-field textarea {
  border: 1px solid var(--color-border-input); border-radius: var(--radius);
  padding: 9px 11px; font-size: 14.5px; background: var(--color-surface);
  color: var(--color-text);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: 2px solid #c9d5fb; border-color: var(--color-primary);
}
/* 자동완성 시 한쪽 필드만 배경색이 바뀌어 달라 보이는 현상 방지 (아이디/비번 통일) */
.form-field input:-webkit-autofill,
.form-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--color-text);
  box-shadow: 0 0 0 1000px var(--color-surface) inset;
}
.form-field select[multiple] { min-height: 90px; }
.form-field .hint { font-size: 12.5px; color: var(--color-text-faint); }
.form-actions { display: flex; gap: var(--space-2); margin-top: var(--space-4); }

.collapse-toggle {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-weight: 700; color: var(--color-text-3); font-size: 14px;
  padding: var(--space-2) 0; border: none; background: none;
}
.collapse-toggle .caret { transition: transform .15s; font-size: 11px; }
.collapse-toggle.open .caret { transform: rotate(90deg); }
.collapse-body { display: none; }
.collapse-body.open { display: block; }

.radio-group { display: flex; gap: var(--space-4); align-items: center; padding: 6px 0; }
.radio-group label { font-size: 14px; font-weight: 500; color: var(--color-text-2); display: flex; gap: 5px; align-items: center; }
.radio-group input { accent-color: var(--color-primary); }

.form-msg { font-size: 14px; font-weight: 600; padding: 9px 0; }
.form-msg.error { color: var(--color-status-stop-ink); }
.form-msg.ok { color: var(--color-status-active-ink); }

/* 상세 화면 */
.detail-header {
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-5) 0;
}
.detail-title-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.detail-title-row h2 { margin: 0; font-size: 20px; }
.detail-tabs { display: flex; gap: 2px; margin-top: var(--space-3); }
.detail-tab {
  padding: 10px 16px; font-weight: 700; font-size: 14px; cursor: pointer;
  color: var(--color-text-muted); border: none; background: none;
  border-bottom: 2px solid transparent;
}
.detail-tab.active { color: var(--color-primary-ink); border-bottom-color: var(--color-primary); }
.detail-tab:disabled { color: var(--color-text-faint); cursor: not-allowed; }
.detail-tab .count { font-size: 12px; color: var(--color-text-faint); }

.info-table { width: 100%; border-collapse: collapse; }
.info-table th {
  text-align: left; width: 150px; padding: 10px 10px;
  font-size: 13px; color: var(--color-text-label); font-weight: 700;
  vertical-align: top; line-height: 1.5;
}
.info-table td { padding: 10px 10px; font-size: 14.5px; color: var(--color-text-2); line-height: 1.5; }
.info-table tr { border-bottom: 1px solid var(--color-border-cell); }
.info-table tr:last-child { border-bottom: none; }

.placeholder-box {
  border: 1.5px dashed var(--color-border-input); border-radius: var(--radius-lg);
  padding: var(--space-6); text-align: center; color: var(--color-text-faint);
  font-size: 14px;
}

/* 메일그룹 주소 복사 */
.email-copy {
  width: 100%; border: 1px solid var(--color-border-input); border-radius: var(--radius);
  padding: 9px 11px; font-size: 13.5px; color: var(--color-text-3);
  background: var(--color-surface-alt); resize: vertical;
}

/* 이벤트 타임라인 (SCR-PRJ-02 이벤트 탭) */
.ev-filter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.ev-keywords { display: flex; flex-wrap: wrap; gap: 6px; }
.ev-kw-chip {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  border: 1px solid var(--color-border-input); border-radius: 20px;
  padding: 4px 11px; font-size: 13px; color: var(--color-text-2); user-select: none;
}
.ev-kw-chip input { accent-color: var(--color-primary); }
.ev-kw-chip:has(input:checked) { border-color: var(--color-primary); background: var(--color-surface-alt); color: var(--color-text); font-weight: 600; }
/* 추천 키워드 설명 노트 (설명처럼 보이게) */
.ev-rec {
  flex-basis: 100%; display: flex; align-items: center; gap: 8px;
  background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 8px 12px; font-size: 12.5px; color: var(--color-text-muted);
}
.ev-rec-text b { color: var(--color-text); }
/* 정보(!) 툴팁 */
.info-tip { position: relative; display: inline-flex; cursor: help; outline: none; }
.info-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 50%; background: var(--color-primary);
  color: #fff; font-size: 11px; font-weight: 800; line-height: 1;
}
.info-bubble {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: 320px; max-width: 70vw; background: var(--color-text); color: #fff;
  font-size: 12px; line-height: 1.6; font-weight: 400; padding: 10px 12px;
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,30,60,.28);
  opacity: 0; visibility: hidden; transition: opacity .12s; z-index: 60; text-align: left;
}
.info-bubble b { color: #ffd; }
.info-bubble::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--color-text);
}
.info-tip:hover .info-bubble, .info-tip:focus .info-bubble, .info-tip:focus-within .info-bubble {
  opacity: 1; visibility: visible;
}
.ev-timeline { display: flex; flex-direction: column; gap: var(--space-4); }
.ev-item { border-left: 2px solid var(--color-border); padding: 0 0 var(--space-2) var(--space-4); position: relative; }
.ev-item::before {
  content: ""; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--color-primary);
}
.ev-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ev-date { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-text); }
.ev-writer { font-size: 13px; color: var(--color-text-muted); }
.ev-del { margin-left: auto; border: none; background: none; cursor: pointer; color: var(--color-text-faint); font-size: 16px; line-height: 1; }
.ev-del:hover { color: var(--color-status-stop); }
.ev-title { font-weight: 700; margin-bottom: 2px; }
.ev-content { color: var(--color-text-2); white-space: pre-wrap; line-height: 1.6; }
.ev-memo { margin-top: 5px; font-size: 13px; color: var(--color-text-muted); background: var(--color-bg-subtle); border-radius: 6px; padding: 6px 10px; }
mark.ev-kw { background: #fff3bf; color: #856404; padding: 0 2px; border-radius: 2px; }

/* 논문 카드 (SCR-PAP-01) */
.paper-card { border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); }
.paper-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.paper-meta { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: 13.5px; color: var(--color-text-3); align-items: center; }
.paper-co { margin-top: 5px; font-size: 13px; color: var(--color-text-muted); }
.paper-pres { margin-top: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--color-border-cell); }
.pres-item { font-size: 13.5px; color: var(--color-text-2); padding: 4px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal details summary { cursor: pointer; font-weight: 700; color: var(--color-text-3); padding: 6px 0; }
.modal details label { display: block; font-size: 12px; font-weight: 700; color: var(--color-text-label); margin-top: 6px; }
.modal select[multiple] { width: 100%; }

/* 간트차트 (R-027·028) */
.gantt { display: flex; flex-direction: column; gap: 8px; }
.gantt-row { display: grid; grid-template-columns: 200px 1fr 240px; align-items: center; gap: var(--space-3); }
.gantt-label { display: flex; flex-direction: column; }
.gantt-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-track { position: relative; height: 22px; background: var(--color-border-cell); border-radius: 5px; }
/* 막대 = 기간(연한 색), 안쪽 채움 = 진행률(진한 색) — 채워진 만큼 진행됨을 직관적으로 표현 */
.gantt-bar {
  --bar-c: var(--color-primary);
  position: absolute; top: 0; height: 22px; border-radius: 5px;
  background: color-mix(in srgb, var(--bar-c) 22%, #ffffff);
  border: 1px solid color-mix(in srgb, var(--bar-c) 45%, #ffffff);
  min-width: 8px; overflow: hidden;
  display: flex; align-items: center;
}
.gantt-bar.done { --bar-c: var(--color-status-active); }
.gantt-bar.delayed { --bar-c: var(--color-status-stop); }
.gantt-progress { position: absolute; left: 0; top: 0; height: 100%; background: var(--bar-c); }
.gantt-bar-text {
  position: relative; color: var(--color-text); font-size: 11px; font-weight: 700;
  padding: 0 6px; text-shadow: 0 0 3px rgba(255,255,255,.75);
}
.gantt-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--color-text-muted); flex-wrap: wrap; }
@media (max-width: 860px) { .gantt-row { grid-template-columns: 1fr; } .gantt-track { display: none; } }

/* 대시보드 그리드 (SCR-DSH-01) */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.dash-grid .card { margin-bottom: 0; max-width: none; }
.dash-grid .dash-wide { grid-column: 1 / -1; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } }
.kpi-row { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.kpi { flex: 1; min-width: 120px; text-align: center; padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius); }
.kpi-num { display: block; font-size: 30px; font-weight: 800; color: var(--color-primary-ink); }
.kpi-label { font-size: 13px; color: var(--color-text-muted); }

/* SOP 워크플로 (Phase 5) */
.wf-steps { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.wf-step {
  flex: 1; min-width: 180px; border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: var(--space-3);
  display: flex; flex-direction: column; gap: 4px;
}
.wf-step.done { border-color: var(--color-status-active); background: var(--color-status-active-bg); }
.wf-role { font-size: 12px; font-weight: 700; color: var(--color-text-label); }
.wf-user { font-weight: 700; }
.wf-sig { font-size: 12.5px; color: var(--color-text-muted); }
.wf-step.done .wf-sig { color: var(--color-status-active-ink); font-weight: 700; }
.wf-step .btn { margin-top: 6px; align-self: flex-start; }

/* 검토의견 */
/* SOP 대시보드 막대 (파이프라인·분류분포) */
.sop-bar-row { display: flex; align-items: center; gap: 12px; margin: 7px 0; }
.sop-bar-label { flex: 0 0 90px; font-size: 13.5px; font-weight: 600; color: var(--color-text-2); }
.sop-bar-track { flex: 1; height: 18px; background: var(--color-border-cell); border-radius: 5px; overflow: hidden; }
.sop-bar-fill { display: block; height: 100%; background: var(--color-primary); border-radius: 5px; }
.sop-bar-n { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--color-text); min-width: 40px; text-align: right; }
/* SOP 대시보드 — 카드 전폭 + 내용 높이만큼(내부 빈공간 제거) */
.sop-dashboard .card { max-width: none; }
.sop-dashboard .dash-grid { align-items: start; gap: var(--space-4); }
.sop-dashboard .dash-grid .card { margin-bottom: 0; }
.sop-dashboard .kpi-row { margin-bottom: var(--space-4); }
.sop-dashboard > .dash-grid { margin-bottom: var(--space-4); }

/* 주기 검토 현황 — 3분할 타일 */
.review-aging { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-3); margin-top: 4px; }
.review-aging .ra-item { text-align: center; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 8px; }
.review-aging .ra-n { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.review-aging .ra-l { font-size: 12px; color: var(--color-text-muted); line-height: 1.4; }
.review-aging .ra-danger { background: var(--color-status-stop-bg); }
.review-aging .ra-danger .ra-n { color: var(--color-status-stop-ink); }
.review-aging .ra-warn { background: var(--color-status-hold-bg); }
.review-aging .ra-warn .ra-n { color: var(--color-status-hold-ink); }
.review-aging .ra-ok { background: var(--color-status-active-bg); }
.review-aging .ra-ok .ra-n { color: var(--color-status-active-ink); }
/* 최근 업데이트 리스트 */
.dash-recent { display: flex; flex-direction: column; }
.dash-recent-item { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid var(--color-border-cell); text-decoration: none; color: var(--color-text); }
.dash-recent-item:last-child { border-bottom: none; }
.dash-recent-item:hover { background: var(--color-hover-bg); }
.dash-recent-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.review-comment { border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-2); }
.review-comment.resolved { background: var(--color-bg-subtle); opacity: .85; }
.rc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; font-size: 13px; }
.rc-head .btn { margin-left: auto; }
.rc-selected { font-size: 13px; color: var(--color-text-muted); font-style: italic; border-left: 2px solid var(--color-border); padding-left: 8px; margin-bottom: 4px; }
.rc-text { color: var(--color-text-2); white-space: pre-wrap; line-height: 1.5; }
.rc-reply { margin: 8px 0 0 18px; padding: 8px 12px; border-left: 2px solid var(--color-primary); background: var(--color-surface-alt); border-radius: 0 6px 6px 0; font-size: 13.5px; }
.rc-reply-who { font-weight: 700; margin-right: 6px; }

/* SOP 검토중 상태 배지 */
.status-badge.st-review { background: var(--color-primary-bg, #e7f0ff); color: var(--color-primary-ink); }

/* 반려 배너 */
.return-banner {
  background: #fdf0ee; border: 1px solid #f0c4bd; border-left: 4px solid var(--color-status-stop);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: var(--space-4);
  font-size: 14px; color: #8a3327; line-height: 1.6;
}
.return-banner b { color: var(--color-status-stop); margin-right: 6px; }

/* SOP 승인 워크플로 스테퍼 */
.sop-stepper { display: flex; gap: 0; flex-wrap: wrap; }
.sop-step {
  flex: 1; min-width: 150px; position: relative; text-align: center;
  padding: 14px 10px 12px; border-top: 3px solid var(--color-border);
}
.sop-step:not(:last-child)::after {
  content: ""; position: absolute; top: -3px; right: 0; width: 0; height: 0;
}
.sop-step.done { border-top-color: var(--color-status-active); }
.sop-step.current { border-top-color: var(--color-primary); background: var(--color-primary-bg, #e7f0ff); }
.sop-step-dot {
  width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
  background: var(--color-border-cell); color: var(--color-text-muted);
}
.sop-step.done .sop-step-dot { background: var(--color-status-active); color: #fff; }
.sop-step.current .sop-step-dot { background: var(--color-primary); color: #fff; }
.sop-step-role { font-weight: 700; font-size: 14px; }
.sop-step-user { font-size: 13px; color: var(--color-text-2); margin: 2px 0; }
.sop-step-sig { font-size: 12px; color: var(--color-text-muted); margin-bottom: 6px; }

/* SOP 문서 목차 (좌측 아웃라인) */
.sop-toc { position: sticky; top: 12px; padding: var(--space-3) 4px; }
.sop-toc-title { font-size: 12px; font-weight: 700; color: var(--color-text-muted); letter-spacing: .02em; margin-bottom: 8px; padding-left: 12px; }
.sop-toc ol { margin: 0; padding: 0; list-style: none; }
.sop-toc a { display: block; padding: 6px 10px; border-radius: 6px;
  color: var(--color-text-2); text-decoration: none; font-size: 13px; line-height: 1.4; }
.sop-toc a:hover { background: var(--color-hover-bg); color: var(--color-text); }
.sop-toc a.active { color: var(--color-primary-ink); font-weight: 700; background: var(--color-active-bg); }

/* 검토 뷰어 3열 레이아웃 (목차 · 문서 본문 · 우측 코멘트 레일) */
.sop-review-layout {
  display: grid; grid-template-columns: 190px minmax(0, 1fr) 370px;
  gap: var(--space-4); align-items: start;
}
@media (max-width: 1200px) { .sop-review-layout { grid-template-columns: 1fr; } }

/* SOP 본문을 실제 '문서(페이퍼)'처럼 */
.sop-doc { min-width: 0; }
.sop-doc-page {
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(20,30,60,.06), 0 8px 24px rgba(20,30,60,.05);
  padding: 48px 56px; max-width: 820px; margin: 0 auto;
}
@media (max-width: 720px) { .sop-doc-page { padding: 28px 22px; } }
.sop-doc-head { text-align: center; border-bottom: 2px solid var(--color-text); padding-bottom: 18px; margin-bottom: 8px; }
.sop-doc-id { font-size: 13px; font-weight: 700; color: var(--color-primary-ink); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.sop-doc-title { font-size: 22px; font-weight: 800; margin: 8px 0 6px; line-height: 1.35; color: var(--color-text); }
.sop-doc-sub { font-size: 12.5px; color: var(--color-text-muted); }
.sop-section { padding: 0; border: none; scroll-margin-top: 16px; }
.sop-doc-h { font-size: 17px; font-weight: 700; color: var(--color-text); margin: 30px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--color-border-cell); }
.sop-doc-hn { color: var(--color-primary); margin-right: 6px; font-variant-numeric: tabular-nums; }
.sop-sec-content { line-height: 1.85; color: var(--color-text); font-size: 14.5px; white-space: pre-wrap; }
/* 블록 요소는 pre-wrap 영향에서 정상 흐름 유지 */
.sop-sec-content p, .sop-sec-content ul, .sop-sec-content ol, .sop-sec-content table { white-space: normal; }
.sop-sec-content p { margin: 0 0 12px; }
.sop-sec-content ul, .sop-sec-content ol { margin: 0 0 12px; padding-left: 22px; }
.sop-sec-content table { border-collapse: collapse; width: 100%; margin: 8px 0 14px; }
.sop-sec-content th, .sop-sec-content td { border: 1px solid var(--color-border); padding: 7px 10px; font-size: 13.5px; }
.sop-sec-content ::selection { background: #ffe08a; }
.sop-doc-empty { color: var(--color-text-faint); font-style: italic; }

/* 하이브리드 검토 코멘트 레일 (문서 위치형 ↔ 목록형) */
.sop-comment-rail { position: relative; }
.sop-comment-rail[data-mode="list"] {
  position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-3);
}
.crail-controls {
  position: sticky; top: 8px; z-index: 6; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 10px 12px; margin-bottom: 8px;
}
.sop-comment-rail[data-mode="list"] .crail-controls { position: static; border: none; padding: 0 0 8px; margin: 0; }
.crail-head { display: flex; align-items: center; gap: 8px; }
.crail-head h3 { margin: 0; font-size: 15px; }
.crail-toolbar { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.crail-modes { display: inline-flex; border: 1px solid var(--color-border-input); border-radius: 8px; overflow: hidden; }
.crail-mode { border: none; background: var(--color-surface); padding: 4px 10px; font-size: 12.5px; cursor: pointer; color: var(--color-text-2); }
.crail-mode.active { background: var(--color-active-bg); color: var(--color-primary-ink); font-weight: 700; }
.crail-tabs { display: flex; gap: 4px; }
.crail-tab { border: 1px solid var(--color-border-input); background: var(--color-surface); border-radius: 16px; padding: 3px 12px; font-size: 12.5px; cursor: pointer; color: var(--color-text-2); }
.crail-tab.active { background: var(--color-active-bg); color: var(--color-primary-ink); border-color: var(--color-primary); font-weight: 700; }

.crail-canvas { position: relative; }
.sop-comment-rail[data-mode="list"] .crail-canvas { display: flex; flex-direction: column; gap: 8px; }

.crail-card {
  left: 0; right: 0; width: 100%; box-sizing: border-box;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 8px 10px; background: var(--color-surface); cursor: pointer;
  transition: box-shadow .12s, border-color .12s;
}
.sop-comment-rail[data-mode="anchored"] .crail-card { position: absolute; }
.crail-card:hover, .crail-card.hl { border-color: var(--color-primary); }
.crail-card.expanded { z-index: 20; box-shadow: 0 4px 18px rgba(20,30,60,.22); border-color: var(--color-primary); }
.crail-card[data-status="resolved"] { opacity: .7; }
.crail-full { display: none; }
.crail-card.expanded .crail-full { display: block; }
.crail-card.expanded .crail-preview { display: none; }
.crail-top { display: flex; align-items: center; gap: 6px; }
.crail-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-status-hold); flex: none; }
.crail-card[data-status="answered"] .crail-dot { background: var(--color-primary); }
.crail-card[data-status="resolved"] .crail-dot { background: var(--color-status-active); }
.crail-preview { font-size: 12.5px; color: var(--color-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.crail-meta { font-size: 12.5px; color: var(--color-text-muted); margin: 4px 0; }
.crail-quote { font-size: 12.5px; color: var(--color-text-muted); font-style: italic; border-left: 3px solid #ffd43b; padding-left: 8px; margin-bottom: 5px; }
.crail-text { font-size: 13.5px; color: var(--color-text-2); line-height: 1.55; }
.crail-reply { margin: 7px 0 0 12px; padding: 6px 10px; border-left: 2px solid var(--color-primary); background: var(--color-surface-alt); border-radius: 0 6px 6px 0; font-size: 12.5px; }
.crail-reply-who { font-weight: 700; margin-right: 5px; }
.crail-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.crail-empty { text-align: center; color: var(--color-text-faint); font-size: 13px; padding: 24px 8px; line-height: 1.7; }

/* 밀집 클러스터 핀 + 스레드 팝오버 */
.crail-pin {
  position: absolute; left: 0; right: 0; margin: 0 auto; width: max-content;
  border: 1px solid var(--color-primary); background: var(--color-primary-bg, #e7f0ff);
  color: var(--color-primary-ink); border-radius: 14px; padding: 3px 12px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; z-index: 3;
}
.crail-cluster-pop {
  position: absolute; left: 0; right: 0; z-index: 30; max-height: 60vh; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-primary); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(20,30,60,.28); padding: 8px; display: flex; flex-direction: column; gap: 8px;
}

/* 본문 앵커 하이라이트 */
.cmt-anchor { background: #fff3bf; border-radius: 2px; padding: 0 1px; cursor: pointer; }
.cmt-anchor.hl { background: #ffd43b; box-shadow: 0 0 0 2px #ffd43b; }

/* 코멘트 연결 곡선 오버레이 */
.cmt-svg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
.cmt-curve { fill: none; stroke: var(--color-primary); stroke-width: 2; opacity: .85; }
.info-table td h3, .info-table td h4 { margin: 4px 0; }
.info-table td ul, .info-table td ol { margin: 4px 0; padding-left: 20px; }

/* 로그인 */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--color-bg);
}
.login-card {
  width: 380px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: var(--space-6); box-shadow: 0 8px 28px rgba(20, 24, 40, .08);
}
.login-card h1 { font-size: 20px; margin: 0 0 var(--space-5); display: flex; gap: 9px; align-items: center; }
.login-card .form-field { margin-bottom: var(--space-3); }
.login-card .btn { width: 100%; justify-content: center; margin-top: var(--space-2); }
/* 테스트 서버 전용 빠른 로그인 링크 */
.dev-login {
  margin-top: var(--space-4); padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border); text-align: center;
  font-size: 13px; color: var(--color-text-muted);
}
.dev-login-label { margin-right: 6px; }
.dev-login-link { color: var(--color-primary); text-decoration: none; margin: 0 3px; font-weight: 600; }
.dev-login-link:hover { text-decoration: underline; }

/* 모바일 (기능정의 §6) */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; height: auto; padding: var(--space-2) var(--space-3); }
  .search-box { width: 100%; }
}

/* ==================== 리소스 맵 (주임교수) ==================== */
.sidebar-wip {
  font-size: 10.5px; color: var(--color-text-muted);
  background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 1px;
}
.toolbar-desc { font-size: 12.5px; color: var(--color-text-muted); margin-left: 10px; }
.rm-select {
  border: 1px solid var(--color-border-input); border-radius: 8px;
  padding: 7px 10px; font-size: 13.5px; background: var(--color-surface); margin-left: 6px;
}
.rm-content .rm-card { max-width: none; padding: 0; overflow: hidden; }

/* 헤더/행 공통 레이아웃 */
.rm-head { display: flex; align-items: stretch; border-bottom: 1px solid var(--color-border); background: var(--color-surface-alt); }
.rm-head-person { align-items: center; gap: 10px; padding: 10px 14px; background: var(--color-surface); }
.rm-ptitle { font-size: 16px; font-weight: 700; }
.rm-namecol { width: 190px; min-width: 190px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; border-right: 1px solid var(--color-border); }
.rm-head .rm-namecol { font-size: 12px; color: var(--color-text-muted); font-weight: 600; }
.rm-timeline-head { flex: 1; min-width: 0; }
.rm-months { display: flex; }
.rm-month {
  font-size: 11.5px; color: var(--color-text-muted); text-align: center;
  padding: 7px 0 6px; border-left: 1px solid var(--color-border);
  overflow: hidden; white-space: nowrap;
}
.rm-month:first-child { border-left: none; }
.rm-month-cur { color: var(--color-primary-ink); font-weight: 700; background: var(--color-active-bg); }

.rm-row { display: flex; border-bottom: 1px solid var(--color-border); }
.rm-row:hover { background: var(--color-surface-alt); }
.rm-person { background: none; border: none; padding: 0; text-align: left; cursor: pointer; min-width: 0; }
.rm-pname { display: block; font-size: 14px; font-weight: 600; color: var(--color-text); }
.rm-person:hover .rm-pname { color: var(--color-primary); text-decoration: underline; }
.rm-pmeta { display: block; font-size: 11.5px; color: var(--color-text-muted); margin-top: 1px; }
.rm-load { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--color-text-muted); }
.rm-load-zero { color: #b08585; }
.rm-empty { padding: 24px 16px; }

/* 타임라인 + 간트 바 (차분한 저채도 팔레트) */
.rm-timeline { flex: 1; min-width: 0; position: relative; }
.rm-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--color-border); opacity: .55; pointer-events: none; }
.rm-curshade { position: absolute; top: 0; bottom: 0; background: var(--color-active-bg); opacity: .5; pointer-events: none; }
.rm-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #c47f6a; opacity: .75; pointer-events: none; }
.rm-bar {
  position: absolute; height: 21px; border-radius: 5px;
  display: flex; align-items: center; padding: 0 7px;
  font-size: 11px; font-weight: 600; color: #fff;
  cursor: pointer; overflow: hidden; white-space: nowrap;
  transition: transform .14s ease, box-shadow .14s ease;
}
.rm-bar { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); }
.rm-bar:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(40, 60, 80, .28); }
.rm-bar-label { overflow: hidden; text-overflow: ellipsis; }
.rm-st-active  { background: #64809e; }
.rm-st-done    { background: #a3adb8; }
.rm-st-hold    { background: #b9a582; }
.rm-st-stopped { background: #a98c8c; }
/* 전체 보기 — 연구구분별 색 (저채도 팔레트) */
.rm-ty-contract { background: #64809e; }   /* 위탁연구 — 청회색 */
.rm-ty-academic { background: #7d9b76; }   /* 학술연구 — 세이지 */
.rm-ty-national { background: #a08bab; }   /* 국책과제 — 모브 */
.rm-ty-joint    { background: #6f9a9c; }   /* 공동연구 — 청록회색 */
.rm-ty-advisory { background: #b9a582; }   /* 자문연구 — 모래색 */
.rm-ty-support  { background: #8d9bb0; }   /* 지원연구 — 회청색 */
.rm-ty-etc      { background: #9aa5b1; }   /* 기타 — 회색 */
.rm-legend {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 14px; border-bottom: 1px solid var(--color-border);
  font-size: 12px; color: var(--color-text-muted);
}
.rm-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.rm-legend .lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 전체 보기 — 바 호버 풍선도움말 */
.rm-d-name { font-weight: 600; }
.rm-tip {
  position: fixed; z-index: 300; max-width: 420px; min-width: 260px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(30, 45, 60, .18);
  padding: 11px 13px; font-size: 13px;
  opacity: 0; visibility: hidden; transform: translateY(3px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
.rm-tip.show { opacity: 1; visibility: visible; transform: none; }
.rm-tip::after {                               /* 풍선 꼬리 (기본: 아래쪽 꼬리 = 바 위에 표시) */
  content: ''; position: absolute; left: var(--ax, 50%); bottom: -6px;
  width: 10px; height: 10px; margin-left: -5px; transform: rotate(45deg);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
}
.rm-tip.below::after {                         /* 바 아래에 표시될 때는 위쪽 꼬리 */
  bottom: auto; top: -6px;
  border: none; border-left: 1px solid var(--color-border); border-top: 1px solid var(--color-border);
}
.rm-tip-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; line-height: 1.4; }
.rm-tip-row { color: var(--color-text-muted); margin: 2px 0; }
.rm-tip .rm-goto { margin-top: 8px; }

/* 개인 상세 — 주차 스냅 마커 + 이벤트 풍선 */
.rm-pcode { cursor: help; }
.rm-snap {
  position: absolute; top: 0; bottom: 0; z-index: 5; pointer-events: none;
  background: rgba(100, 128, 158, .16);
  border-left: 1px solid #8fa5ba; border-right: 1px solid #8fa5ba;
}
.rm-snap-label {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 10.5px; font-weight: 700; color: #fff;
  background: #64809e; border-radius: 999px; padding: 1px 8px;
  box-shadow: 0 1px 4px rgba(40, 60, 80, .25);
}
.rm-tip-week { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; font-size: 12.5px; }
.rm-tip-evs { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.rm-wtabs { display: flex; gap: 4px; }
.rm-wtab {
  border: 1px solid var(--color-border); background: var(--color-surface);
  border-radius: 999px; padding: 3px 11px; font-size: 12px; cursor: pointer; color: var(--color-text-muted);
}
.rm-wtab.on { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 600; }
.rm-evlist { margin-top: 4px; }
.rm-ev { border-top: 1px solid var(--color-border); }
.rm-ev:first-child { border-top: none; }
.rm-ev-title {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 7px 4px; font-size: 13px; cursor: pointer; color: var(--color-text);
}
.rm-ev-title:hover { color: var(--color-primary); }
.rm-ev-date { font-size: 11.5px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.rm-ev-writer { font-size: 11.5px; color: var(--color-text-muted); margin-left: 6px; }
.rm-ev-body {
  padding: 2px 8px 11px 8px; font-size: 13px; line-height: 1.7;
  color: var(--color-text); white-space: normal;
}

/* 대시보드 리소스 현황 가젯 */
.resource-gadget h3 { display: flex; align-items: center; gap: 10px; }
.rg-month { font-size: 12.5px; color: var(--color-text-muted); font-weight: 500; }
.rg-open { margin-left: auto; }
.rg-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-top: var(--space-3); }
.rg-subtitle { font-size: 12px; font-weight: 700; color: var(--color-text-muted); margin-bottom: 6px; }
@media (max-width: 860px) { .rg-cols { grid-template-columns: 1fr; } }
