:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2f5fe0;
  --danger: #d64545;
  --warn: #d99a1f;
  --ok: #2f9e5b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 17px; }
.topbar nav a { margin-right: 16px; color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--accent); }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.summary-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.summary-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  min-width: 100px;
}
.summary-stat .num { font-size: 20px; font-weight: 700; }
.summary-stat .label { font-size: 12px; color: var(--muted); }
.summary-stat.warn .num { color: var(--warn); }
.summary-stat.danger .num { color: var(--danger); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 8px;
}

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small { padding: 3px 8px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-waiting { background: #eef0f4; color: var(--muted); }
.status-progress { background: #e6ecff; color: var(--accent); }
.status-done { background: #e5f6ec; color: var(--ok); }
.status-overdue { background: #fdeaea; color: var(--danger); }
.status-hold { background: #fdf3e0; color: var(--warn); }

#gantt-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
#gantt-flex { display: flex; align-items: flex-start; }
#gantt-sidebar {
  flex: 0 0 200px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.gantt-side-header {
  display: flex;
  align-items: flex-end;
  padding: 0 10px 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}
.gantt-side-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 10px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
}
.gantt-side-row:hover { background: var(--bg); }
.gantt-side-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-side-subtitle { font-size: 12px; color: var(--muted); white-space: nowrap; }
.gantt-side-row-indent { padding-left: 20px; }
.gantt-side-row-indent .gantt-side-title { font-size: 13px; font-weight: 400; color: var(--muted); }

/* Frappe Gantt 바 위 라벨(프로젝트명) 글자 크기 — 기본값이 작아서 키움 */
#gantt-scroll .bar-label { font-size: 13px; font-weight: 600; }
#gantt-scroll .bar-wrapper[data-id^="s"] .bar-label { font-size: 12px; font-weight: 400; }
#gantt-scroll { flex: 1; overflow-x: auto; min-width: 0; }

dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  width: 520px;
  max-width: 92vw;
}
dialog::backdrop { background: rgba(15, 18, 25, 0.45); }
.dialog-body { padding: 20px; }
.dialog-body h2 { margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.stage-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
/* .field input 의 width:100% 규칙이 flex 자식 크기 계산과 충돌하지 않도록 명시적으로 재정의 */
.stage-row input[type="text"] { flex: 2 1 0; width: auto; min-width: 0; }
.stage-row input[type="date"] { flex: 0 0 170px; width: 170px; }
.stage-row input[type="number"] { flex: 1 1 0; width: auto; min-width: 0; }
.stage-row .stage-hint { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stage-row button { flex: 0 0 auto; }

.muted { color: var(--muted); font-size: 13px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 4px 0; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 999;
}
.toast.toast-error { background: var(--danger); }
.toast.hidden { display: none; }

.upcoming-list, .overdue-list { margin: 0; padding-left: 18px; font-size: 13px; }

/* Frappe Gantt 상태별 바 색상 (모비 상태값과 매핑).
   이 버전은 .bar(트랙) 위에 .bar-progress(기본 회색)를 겹쳐 그리므로 둘 다 칠해야
   한다. .bar만 칠하면 회색 진척 막대가 위를 덮어 전부 회색으로 보인다.
   진척률은 Flow가 늘 0으로 주니 부분 채움은 의미가 없고, 상태 색 한 덩어리로
   읽히는 편이 정확하다. */
.bar-wrapper.bar-waiting .bar,
.bar-wrapper.bar-waiting .bar-progress { fill: #c7cbd4; }
.bar-wrapper.bar-progress .bar,
.bar-wrapper.bar-progress .bar-progress { fill: #2f5fe0; }
.bar-wrapper.bar-done .bar,
.bar-wrapper.bar-done .bar-progress { fill: #2f9e5b; }
.bar-wrapper.bar-overdue .bar,
.bar-wrapper.bar-overdue .bar-progress { fill: #d64545; }
.bar-wrapper.bar-hold .bar,
.bar-wrapper.bar-hold .bar-progress { fill: #d99a1f; }
/* 정량목표 막대는 옅게. custom_class로 클래스를 하나 더 붙이면 Frappe Gantt가
   공백 때문에 예외를 내며 막대를 전부 못 그리므로, 과제(c)/정량목표(s)를 구분하는
   task id 접두사로 고른다. */
.bar-wrapper[data-id^="s"] .bar,
.bar-wrapper[data-id^="s"] .bar-progress { opacity: 0.75; }
.hidden { display: none !important; }

/* ---------- Flow 거울 구조 ---------- */

/* 화면 맨 위에서 "여기는 고치는 곳이 아니다"를 먼저 알린다. 이 안내가 없으면
   편집 버튼이 없는 이유를 몰라 Flow와 대시보드를 번갈아 고치게 된다. */
.source-note {
  font-size: 13px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
}
.source-note strong { color: var(--text); }

/* 링크를 버튼처럼 보이게 — button, .btn 규칙을 그대로 타고 크기만 맞춘다. */
a.button-like {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
}

/* 메모 셀: 평소엔 글만 보이고, 마우스를 올리거나 비어 있을 때 버튼이 드러난다. */
.note-cell { min-width: 200px; }
.note-cell .note-text { white-space: pre-wrap; }
.note-cell .note-edit {
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.12s;
}
.note-cell:hover .note-edit,
.note-cell.editing .note-edit,
.note-cell .note-text:empty + .note-edit { opacity: 1; }

.note-editor { margin-top: 6px; }
.note-editor .note-input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  resize: vertical;
}
.note-editor .note-actions { margin-top: 6px; }

/* ---------- 간트 과제 골라보기 ---------- */

#gantt-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

/* 꺼진 과제는 흐리게 — 없어진 게 아니라 접어둔 것임이 보여야 한다. */
.gantt-chip {
  opacity: 0.45;
  border-radius: 999px;
}
.gantt-chip.on {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}
.gantt-chip-count {
  opacity: 0.65;
  font-size: 11px;
  margin-left: 2px;
}
