/* ---------------------------------------------------------------------------
 * IK000210_P01.xfdl 변환본 — IK 부서 마스터 관리 모달 (600x400).
 * Modal #A 27번째 인스턴스 + *폼 카테고리 7번째 사례*.
 *
 * IK000200_P01 (팀 등록 다구역) 의 *단순화 버전*:
 *   - 4 구역 → 2 구역 (입력 폼 + 그리드)
 *   - lookup 의존 없음 (단일 도메인 CRUD)
 *   - 그리드 셀 더블클릭 → 폼 채움 (수정 모드)
 *
 * 디자인:
 *   - 헤더: 폼 정형색 (#2c4368)
 *   - 본문: 입력 카드 + 미니 그리드
 *   - 푸터: 닫기 (bState true = 부모 재조회)
 * --------------------------------------------------------------------------- */

#ik-dept-master-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  font-family: 'Pretendard', 'Malgun Gothic', sans-serif;
}
#ik-dept-master-modal.is-open { display: flex; }

#ik-dept-master-modal .layer-wrap {
  width: 620px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#ik-dept-master-modal .layer-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 2px solid #2c4368;
  background: #2c4368;
  color: #ffffff;
}
#ik-dept-master-modal .layer-title { flex: 1; font-size: 14px; font-weight: 600; margin: 0; }
#ik-dept-master-modal .layer-close {
  background: transparent; border: 0; color: #ffffff; font-size: 20px; cursor: pointer; line-height: 1;
}
#ik-dept-master-modal .layer-content {
  padding: 12px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

#ik-dept-master-modal .input-card {
  background: #f7fafe;
  border: 1px solid #d8e3f0;
  border-radius: 4px;
  padding: 10px 12px;
}
#ik-dept-master-modal .input-grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 6px 8px;
  font-size: 12px;
  align-items: center;
}
#ik-dept-master-modal .input-grid label { color: #344b6e; font-weight: 600; }
#ik-dept-master-modal .input-grid input {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid #c8d3e0;
  border-radius: 3px;
}
#ik-dept-master-modal .input-grid input[readonly] { background: #f0f4f9; }
#ik-dept-master-modal .input-grid .field-with-btn {
  display: flex; gap: 4px; align-items: center;
}
#ik-dept-master-modal .input-grid .field-with-btn input { flex: 1; }
#ik-dept-master-modal .input-grid .field-with-btn button {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid #2c4368;
  background: #ffffff;
  color: #2c4368;
  border-radius: 3px;
  cursor: pointer;
}
#ik-dept-master-modal .input-grid .field-with-btn button:disabled {
  opacity: 0.4; cursor: not-allowed;
}

#ik-dept-master-modal .grid-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;
}
#ik-dept-master-modal .grid-head .btn-area { display: flex; gap: 4px; }
#ik-dept-master-modal .grid-head button {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid #c8d3e0;
  background: #ffffff;
  color: #344b6e;
  border-radius: 3px;
  cursor: pointer;
}

#ik-dept-master-modal .mini-grid-shell {
  border: 1px solid #c8d3e0;
  border-radius: 3px;
  max-height: 220px;
  overflow: auto;
  background: #ffffff;
}
#ik-dept-master-modal .mini-grid-shell table {
  width: 100%; border-collapse: collapse; font-size: 11px;
}
#ik-dept-master-modal .mini-grid-shell th,
#ik-dept-master-modal .mini-grid-shell td {
  padding: 4px 6px; border-bottom: 1px solid #e3e8ee; text-align: center;
}
#ik-dept-master-modal .mini-grid-shell th {
  background: #f0f4f9; color: #344b6e; font-weight: 600; position: sticky; top: 0;
}
#ik-dept-master-modal .mini-grid-shell tr { cursor: pointer; }
#ik-dept-master-modal .mini-grid-shell tr:hover td { background: #f7fafe; }
#ik-dept-master-modal .mini-grid-shell tr.selected td { background: #e3eef7; }
#ik-dept-master-modal .mini-grid-shell .empty-row { cursor: default; }
#ik-dept-master-modal .mini-grid-shell .empty-row td {
  text-align: center; color: #888; padding: 24px 8px;
}

#ik-dept-master-modal .layer-footer {
  display: flex; justify-content: flex-end;
  padding: 10px 16px;
  border-top: 1px solid #e1e5eb;
  background: #f7f8fa;
  gap: 6px;
}
#ik-dept-master-modal .btn {
  min-width: 80px; padding: 6px 12px; border-radius: 3px;
  font-size: 12px; cursor: pointer;
  border: 1px solid #c8d3e0; background: #ffffff; color: #344b6e;
}
#ik-dept-master-modal .btn.primary {
  border-color: #2c4368; background: #2c4368; color: #ffffff;
}
#ik-dept-master-modal .btn:hover { background: #f0f4f9; }
#ik-dept-master-modal .btn.primary:hover { background: #1f314c; }
